fix(findings): bare semgrep rule ids, real umlauts in control titles (#463) #473

Merged
sharang merged 1 commits from fix/463-rule-id-prefix into main 2026-10-05 23:07:15 +00:00
Owner

Closes #463.

Rule ids

semgrep prefixes a rule's id with its config's directory relative to its working directory. Our packs are staged in the temp directory, so stored ids looked like tmp.cra-ai-20-csharp-xxe. The scanner now stores the bare id of our rules (semgrep::bare_rule_id, matched against the ids in the bundled packs). Ids that aren't ours are left unchanged.

Fingerprints

rule_id is part of the semgrep fingerprint. The scanner hashes the bare id behind a fixed tmp. prefix (semgrep::fingerprint), which is exactly what prod stored. As a result:

  • stored findings keep their fingerprint, and with it their triage, status and tracker issues (the issue search goes by fingerprint first);
  • a rescan of an unchanged tree finds nothing new (tested against Mongo in tests/finding_migrations.rs and as a unit test in semgrep.rs);
  • the fingerprint no longer depends on TMPDIR or the working directory.

Migration (at agent start, idempotent)

finding_migrations::migrate_stored_findings runs for every tenant before interrupted scans are resumed:

  • semgrep findings: the rule_id prefix is removed. A fingerprint computed from an older prefix (tmp.compliance-cra-semgrep.<id>) moves to the one a scan computes now, unless another row already holds it.
  • control-check findings: title and description are spelled with umlauts.
    A second run changes nothing.

Umlauts

The CRA catalog spells umlauts out. Titles and statement prose are corrected when the catalog is loaded (OscalDocument::restore_umlauts). It uses a word list, not a rule, so "aktuell", "neue", "Quelle" and "Prozess" stay as they are. Prod runs snapshot-only from the snapshot it was seeded with (copy-if-absent), so the fix has to work at load time. The shipped snapshot is corrected as well.

Not changed: tracker issues that already exist keep their old titles. The catalog upstream in breakpilot-compliance still spells umlauts out.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Closes #463. ## Rule ids semgrep prefixes a rule's id with its config's directory relative to its working directory. Our packs are staged in the temp directory, so stored ids looked like `tmp.cra-ai-20-csharp-xxe`. The scanner now stores the bare id of our rules (`semgrep::bare_rule_id`, matched against the ids in the bundled packs). Ids that aren't ours are left unchanged. ## Fingerprints `rule_id` **is** part of the semgrep fingerprint. The scanner hashes the bare id behind a fixed `tmp.` prefix (`semgrep::fingerprint`), which is exactly what prod stored. As a result: - stored findings keep their fingerprint, and with it their triage, status and tracker issues (the issue search goes by fingerprint first); - a rescan of an unchanged tree finds nothing new (tested against Mongo in `tests/finding_migrations.rs` and as a unit test in `semgrep.rs`); - the fingerprint no longer depends on `TMPDIR` or the working directory. ## Migration (at agent start, idempotent) `finding_migrations::migrate_stored_findings` runs for every tenant before interrupted scans are resumed: - semgrep findings: the `rule_id` prefix is removed. A fingerprint computed from an older prefix (`tmp.compliance-cra-semgrep.<id>`) moves to the one a scan computes now, unless another row already holds it. - control-check findings: title and description are spelled with umlauts. A second run changes nothing. ## Umlauts The CRA catalog spells umlauts out. Titles and statement prose are corrected when the catalog is loaded (`OscalDocument::restore_umlauts`). It uses a word list, not a rule, so "aktuell", "neue", "Quelle" and "Prozess" stay as they are. Prod runs snapshot-only from the snapshot it was seeded with (copy-if-absent), so the fix has to work at load time. The shipped snapshot is corrected as well. Not changed: tracker issues that already exist keep their old titles. The catalog upstream in breakpilot-compliance still spells umlauts out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-10-05 22:53:19 +00:00
fix(findings): bare semgrep rule ids, real umlauts in control titles (#463)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m19s
20e68b6d3f
semgrep prefixes a rule's id with its config's directory, relative to its
working directory; our packs are staged in the temp directory, so findings
showed rule ids like tmp.cra-ai-20-csharp-xxe. The scanner now stores the
bare id of our rules. The fingerprint keeps hashing the id with the fixed
"tmp." prefix it was stored with, so findings already stored keep their
fingerprint, triage, status and tracker issues, and a rescan finds nothing
new; the prefix no longer depends on where the temp directory is.

The CRA catalog spells umlauts out ("Integritaetspruefung"). Its titles and
statement prose are now spelled right when the catalog is loaded, from a
word list (a rule would break "aktuell", "neue", "Quelle"). Prod serves the
snapshot it was seeded with, so the fix cannot rely on the corrected
shipped snapshot alone; that one is corrected too.

At start the agent rewrites stored findings once (idempotent): semgrep
rule ids lose their prefix (fingerprints from an older prefix move to what
a scan computes, unless taken), and control-check titles and descriptions
get their umlauts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang force-pushed fix/463-rule-id-prefix from a1973a5663 to 20e68b6d3f 2026-10-05 22:53:19 +00:00 Compare
sharang merged commit fc099d07c1 into main 2026-10-05 23:07:15 +00:00
Sign in to join this conversation.