Repository navigation
feat(exec): expose knownLongFlags in safeBinProfiles config schema - #56806
spencer2211 wants to merge 1 commit into
Conversation
Greptile SummaryThis PR exposes the Key changes:
The merge-over-replace strategy is the right call: it preserves the invariant that every flag in Confidence Score: 5/5Safe to merge — the change is additive, backwards-compatible, and the core validator logic is unchanged. No P0 or P1 issues found. The Zod schema fix, fixture type update, normalization flow, and merge strategy are all correct. Edge cases (flags-in-both-sets, empty arrays, non---prefixed strings) are handled safely by the existing validator pipeline. The 6 new tests exercise the important paths including GNU abbreviation, denial precedence, and merge idempotency. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/config/zod-schema.agent-runtime.ts | Added knownLongFlags: z.array(z.string()).optional() to ToolExecSafeBinProfileSchema; directly fixes the .strict() crash. Consistent with adjacent fields. |
| src/infra/exec-safe-bin-policy-profiles.ts | Added knownLongFlags to SafeBinProfileFixture type; merge strategy in compileSafeBinProfile unions user-provided flags with auto-derived flags correctly; normalizeSafeBinProfileFixture delegates to normalizeFixtureFlags consistently. |
| src/config/normalize-exec-safe-bin.ts | Type cast updated to include knownLongFlags, keeping it in sync with SafeBinProfileFixture. |
| src/config/schema.base.generated.ts | Regenerated schema correctly reflects the new knownLongFlags field in both relevant locations. |
| src/infra/exec-safe-bin-policy.test.ts | 6 new tests covering boolean flags, inline value rejection, unknown flag rejection, merge idempotency, GNU abbreviation, and deduplication with allow/deny — all assertions are correct. |
Reviews (1): Last reviewed commit: "feat(exec): expose knownLongFlags in saf..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 856a903119
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const knownLongFlags = collectKnownLongFlags(allowedValueFlags, deniedFlags); | ||
| const derivedKnownLongFlags = collectKnownLongFlags(allowedValueFlags, deniedFlags); | ||
| const knownLongFlags = fixture.knownLongFlags | ||
| ? Array.from(new Set([...derivedKnownLongFlags, ...fixture.knownLongFlags])) |
There was a problem hiding this comment.
Reject abbreviated entries in knownLongFlags
Merging fixture.knownLongFlags directly into the compiled profile allows non-canonical prefixes (for example --rec) to become exact canonical hits. In validateSafeBinArgv, resolveCanonicalLongFlag checks knownLongFlagsSet before prefix resolution, so --rec is treated as canonical --rec and bypasses deniedFlags entries like --recursive; GNU tools can still interpret --rec as --recursive, re-enabling denied behavior. Since this commit exposes knownLongFlags through config, this creates a new denial-bypass path for misconfigured profiles unless knownLongFlags is validated/normalized to full canonical long flags.
Useful? React with 👍 / 👎.
…lags Addresses review feedback on PR openclaw#56806. User-provided knownLongFlags entries that are strict prefixes of denied flags (e.g. "--rec" when "--recursive" is denied) would get exact-match priority in resolveCanonicalLongFlag, bypassing the denial check. The flag resolves to itself rather than the denied canonical form. Filter these entries at compile time in compileSafeBinProfile. Full canonical forms (e.g. "--recursive" itself) are unaffected — they're already auto-derived from deniedFlags and denied at validation time. Adds 2 tests covering the prefix-filtering and non-prefix preservation. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Thanks for flagging this — the concern is valid. A user-provided Fixed in 481f67b: Added 2 tests:
|
|
Friendly bump — this has been open for a couple of weeks now. Happy to address any feedback or make changes if needed. Also happy to rebase if the branch has drifted. Re: the Codex bot's note about abbreviated flags in |
|
Small clarification on my comment from April 10 — I said I was "happy to rebase or add validation if the team prefers," but looking back at the branch history, validation was actually already pushed in That commit filters any user-supplied |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Codex review: needs maintainer review before merge. Reviewed July 20, 2026, 7:57 PM ET / 23:57 UTC. Summary PR surface: Source +23, Tests +111, Docs +13, Generated 0. Total +147 across 8 files. Reproducibility: yes. for the reported configuration gap: current main's strict schema lacks Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Close this stale PR as superseded: Decline the public setting. Keep the current built-in-only recognition model so custom profiles cannot expand the auto-approved boolean-flag surface. Do we have a high-confidence way to reproduce the issue? Yes for the reported configuration gap: current main's strict schema lacks Is this the best way to solve the issue? Unclear. The implementation is a narrow solution to the schema gap, but current adjacent safe-bin work intentionally keeps comparable boolean-flag recognition built-in-only, so maintainer product approval is required before calling this the best solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2220e9f84184. Label changesLabel justifications:
Evidence reviewedPR surface: Source +23, Tests +111, Docs +13, Generated 0. Total +147 across 8 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (5 earlier review cycles)
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
481f67b to
d3209dc
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. |
d3209dc to
c8f79b0
Compare
|
Rebased onto current Re-verified on current
Real-behavior proof and the strict-prefix denial-bypass filter (the original Codex P1) are unchanged. |
c8f79b0 to
f2cc40a
Compare
|
Refreshed against current Re-verified on current
|
f2cc40a to
69923f7
Compare
|
Refreshed against current Rebase: branch had gone
P3 (review finding — docs overview alignment): Re-verified on the new head (Node 22):
The strict-prefix denial-bypass filter (original Codex P1) is unchanged. The remaining item — accepting @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
69923f7 to
cbe4b33
Compare
|
Refreshed against current Conflicts resolved:
Re-verified on the new head (Node 22):
The strict-prefix denial-bypass filter (original Codex P1) is unchanged. The remaining item — accepting @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
knownLongFlags is used internally by validateSafeBinArgv for GNU long-option abbreviation resolution, but was not exposed in the config schema. Attempting to set it crashed the strict() Zod schema with an "Unrecognized key" error. This change: - Adds knownLongFlags to ToolExecSafeBinProfileSchema (Zod) and the SafeBinProfileFixture type, and normalizes it in the config + fixture normalizers - Merges user-provided knownLongFlags with the auto-derived set from allowedValueFlags union deniedFlags in compileSafeBinProfile - Filters any user entry that is a strict prefix of a denied flag, so a short form like "--rec" cannot gain exact-match priority and bypass the denial of "--recursive" (addresses prior Codex review feedback) - Documents the field, its auto-derivation default, and the prefix-filter security semantics in docs/tools/exec-approvals-advanced.md - Regenerates docs/.generated/config-baseline.sha256 for the new field - Adds 8 tests covering the config path, GNU abbreviation, merge with auto-derivation, and the strict-prefix-of-denied security filter Backwards-compatible: existing configs without knownLongFlags continue to work identically via auto-derivation. Closes openclaw#56805 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cbe4b33 to
510a228
Compare
|
Refreshed against current
Green locally: 117/117 infra unit tests, @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Closing per ClawSweeper review verdict |
Summary
Expose the
knownLongFlagsfield in thesafeBinProfilesconfig schema, allowing operators to declare long flags as "known" for GNU abbreviation resolution without misusingallowedValueFlagsordeniedFlags.Closes #56805
Problem
The
knownLongFlagsfield exists internally inSafeBinProfileand is used byvalidateSafeBinArgvfor GNU long-option abbreviation resolution. However, it is not present in:ToolExecSafeBinProfileSchema) —.strict()rejects it as an unknown keySafeBinProfileFixturetype — no way to pass it through config normalizationFor empty profiles
{},knownLongFlagsauto-derives as[], causing all long flags to be treated as unknown and rejected. The only workaround is to list every possible long flag inallowedValueFlagsordeniedFlags, which changes their semantics.Changes
src/config/zod-schema.agent-runtime.tsknownLongFlags: z.array(z.string()).optional()toToolExecSafeBinProfileSchemasrc/infra/exec-safe-bin-policy-profiles.tsknownLongFlagstoSafeBinProfileFixture; normalize it innormalizeSafeBinProfileFixture; merge user-provided with auto-derived flags incompileSafeBinProfile, filtering strict prefixes of denied flagssrc/config/normalize-exec-safe-bin.tsknownLongFlagsto the type cast in normalizationdocs/tools/exec-approvals-advanced.mddocs/.generated/config-baseline.sha256pnpm config:docs:genfor the new fieldsrc/infra/exec-safe-bin-policy.test.tsDesign Decisions
knownLongFlagsare merged with auto-derived flags fromallowedValueFlags ∪ deniedFlags, so flags in those lists stay "known" even if not explicitly listed.--recwhen--recursiveis denied) is filtered at compile time, so it cannot gain exact-match priority inresolveCanonicalLongFlagand bypass the denial. (Addresses the prior Codex review P1.)normalizeFixtureFlags: Same normalization (trim, dedupe, sort) as other flag arrays.knownLongFlagswork identically via auto-derivation.Usage
Real behavior proof
Behavior or issue addressed: Setting
tools.exec.safeBinProfiles.<bin>.knownLongFlagsin a real config previously could not be accepted — the strict Zod schema had no such key. After this patch the field is accepted by config validation and is honored by the safe-bin argv validator (declared long flags resolve, including GNU abbreviation), while strict prefixes of denied flags are still blocked.Real environment tested: Local OpenClaw build from this branch,
OpenClaw 2026.6.2 (bb6e477), Node v22.22.0, run via the realopenclawCLI and the compiledexec-safe-bin-policymodule (not mocks).Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: The live
openclaw config validatereturnsvalid: truefor a config carryingknownLongFlags, and still returnsvalid: falsefor an unknown sibling key — confirming the field is genuinely wired into the strict schema. At runtime the compiled validator accepts the user-declared--verbose, resolves the--verbabbreviation to it, keeps--recursivedenied, and drops the--recprefix so it cannot bypass that denial.What was not tested: End-to-end exec of a real third-party binary through the approval pipeline (requires a trusted-dir executable); behavior is covered at the policy/validator layer instead.
Test Plan
exec-safe-bin-policy.test.tspass: 98 passed (90 existing + 8 new) undervitest.infra.config.tspnpm config:docs:checkandpnpm config:schema:checkpass (baseline in sync, no drift)oxlintclean on changed files; no new type errors introducedopenclawCLI and compiled validator