fix(managed): guard experimental authorization and startup requests
Reject explicit candidate-ID and inherited-policy CLI bypasses of the guarded native-circular operator path. Validate empty private runtime-owned request inodes without following links before state mutation, atomically claim and sync them before apply, retain failed claims, and never delete replacement requests. Keep internal journal reconciliation and legacy qualification unchanged. Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
371382c2c4
commit
f88c8e9c45
6 files changed
+294
-13
No files matched your search
@@ -60,7 +60,7 @@ func managedArguments(args []string) (string, []int64, error) {
|
||||
if len(args) == 2 && args[0] == "status" && args[1] == "--assets" {
|
||||
return "status", nil, nil
|
||||
}
|
||||
if len(args) == 1 && (args[0] == "init" || args[0] == "reconcile" || args[0] == "status" || args[0] == "active-ids") {
|
||||
if len(args) == 1 && (args[0] == "init" || args[0] == "reconcile" || args[0] == "status" || args[0] == "active-ids" || args[0] == "experimental-request-check") {
|
||||
return args[0], nil, nil
|
||||
}
|
||||
if len(args) < 3 || len(args)%2 != 1 || args[0] != "apply" {
|
||||
@@ -70,9 +70,17 @@ func managedArguments(args []string) (string, []int64, error) {
|
||||
seen := map[int64]bool{}
|
||||
scopeSeen := false
|
||||
experiment := false
|
||||
request := false
|
||||
var scope GooglevideoScope
|
||||
for i := 1; i < len(args); i += 2 {
|
||||
key := args[i]
|
||||
if key == "--googlevideo-request" {
|
||||
if request || args[i+1] != "startup" {
|
||||
return "", nil, invalid
|
||||
}
|
||||
request = true
|
||||
continue
|
||||
}
|
||||
if key == "--googlevideo-experiment" {
|
||||
if experiment || args[i+1] != "native-circular" {
|
||||
return "", nil, invalid
|
||||
@@ -117,6 +125,9 @@ func managedArguments(args []string) (string, []int64, error) {
|
||||
}
|
||||
return "experiment", nil, nil
|
||||
}
|
||||
if request || scope == GooglevideoScopeExperimental {
|
||||
return "", nil, invalid
|
||||
}
|
||||
for _, key := range []string{"--frontend-candidate", "--googlevideo-candidate", "--asset-candidate"} {
|
||||
ids = append(ids, selected[key]...)
|
||||
}
|
||||
@@ -381,7 +392,9 @@ func managedCLI(args []string, stdout, stderr io.Writer, d managedDeps) int {
|
||||
return 1
|
||||
}
|
||||
m := &managedTransaction{Dir: dir, Name: "config", Reload: func() error { return d.run(d.script, "restart") }, Health: func() (string, error) { return "", fmt.Errorf("health not configured") }}
|
||||
if command == "init" {
|
||||
if command == "experimental-request-check" {
|
||||
err = managedExperimentalRequest(dir, false, nil)
|
||||
} else if command == "init" {
|
||||
err = managedInitialize(m)
|
||||
} else if err = managedCheckIdentity(m); err == nil {
|
||||
if command == "reconcile" {
|
||||
@@ -389,7 +402,15 @@ func managedCLI(args []string, stdout, stderr io.Writer, d managedDeps) int {
|
||||
} else if command == "status" || command == "active-ids" {
|
||||
err = managedReport(m, stdout, d.openDB, command == "active-ids", len(args) == 2 && args[1] == "--assets")
|
||||
} else if command == "experiment" {
|
||||
err = managedExperimentalSuffix(m, d)
|
||||
startup := false
|
||||
for i := 1; i < len(args); i += 2 {
|
||||
startup = startup || args[i] == "--googlevideo-request"
|
||||
}
|
||||
if startup {
|
||||
err = managedExperimentalRequest(dir, true, func() error { return managedExperimentalSuffix(m, d) })
|
||||
} else {
|
||||
err = managedExperimentalSuffix(m, d)
|
||||
}
|
||||
} else {
|
||||
expected := map[int64]string{}
|
||||
var scopes []GooglevideoScope
|
||||
@@ -407,7 +428,14 @@ func managedCLI(args []string, stdout, stderr io.Writer, d managedDeps) int {
|
||||
expected[id] = group
|
||||
}
|
||||
}
|
||||
err = managedActivate(m, d, ids, expected, scopes...)
|
||||
journal, loadErr := m.load()
|
||||
if loadErr != nil {
|
||||
err = loadErr
|
||||
} else if journal.Scope == GooglevideoScopeExperimental && len(scopes) == 0 {
|
||||
err = fmt.Errorf("experimental CLI apply requires explicit guarded operator path")
|
||||
} else {
|
||||
err = managedActivate(m, d, ids, expected, scopes...)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user