Skip to content

feat(audit): T2 security department — prompt, registry flip, validate CLI, artifact contract - #26

Merged
2233admin merged 1 commit into
mainfrom
feat/audit-security-department
Jul 25, 2026
Merged

feat(audit): T2 security department — prompt, registry flip, validate CLI, artifact contract#26
2233admin merged 1 commit into
mainfrom
feat/audit-security-department

Conversation

@2233admin

Copy link
Copy Markdown
Owner

Closes #19. Part of the audit layer map #17.

Stacked on #24 (feat/audit-kernel-t1) — the T1 kernel is not on main yet, so this PR targets that branch. Review the last commit only; rebase onto main once #24 lands.

What

The first audit department. The kernel was built so a department is a prompt plus a registry flag — that held: no kernel change was needed.

  • orchestration/audit/prompts/security.md — the department prompt, adapted from Fuck_My_Shit_Mountain prompts/security-audit.md (MIT, attributed). Rewritten for this pipeline: threat-model-first (a local CLI that parses untrusted repositories does not get TLS findings), evidence sourced from modalities (xray sweep, ct hotspot ordering, anatomy boundaries, chart for false-positive suppression) with tool hits treated as leads that a targeted read must confirm, and output bound to the fail-closed code-intel-audit-report.v1 contract. Secrets red line: redacted: true, path and variable name only, never the value.
  • orchestration/audit/departments.v1.jsonsecurity flipped to enabled: true (its prompt now exists, so the registry's enabled-requires-prompt rule passes). ai-safety and supply-chain stay disabled.
  • code-intel audit --operation validate|render (crates/code-intel-cli/src/audit_report/cli.rs) — validate parses a report, loads and validates the registry, runs the kernel's fail-closed invariants, and prints a one-line JSON verdict; render prints the hospital.md audit section. Registered through the existing RAW_ROUTES table, no new dependencies.
  • crates/code-intel-cli/src/artifact_ref.rs(code-intel-audit-report.v1, diagnosis.audit) contract pair so an audit report can be carried as a first-class Artifact Ref. The payload validator is structural only; registry-level validation needs a repo root, which payload validators do not get, so that stays with the CLI.
  • Test ripples from the flip: the registry slot test now asserts per-department enabled flags, and the real-registry coherence test reports security as not_assessed instead of disabled (valid under rules (c), (d), (e), (i) together).
  • Docs: registration state and a "Validating a Report" section in docs/audit-report.md; CHANGELOG entry.

Dogfood: the department audited this repository

Not a fixture — the real CLI over the real tree, and the point of the whole design (tool-level evidence plus model judgment, which a prompt-only auditor cannot do):

{"departments_assessed":1,"findings_total":1,"ok":true,"overall":8.0}

The sweep covered all 22 Command::new sites, all 11 environment reads, and artifact path handling. What it found:

  • One finding (security-001, low/suspected): the cmd.exe /d /c wrapper for .cmd/.bat provider tools passes the tool path as an argument cmd.exe re-parses, and because the spawned program is cmd.exe rather than the batch file, Rust's batch-file argument quoting does not apply. Precondition is operator control of options.toolPathPrefix, not scanned-repository content — hence low, not high.
  • One hypothesis refuted by test, not by argument: Command::new("rg") with .current_dir(target) looked like a Windows current-directory program-search hijack. A scanned repository containing rg.exe and rg.bat decoys did not divert execution. Recorded in the coverage matrix as inspected evidence rather than reported as a finding.
  • Existing hardening confirmed: argv arrays throughout with no shell string interpolation, env_remove("RIPGREP_CONFIG_PATH") against ripgrep config injection, and traversal-segment rejection on artifact paths.

Coverage is honestly medium, not high — provider HTTP surfaces, PowerShell compatibility entry points, and parser fuzzing were out of scope, and the exclusions say so. Under rubrics/scoring.md that ceiling is what keeps the score at 8.0 instead of a clean-looking 10.

Verification

  • cargo test -p code-intel --bin code-intel audit: 46 passed, 0 failed (39 before this PR).
  • --test audit_report --test hospital_diagnosis --test artifact_ref: 9 + 5 + 9, 0 failed.
  • cargo fmt --all --check clean; cargo test --no-run compiles every binary.
  • test-atomic-capability-contract.ps1: "ok": true (the artifact_ref.rs toolchain digest in integrations.json was refreshed surgically — 3 lines).
  • sentrux gate: Quality 3971 -> 3973, Coupling 44.78 -> 44.59, Cycles 0 -> 0, God files 29 -> 29, No degradation detected.
  • CLI smoke both ways: the unadjusted T1 fixture fails against the real registry with the rule-(d) message and exit 65; the self-audit report above passes with exit 0.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@2233admin, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d249f32-8d76-4e7b-89e4-db6565fb5db5

📥 Commits

Reviewing files that changed from the base of the PR and between 9091c9e and 76b7eca.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • crates/code-intel-cli/src/artifact_ref.rs
  • crates/code-intel-cli/src/audit_report/cli.rs
  • crates/code-intel-cli/src/audit_report/cli_tests.rs
  • crates/code-intel-cli/src/audit_report/mod.rs
  • crates/code-intel-cli/src/audit_report/validate_tests.rs
  • crates/code-intel-cli/src/main.rs
  • crates/code-intel-cli/tests/audit_report.rs
  • docs/audit-report.md
  • orchestration/audit/departments.v1.json
  • orchestration/audit/prompts/security.md
  • orchestration/integrations.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ The sha of the head commit of this PR conflicts with #25. Mergify cannot evaluate rules on this PR. Once #25 is merged or closed, Mergify will resume processing this PR. ⚠️

security flips to enabled:true in departments.v1.json with its prompt at
orchestration/audit/prompts/security.md (adapted from
Fuck_My_Shit_Mountain, MIT). New `code-intel audit --operation
validate|render` CLI (audit_report/cli.rs) validates a report against the
department registry or renders its markdown section. Audit reports are
now a registered artifact (code-intel-audit-report.v1 / diagnosis.audit)
in artifact_ref.rs. Toolchain digest for the changed prompt refreshed in
integrations.json.
@2233admin
2233admin force-pushed the feat/audit-security-department branch from 0c6254a to 76b7eca Compare July 25, 2026 13:49
@2233admin 2233admin mentioned this pull request Jul 25, 2026
2 tasks
@2233admin
2233admin changed the base branch from feat/audit-kernel-t1 to main July 25, 2026 13:50
@2233admin

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@2233admin
2233admin merged commit 76d992b into main Jul 25, 2026
6 checks passed
@2233admin
2233admin deleted the feat/audit-security-department branch July 25, 2026 15:16
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.

[audit] T2 security 科

1 participant