fix(19.6.1-04): refuse code-declared role capture and wrap Administrators Runs
- Roles create and update refuse a submitted code that code-declared grants attach to - compileActionExtensions wraps contributed Administrators Runs with guardOutranked - Prove both holes on Postgres; keep the boot smoke callable with a superuser principal Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package cabana
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/bouncer"
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
"git.golem15.com/golem15/summercms/modules/party"
|
||||
)
|
||||
@@ -48,6 +50,9 @@ func compileActionExtensions(reg *Registry, plugins []party.Plugin) error {
|
||||
if err := checkContributedAction(cc, pluginID, ext.Controller, action); err != nil {
|
||||
return err
|
||||
}
|
||||
if ext.Controller == AdministratorsControllerID {
|
||||
action.Run = wrapAdministratorsContributedRun(reg, action.Run)
|
||||
}
|
||||
// A new slice and map: the compiled backing array may be
|
||||
// shared with another schema value.
|
||||
names := make([]string, 0, len(cc.Form.recordActions)+1)
|
||||
@@ -95,3 +100,21 @@ func checkContributedAction(cc *CompiledController, pluginID, controller string,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// wrapAdministratorsContributedRun runs guardOutranked on the locked
|
||||
// Administrators record before the contributor's Run (D-19). Contributions
|
||||
// to any other controller are stored unchanged. The wrap is not exported:
|
||||
// cabana owns the privilege check.
|
||||
func wrapAdministratorsContributedRun(reg *Registry, next func(context.Context, pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error)) func(context.Context, pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error) {
|
||||
return func(ctx context.Context, in pact.AdminRecordActionInput) (pact.AdminRecordActionResult, error) {
|
||||
principal, _ := bouncer.User(ctx)
|
||||
user, ok := in.Record.(*BackendUser)
|
||||
if !ok || user == nil {
|
||||
return pact.AdminRecordActionResult{}, fmt.Errorf("cabana: contributed Administrators action: record is not a backend user")
|
||||
}
|
||||
if err := guardOutranked(ctx, reg, principal, user); err != nil {
|
||||
return pact.AdminRecordActionResult{}, err
|
||||
}
|
||||
return next(ctx, in)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user