Skip to content

fix(panicbot): canonical PA rule IDs from panic-attack; test the --parallel wrapper and drain - #645

Open
hyperpolymath wants to merge 4 commits into
mainfrom
claude/vigilant-turing-94eajv
Open

hyperpolymath wants to merge 4 commits into
mainfrom
claude/vigilant-turing-94eajv

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Two follow-ups from the outcome-verdict work (#616, #622, #623) and from panic-attack#232.

1. panicbot filed findings under the wrong PA rules

panicbot's translator used its own numbering, and 20 of its 25 rule IDs disagreed with panic-attack's canonical WeakPointCategory::rule_id:

Category panicbot panic-attack
UnsafeCode PA001 PA004
CommandInjection PA003 PA009
HardcodedSecret PA004 PA017
… (17 more)

Only PA021–PA025 agreed. Hypatia deduplicates findings by these IDs, and its patterns follow panic-attack's numbering (for example PA009-shell-unquoted-var). So every panicbot finding in PA001–PA020 was deduplicated against the wrong rule.

The fix:

  • Source of truth. panic-attack's published table, data/canonical-rule-ids.json at 5175a68, is vendored into bots/panicbot/canon/ and pinned by sha256 in pin.toml. This follows the rhodibot canon pattern.
  • Translator. IDs are corrected from that table. The new tests/canonical_rule_ids_test.rs checks every category against it.
    • Five panic-attack categories aren't translated yet: UnboundedAllocation, LicensePolicy, Advisory, BannedDep and UnknownSource. They're listed explicitly, so when panic-attack adds a category, the test fails until someone decides how to map it.
    • LicensePolicy stays unmapped on purpose, since licence findings are flag-only.
  • Fix-script headers. Six cited wrong PA codes (ResourceLeak PA020→PA008, HardcodedSecret PA013→PA017, UncheckedError PA019→PA018, UnboundedLoop PA019→PA002, innerHTML PA014→PA011, SQL PA012→none).
    • This was documentation only: the registry routes by category name.
    • Headers now cite PAnnn (Category), and Hypatia pattern IDs are back-quoted so the two namespaces can't be confused.
    • tests/panic-attack-rule-ids-test.sh checks the pin digest and every reference. Its --upstream flag compares the pin against panic-attack main.
  • CI. panicbot joins the rust.yml matrix: it was built, but never tested or linted, in CI. Making it clippy-clean meant implementing FromStr for MinSeverity and applying rustfmt, in a separate, behaviour-neutral commit. The new shell test runs in e2e.yml.

2. The --parallel wrapper and drain had no test (CodeRabbit on #622/#623)

Section 8 of tests/outcome-verdict-test.sh drove count/fold_counts directly. New section 9 extracts the runner's real run_entry and its post-loop wait; fold_counts block, the same way section 4 extracts record_outcome. It then runs five stubbed entries at --parallel 1 and 2.

The main loop itself is not run. It sits behind the automation quarantine (exit 78, which per the owner ruling stays), and this test does not bypass that.

Validation

  • panicbot: 82 tests pass; cargo clippy --all-targets -D warnings and cargo fmt --check are clean.
  • Mutation checks:
    • Restoring one old ID (ResourceLeak back to PA009) fails canonical_rule_ids_test.
    • A wrong header, an unquoted Hypatia ID, and an edited vendored table each fail panic-attack-rule-ids-test.sh.
    • Removing IN_JOB=1 from run_entry, or fold_counts from the drain, fails section 9.
  • outcome-verdict-test.sh passes 41/41. Its ShellCheck findings are identical to main's.
  • The automation-quarantine, dispatch-paths and e2e tests pass.
  • actionlint 1.7.7 is clean on rust.yml and e2e.yml, and check-lock-sync.sh is clean.

Deliberately not here

I didn't add --check predicates to fix-heredoc-install.sh and fix-todo-markers.sh, even though their recipes have the most outcome-log rows after the two that already have predicates.

  • Those rows were written by robot-repo-automaton, not by these scripts.
  • Both scripts are effectively reporters: one only adds a warning comment, the other changes nothing.

Whether they should stay routed as auto_execute fixers is a design question. It goes to a tracking issue instead.


Generated by Claude Code

Groundwork for adding panicbot to the rust.yml CI matrix, where it has
never been tested or linted: `cargo clippy -D warnings` failed on
`MinSeverity::from_str` shadowing the std trait method
(should_implement_trait), and rustfmt reported drift in seven files.

MinSeverity now implements std::str::FromStr (callers use `.parse()`);
the rest is `cargo fmt`. No behaviour change: 80 tests pass before and
after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PpQVLrCbURpoXtrdvy8V3B
…n CI

panicbot's translator numbered panic-attack categories with its own
sequence: 20 of its 25 rule IDs disagreed with panic-attack's
WeakPointCategory::rule_id (UnsafeCode PA001 vs PA004, CommandInjection
PA003 vs PA009, HardcodedSecret PA004 vs PA017, ...). Hypatia
deduplicates findings by these IDs and follows panic-attack's numbering
(e.g. its `PA009-shell-unquoted-var` pattern), so panicbot filed findings
under the wrong rules.

- Vendor panic-attack's published table (data/canonical-rule-ids.json at
  5175a68) into bots/panicbot/canon/, pinned by sha256 in pin.toml.
- Correct the translator's rule IDs from that table.
  tests/canonical_rule_ids_test.rs checks every category against it;
  the five panic-attack categories panicbot does not translate yet
  (UnboundedAllocation, LicensePolicy, Advisory, BannedDep, UnknownSource)
  are listed explicitly, so a new upstream category fails the test until
  someone decides how to map it.
- Fix-script headers cited six wrong PA codes (documentation only: routing
  is by category name). They now cite `PAnnn (Category)` from the table,
  and Hypatia pattern IDs are back-quoted so the two namespaces stay apart.
  tests/panic-attack-rule-ids-test.sh checks the pin digest and every
  reference (`--upstream` compares with panic-attack main).
- Add panicbot to the rust.yml matrix (it was built, never tested or
  linted, in CI) and the new shell test to e2e.yml.

Verified: panicbot 82 tests, clippy -D warnings, fmt; a reintroduced old
ID (ResourceLeak PA009) fails canonical_rule_ids_test; a wrong header,
an unquoted Hypatia ID and an edited table each fail the shell test;
actionlint and check-lock-sync clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PpQVLrCbURpoXtrdvy8V3B
Section 8 drove count/fold_counts directly, so dropping IN_JOB=1 from
run_entry, or the fold_counts after the post-loop wait, left the suite
green while --parallel summaries read zero (CodeRabbit on #622).

Section 9 extracts the real run_entry and drain from dispatch-runner.sh,
as section 4 extracts record_outcome, and runs five stubbed entries at
--parallel 1 and 2. The main loop itself stays behind the automation
quarantine (exit 78); this test does not bypass it. Both mutations above
now fail the suite (41 checks).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PpQVLrCbURpoXtrdvy8V3B
@hyperpolymath
hyperpolymath requested a balanced review from Copilot November 5, 2026 00:03
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8a91dd9 and 0d8aef9.

Files selected for processing: 29

  • .github/workflows/e2e.yml
  • .github/workflows/rust.yml
  • bots/panicbot/canon/canonical-rule-ids.json
  • bots/panicbot/canon/pin.toml
  • bots/panicbot/src/a2ml_writer.rs
  • bots/panicbot/src/cli.rs
  • bots/panicbot/src/config.rs
  • bots/panicbot/src/directives.rs
  • bots/panicbot/src/main.rs
  • bots/panicbot/src/scanner.rs
  • bots/panicbot/src/translator.rs
  • bots/panicbot/tests/a2ml_writer_test.rs
  • bots/panicbot/tests/canonical_rule_ids_test.rs
  • bots/panicbot/tests/integration_test.rs
  • bots/panicbot/tests/translator_test.rs
  • scripts/fix-believe-me.sh
  • scripts/fix-heredoc-install.sh
  • scripts/fix-http-to-https.sh
  • scripts/fix-innerhtml.sh
  • scripts/fix-resource-leak.sh
  • scripts/fix-secret-to-env.sh
  • scripts/fix-shell-quoting.sh
  • scripts/fix-sql-parameterize.sh
  • scripts/fix-tmp-paths.sh
  • scripts/fix-todo-markers.sh
  • scripts/fix-unbounded-loop.sh
  • scripts/fix-unchecked-error.sh
  • tests/outcome-verdict-test.sh
  • tests/panic-attack-rule-ids-test.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@linear-code
linear-code Bot marked this pull request as ready for review November 5, 2026 00:03

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T01:24:06.219844Z 0d8aef9 New commits
ℹ️ 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.

Copy link
Copy Markdown
Owner Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@hyperpolymath have exceeded the limit for the number of chat messages per hour. Please wait 25 minutes and 31 seconds before sending another message.

Copy link
Copy Markdown
Owner Author

This PR has two red checks that aren't caused by its diff:


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

There's a third red check that this PR doesn't cause: governance / Allowlist Preflight.

Main's workflows now call four reusables at metadatastician/standards/.github/workflows/{governance,hypatia-scan,mirror,scorecard}-reusable.yml@75bd599; they arrived with #639's fleet owner migration. The standards actions allowlist (rhodium-standard-repositories/actions-allowlist/allowed-actions.json) has no metadatastician/* pattern. As a result, every gitbot-fleet PR reports 4 not covered by the allowlist.

Fixing this means deciding whether the metadatastician owner is trusted, so it belongs in the standards allowlist rather than in a gitbot-fleet PR. No fix exists yet.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

A fourth red check doesn't come from this PR: governance / Language / package anti-pattern policy. It flags four Python files that #632 added on 2026-10-31, none of which this PR touches, so main is red on it too. Porting them is tracked in #650; no fix exists yet.


Generated by Claude Code

hyperpolymath added a commit that referenced this pull request Nov 5, 2026
…#649)

## Summary

`build · test · clippy (idris-dependents)` has failed on main since
#628, and on every PR since (for example #645).

1. **Compile error.** `ready_mock()` in `tests/scan_tests.rs` predates
the `responses` field on `Mock`, so the test crate failed with E0063
before any test ran. The field is now initialised empty, as the file's
other two `Mock` literals already do.
2. **Two tests the compile error had hidden.** In
`tests/scan_edge_tests.rs`, both tests encoded behaviour from before raw
files returning HTTP 404/410/451 became *skipped URLs*. That contract is
specified in the README, in the `get_file` doc comment, and in
`scan_tests::unavailable_files_are_logged_reported_and_skipped_in_both_raw_fetch_paths`.
- `raw_content_fetches_retry_rate_limits_and_propagate_hard_failures`
expected a raw 404 to fail the run. Its hard-failure case now uses HTTP
500, which still propagates as `HTTP 500 for <url>`. The 404 skip stays
covered by `scan_tests`.
- `report_json_keeps_public_field_names_and_confidence_spelling` now
includes the public `skippedUrls` field.

Only test code changes; the product behaviour is untouched.

## Validation

- I reproduced E0063 on a clean checkout of main.
- All 79 idris-dependents tests pass across every test binary.
- `cargo clippy --all-targets -D warnings` and `cargo fmt --check` are
clean.
- The first commit's message says "all tests pass". That was wrong when
written: the two edge-test failures had been cut from the output I
checked. The second commit fixes them and says so.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01PpQVLrCbURpoXtrdvy8V3B)_

---------

Co-authored-by: Claude <[email protected]>

Copy link
Copy Markdown
Owner Author

I've merged main into this branch (0d8aef9), which picks up #649. The idris-dependents job should now pass here; locally all 79 of its tests pass, as do this PR's own suites (41/41 outcome checks and the PA rule-ID test).

governance / Validate Hypatia Baseline isn't caused by this PR either. None of its 16 new findings is in a file this PR changes:

Main is red on all of these.

This PR still needs:

  • the SonarCloud findings, which I can't read from this session;
  • an owner decision on adding metadatastician to the allowlist.

Generated by Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.2% Duplication on New Code (required ≤ 3%)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

3 participants