Skip to content

feat(detectors): broaden Claude grant/deny coverage and harden instruction scan#51

Merged
Conalh merged 1 commit into
mainfrom
pr5-detector-coverage
May 29, 2026
Merged

feat(detectors): broaden Claude grant/deny coverage and harden instruction scan#51
Conalh merged 1 commit into
mainfrom
pr5-detector-coverage

Conversation

@Conalh
Copy link
Copy Markdown
Owner

@Conalh Conalh commented May 29, 2026

Addresses review findings #5, #6, #7.

Claude permissions (parsers/claude.ts)

#5 — bare tool grants. isBroadAllow flagged bare WebFetch/WebSearch/Task and wildcard/broad-root forms, but not a bare Bash, Read, Write, or Edit. In Claude Code a bare tool name matches every use of the tool, so those grant unrestricted shell / filesystem access and are now treated as broad.

Filesystem verbs get correct scope semantics: a scoped subtree glob like Read(src/**) stays narrow (it's not a broad grant); only bare (Read) or broad-root (Read(/), Write(C:\), Read(~/**), Read(**)) forms are broad. Bash/Web/Task remain broad on any wildcard scope (Bash(npm *)).

#6 — sensitive denies. Expanded isSensitiveDeny beyond .env/secret/credential/.pem to also cover SSH & signing keys (.ssh, id_rsa, id_ed25519, .key, .p12, .pfx), token, .npmrc/.pypirc/.netrc, kubeconfig, and cloud credential stores (.gcp, .azure; .aws/credentials already matched credential). The posture-gap and deny/allow-overlap detectors depend on recognising strict denies, so the list errs toward inclusion (a deny is the protective side).

Instruction scan (parsers/instructions.ts)

#7 — legacy .cursorrules is now scanned alongside AGENTS.md, CLAUDE.md, Copilot instructions, and .cursor/rules/*.

#7 — fenced code. The scanner now tracks Markdown code fences (```/~~~) and skips their contents, so a documentation example showing a "bad" instruction (Ignore all safety checks… inside a fence) is no longer flagged as a live directive. A real directive outside the fence still fires.

Tests

Unit tests for bare-vs-scoped grants (incl. Read(src/**) stays narrow) and the expanded sensitive-deny list; CLI tests for .cursorrules scanning and fenced-code skipping. The previously-clean aligned fixture stays at none rating (caught a regression where Read(src/**) was briefly mis-flagged). All 122 tests pass; dist/ rebuilt and committed.

🤖 Generated with Claude Code

…ction scan

Claude permissions (parsers/claude.ts):
- Treat a bare `Bash`, `Read`, `Write`, or `Edit` allow as broad. In Claude
  Code a bare tool name matches every use of the tool, so it grants
  unrestricted shell / filesystem access — previously only bare WebFetch /
  WebSearch / Task and wildcard/broad-root forms were flagged. Filesystem
  verbs keep narrow semantics for scoped subtree globs (Read(src/**) stays
  narrow); only bare or broad-root forms (Read(/), Write(C:\), Read(~/**))
  are broad. Bash/Web/Task remain broad on any wildcard scope.
- Expand isSensitiveDeny beyond .env/secret/credential/.pem to cover SSH and
  signing keys, tokens, .npmrc/.pypirc/.netrc, kubeconfig, cloud credential
  stores, and .p12/.pfx/.key. The posture-gap and overlap detectors depend on
  recognising strict denies, so the list errs toward inclusion.

Instruction scan (parsers/instructions.ts):
- Scan the legacy single-file `.cursorrules` alongside the modern surfaces.
- Track Markdown fenced code blocks (``` / ~~~) and skip their contents, so a
  documentation example showing a "bad" instruction is no longer flagged as a
  live directive.

Tests cover bare vs scoped grants, the expanded sensitive-deny list,
.cursorrules scanning, and fenced-code skipping (real directive outside the
fence still fires).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Conalh Conalh merged commit a18eb84 into main May 29, 2026
5 checks passed
@Conalh Conalh deleted the pr5-detector-coverage branch May 29, 2026 15:58
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.

1 participant