fix: enforce trusted-before-project ordering for hooks#15936
fix: enforce trusted-before-project ordering for hooks#15936viyatb-oai wants to merge 7 commits intocodex/viyatb/trusted-project-config-gatingfrom
Conversation
8dfdefd to
a5e69ff
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9401e5ff84
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let projects_trust = projects | ||
| .into_iter() | ||
| .filter_map(|(key, project)| project.trust_level.map(|trust_level| (key, trust_level))) | ||
| .flat_map(|(key, project)| { | ||
| project.trust_level.into_iter().flat_map(move |trust_level| { | ||
| normalized_project_trust_key_strs(&key) | ||
| .into_iter() | ||
| .map(move |normalized_key| (normalized_key, trust_level)) | ||
| }) | ||
| }) | ||
| .collect(); |
There was a problem hiding this comment.
Resolve canonical trust-key collisions deterministically
project_trust_context canonicalizes each project key and then collects into a HashMap. If config contains two different keys that resolve to the same canonical path (e.g. symlink path vs real path) with conflicting trust_level, the later insert wins. Because HashMap iteration order is not stable, trust can flip between trusted/untrusted across runs, enabling or disabling project hooks/config unpredictably.
Useful? React with 👍 / 👎.
Co-authored-by: Codex noreply@openai.com
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex noreply@openai.com
Co-authored-by: Codex noreply@openai.com
Co-authored-by: Codex noreply@openai.com
9401e5f to
f0f222a
Compare
Summary
PreToolUse,SessionStart, andUserPromptSubmitSecurity
PreToolUserace where a project hook could observe or exfiltrate a tool invocation before a higher-precedence user or managed hook denied itUserPromptSubmitorSessionStarthooks could observe prompt or startup data before a higher-precedence hook stopped processingStack
.codex/hooks.jsonexists without.codex/config.tomlTest
cargo test -p codex-hookscodex-coreregressions covering project hooks withoutconfig.tomlcargo clippy -p codex-core -p codex-hooks --tests -- -D warningscargo clippy -p codex-core --tests -- -D warnings