Skip to content

codex-protected-file-guard

Block protected files, secret-bearing paths, git internals, traversal, and direct lockfile edits in Codex.

hook PreToolUse codex mode: enforce

Block protected files, secret-bearing paths, git internals, traversal, and direct lockfile edits in Codex.

FieldValue
idcodex-protected-file-guard
status_messageChecking protected paths
modeenforce
logical_eventPreToolUse
matcherWrite|Edit|MultiEdit|apply_patch|edit|create|replace|write_file|Bash|bash|run_shell_command
commandpython3 {repo_root}/hooks/wagents-hook.py codex-protected-file-guard --harness {harness}
timeout5
harnesses["codex"]
Full hook config + command reference
config/hook-registry.json (entry)
{
"id": "codex-protected-file-guard",
"description": "Block protected files, secret-bearing paths, git internals, traversal, and direct lockfile edits in Codex.",
"status_message": "Checking protected paths",
"mode": "enforce",
"logical_event": "PreToolUse",
"matcher": "Write|Edit|MultiEdit|apply_patch|edit|create|replace|write_file|Bash|bash|run_shell_command",
"command": "python3 {repo_root}/hooks/wagents-hook.py codex-protected-file-guard --harness {harness}",
"timeout": 5,
"harnesses": [
"codex"
]
}
hooks/wagents-hook.py (policy excerpt)
def _policy_codex_protected_file_guard(payload: NormalizedPayload) -> int:
reason = _protected_payload_reason(payload)
if reason:
return _deny(payload, reason, policy_id="codex-protected-file-guard")
return 0

Command (Codex): python3 {repo_root}/hooks/wagents-hook.py codex-protected-file-guard --harness codex


View source on GitHub