Skip to content

feat(claude-config): script the deterministic audit checks and emit audit-pass-shaped findings - #3991

Merged
kyle-sexton merged 7 commits into
mainfrom
claude/config-audit-a4277l
Sep 9, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
claude/config-audit-a4277l

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Closes #3989
Closes #3990

Summary

The claude-config:audit skill now runs a deterministic engine for every check that needs no reasoning and reserves the model for judgment. The engine writes its findings in the audit-pass identity shape, so the two skills share one suppression record. The drift and hook-coverage bugs found during the audit of this repository are fixed, and the repository's own audit findings are applied.

Fix

  • scripts/audit-engine.sh (new): scope discovery, JSON validity, $schema, baseline deny and ask patterns from required-permissions.md, the three narrowings, hook inventory, plugin drift, skill-listing budget from the session debug log, and the env-vars page cross-check. --table or --json; --out writes a findings artifact with check, claim, sites (anchor/v1), and finding_id; anchor and finding-id subcommands give a judged finding the same identity. A scope the engine cannot read is reported as not inspectable, never clean. Reads .claude/audit-pass.md through the config-cascade layers: only the team layer suppresses, personal-only entries are reported as not applied, and malformed entries never suppress. Every table finding carries a paste-ready suppress: line.
  • Narrowing 3 is corroborated before it is taken. A coverage manifest is a plugin's claim about its own enforcement, so an entry narrows a baseline family only when the hook it names appears in the enumerated inventory on the event and matcher it declares, matched on the hook's file name so a dispatcher that runs the named guard still counts. An entry naming no such hook is reported and narrows nothing. When a settings scope does not parse, the inventory reports the suppression-lever state unknown and the engine refuses the narrowing rather than reading unread levers as unset. required-permissions.md carries both as preconditions.
  • Category D never persists a hook command that should not be tracked. A command from a personal scope, and any command matching the secret-shaped-value pattern, is named by its excerpt hash in every claim and detail, so the suppression stanza an operator pastes into tracked source cannot carry a credential.
  • scripts/check-doc-citations.sh + reference/doc-citations.tsv (new): verifies every quoted upstream span against the live page, including a final row with no trailing newline. The permissions page had already moved under one span; it is re-quoted. The manifest also pins the sentence stating that CLAUDE_CODE_DEBUG_LOGS_DIR is a file path despite its name.
  • check-plugin-drift.sh: directory-source marketplaces resolve against <path>/.claude-plugin/marketplace.json, not the registry cache; reports source. A missing curl is no longer fatal: directory-sourced catalogs still audit and each repo-sourced one is recorded as a fetch failure.
  • check-hook-coverage.sh: marketplace-directory-first resolution, DIVERGENCE when the cache copy differs, an unparsable directory catalog reported rather than read as "plugin absent", lever_state, and a widened --json (project root, hook timeout/type/args, plugin paths, divergence list).
  • guardrails hooks/coverage.json (new): the coverage manifest that turns the narrowing into a lookup. Guardrails 0.32.23.
  • SKILL.md and context docs: phases run the engine first; Phase 3 runs the citation checker, points settings keys at settings-reference, and degrades the known-issues check from the API to /claude-ops:known-issues to an unverified statement dated from the new Last verified column; Phase 4 reports suppressed and undecided rows and persists the findings artifact; ## Next section added. B.5 rows are info. A debug log the engine discovered rather than was given settles the skill-listing row only when the log names the project being audited.
  • audit-pass: /claude-config:audit is a delegated lane. Rows append unchanged; engine rows carry the derived tier, model rows judged.
  • Repository config: .claude/settings.json carries the baseline Read denies; .claude/audit-pass.md records the team decision that cloud sessions push without an ask gate; docs/CLOUD-SESSIONS.md states the playgrounds opt-out reason.
  • claude-config 0.41.0 with a CHANGELOG entry.

Verification

  • scripts/affected-tests.sh --run: every selected suite passes.
  • audit-engine.test.sh 118 checks as a non-root user (114 as root, where the unreadable-file case skips), check-hook-coverage.test.sh 85, check-plugin-drift.test.sh 75, check-doc-citations.test.sh 21, coverage-manifest.test.sh 17.
  • check-doc-citations.sh live: 33 spans checked, 0 missing.
  • audit-engine.sh on this repository: 126 rows, 15 findings, 0 errors, 0 warnings, the two ask-gate rows suppressed by the team layer.
  • check-changelog-parity.sh --check and --check-bump origin/main, check-contract-slice-prune.sh --check-diff origin/main, check-shell-portability.sh origin/main, and validate-plugins.sh pass; shellcheck, shfmt, and markdownlint clean on every changed file.
  • Every review thread from the code-review, security-review, and Codex lanes is answered and resolved. One Codex suggestion was rejected against the primary source: the env-vars page states CLAUDE_CODE_DEBUG_LOGS_DIR is a file path, not a directory, and that sentence is now covered by the citation checker.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD

Interview output for scoping changes to the claude-config audit skill:
script-first engine for deterministic rows, audit-pass-shaped findings,
declared session posture, plugin-declared hook coverage, and the
mechanical fixes observed on a 2026-09-08 cloud run.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
…udit-pass-shaped findings

The audit skill now runs an engine for every check that needs no reasoning
and reserves the model for judgment. audit-engine.sh covers scope discovery,
JSON validity, the baseline deny and ask patterns, the three narrowings,
hook inventory, plugin drift, the skill-listing budget, and the env-vars
cross-check, and writes a findings artifact in the audit-pass identity
shape so both skills share one suppression record. Scopes it cannot read
are reported as not inspectable rather than clean.

check-plugin-drift.sh resolves directory-source marketplaces against the
marketplace directory instead of the registry cache, and
check-hook-coverage.sh resolves plugins marketplace-directory first and
reports cache divergence. check-doc-citations.sh verifies every quoted
upstream span against the live page; the permissions page had already
moved under one of them, which is re-quoted here. Guardrails ships a
hooks/coverage.json manifest so the narrowing is a lookup.

The repository's own findings are applied: project settings carry the
baseline Read denies, and .claude/audit-pass.md records the team decision
that cloud sessions push without an ask gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
…4277l

# Conflicts:
#	plugins/claude-config/.claude-plugin/plugin.json
#	plugins/claude-config/CHANGELOG.md
@kyle-sexton
kyle-sexton marked this pull request as ready for review September 9, 2026 01:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-09T01:27:57.269599Z 8799a11 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 9m 32s —— View job


Claude finished the code review

Ran /review:code-review's procedure: read the changed scripts in full, fanned out subagents per file to hunt correctness bugs, then independently verified each candidate before posting (adversarial validation — the producer of a finding never verified its own finding). Security-scoped findings are intentionally out of scope for this lane (claude-security-review.yml covers those).

5 confirmed findings, posted inline:

  1. check-hook-coverage.sh — args field is double-JSON-encoded, which silently disables audit-engine.sh's placeholder-quoting check for every ordinary shell-form hook (verified end-to-end with jq). Highest severity of the batch: a whole Category D check goes dark.
  2. check-plugin-drift.sh — the pre-existing unconditional curl-required gate defeats the PR's own new directory-source (offline) resolution path, and audit-engine.sh:828 has the same gap on the invocation side. Confirmed via an independent adversarial pass: neither test suite exercises a curl-less host.
  3. audit-engine.sh — resolve_hook_path truncates a quoted command path containing a space, producing a false hook-path-missing error.
  4. audit-engine.sh — a required-permissions.md that exists but fails to parse silently produces zero Category B rows, with no skip/warning row, which contradicts the engine's own stated "never report clean, never inspectable" invariant.
  5. check-hook-coverage.sh — a malformed directory-source marketplace.json is silently treated as "plugin absent" rather than reported unreadable, unlike the jq empty guard used elsewhere in the same file.

Investigated and dropped (didn't survive verification, in the interest of transparency):

  • A candidate finding that check-doc-citations.sh's while read < manifest loop could silently drop the last citation row if the TSV ever lost its trailing newline was confirmed as a real bash mechanic but rejected as a reportable bug — the repo's .editorconfig (insert_final_newline = true) plus its editorconfig-checker CI step already gate that precondition out before merge, so it's defense-in-depth, not a live gap.

Also reviewed, no issues found: the SKILL.md / context / reference doc updates for the audit skill (checked for consistency against the engine's actual field names, severities, and exit codes — all matched), the plugin version bumps and CHANGELOGs, the new hooks/coverage.json manifest against the guard it documents, and the repository's own .claude/settings.json / .claude/audit-pass.md changes.

@claude

claude Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 13m 34s —— View job


Security review — PR #3991

Ran /review:security-review per this repo's CI security-review lane conventions: security issues only, scoped to files changed in this PR, GitHub Actions/zizmor concerns out of scope. The diff is almost entirely new/modified bash (audit tooling), so I hunted for injection, path-traversal, and trust-boundary issues, then adversarially verified each candidate with a separate agent before reporting.

Two findings are posted as inline comments on audit-engine.sh (lines 814 and 735-768). One cross-file finding below.

IMPORTANT — coverage-manifest claim isn't corroborated against the actual hook inventory

audit-engine.sh:552-584, narrowing at :611-617, enabled by check-hook-coverage.sh:353-389 (resolve_marketplace_dir resolves extraKnownMarketplaces directory sources from the project or local settings scope, not just the user-scope plugin registry).

A directory-source marketplace declared in the audited repo's own .claude/settings.json/settings.local.json can point at a repo-controlled plugin directory. audit-engine.sh reads that plugin's hooks/coverage.json and uses it to demote a missing baseline permissions.deny/ask pattern from error to info (dropping it from ERROR_COUNT and flipping the exit code to 0), without ever checking that the manifest's claimed .hook actually appears in the parsed hook inventory (.hook is only used as a display label) or that the hook is a real PreToolUse blocker. The repo's own audit-engine.test.sh:147-161 demonstrates the exact mechanism (a project-scope directory marketplace + a manifest producing exit 0).

This is largely intended narrowing behavior (documented as "narrowing 3" in required-permissions.md) and the demoted row is still emitted, naming the claiming plugin — it doesn't silently vanish. But the engine verifies only two of its three own preconditions (matcher/tool-surface, and levers) and never corroborates that the named hook is real, so a coverage manifest with no actual enforcement code can talk the audit down from error to info for every baseline deny/ask pattern. Given this engine's purpose is to be the trustworthy floor the audit relies on, I'd treat this as worth hardening even though today it's a known narrowing rather than a hidden bug: cross-check .hook against INVENTORY_JSON.hooks[] before populating COVERED_BY, and/or flag when the covering plugin's marketplace resolved through a project/local-scope directory source rather than the user-scope registry.

A third candidate (path traversal via an unvalidated slug in check-doc-citations.sh's curl -o output path) did not survive verification — curl normalizes .. in the request path by default, so a traversal slug also breaks the fetch URL and the -f/rm -f failure path removes the file; the manifest also isn't a real trust boundary since it lives beside the script. Not reported.

No command injection, eval, unsafe temp-file handling, or unsanitized shell-hook execution was found in resolve_hook_path, the awk-based suppression parser, or the plugin-drift/curl calls — those were checked and are sound (suppression cascade correctly refuses to let personal/local layers suppress; every id is re-hashed against its own key).

…nreadable scope

Bash applies redirections left to right, so `: <file 2>/dev/null` prints
the open() failure before stderr is redirected. The engine's probe, the
test's own root guard, and check-structure.sh redirect stderr first, so an
unreadable settings.local.json no longer prefixes the JSON document with a
permission-denied line. The engine suite's case 13 now runs cleanly as a
non-root user, which is how CI runs it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

…e audit scripts

The four new scripts carry the executable bit the exec-bit gate expects.
The two test fixtures that spell a Windows path no longer read as a GNU
regex escape to the portability lint: one carries the reviewed
portability-ok marker and the other spells its backslashes as the JSON
\ escape. The interview brief under docs/topics is pruned, as the
contract tier requires before merge; its content lives in the design
issue the pull request closes.

check-plugin-drift.sh no longer exits fatally when curl is absent, since
a directory-sourced marketplace needs no network; a repo-sourced one is
recorded as a fetch failure instead. check-doc-citations.sh reads a final
manifest row that has no trailing newline, with a test that proves it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Last security-reviewed head: 8799a117d97f9eafee5e1749d8cebd622444e3e5. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8799a117d9

ℹ️ 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".

…nd hook inventory

check-hook-coverage.sh encodes a hook's args once, so the engine sees an
array and its placeholder-quoting check fires again; an unparsable
directory catalog is reported as unreadable and leaves the inventory
partial instead of reading as "plugin absent".

The engine reads a hook command's first word the way the shell does, so a
quoted path with a space resolves whole. A hook command from a personal
scope, or one carrying a token-shaped value in any scope, is named by its
excerpt hash in every claim and detail, so a pasted suppression stanza
never carries the command. A baseline reference that parses to no pattern
is reported as unparsed rather than producing no category B rows.
Marketplace names are matched as fixed strings, and the drift script runs
without curl.

Fixing the redaction exposed a latent gap: the tab-separated inventory
read folded an empty timeout field, so every hook without a timeout
shifted its type into the timeout column and dropped out of category D.
The read now carries a sentinel for an empty middle field.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
A coverage manifest is a plugin's claim about its own enforcement, not
evidence of it. The engine now takes an entry only when the hook it names
appears in the enumerated inventory on the event and matcher the entry
declares, matched on the hook's file name so a dispatcher that runs the
named guard as an argument still counts. An entry naming a hook the plugin
does not register is reported and narrows nothing.

An unread lever is not an unset lever. When a settings scope does not
parse, the hook inventory reports its lever state unknown, and the engine
refuses the narrowing and says so, which is what required-permissions.md
already prescribed and the engine did not do.

A debug log the engine discovered rather than was given now settles the
skill-listing row only when the log names the project being audited; the
debug directory also holds other sessions' logs, and a stale one carrying
no warning would otherwise read as clean. CLAUDE_CODE_DEBUG_LOGS_DIR stays
a file path, which the env-vars page states and doc-citations.tsv now pins.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01My8tf3usypMrUUZodghKvD
@kyle-sexton
kyle-sexton merged commit cc4e931 into main Sep 9, 2026
3 checks passed
@kyle-sexton
kyle-sexton deleted the claude/config-audit-a4277l branch September 9, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants