Rust: Add AlertSuppression.ql for inline suppression comments#21638
Open
cnuss wants to merge 1 commit intogithub:mainfrom
Open
Rust: Add AlertSuppression.ql for inline suppression comments#21638cnuss wants to merge 1 commit intogithub:mainfrom
cnuss wants to merge 1 commit intogithub:mainfrom
Conversation
3295a0d to
832761a
Compare
Enable // codeql[...] and // lgtm[...] inline suppression comments for Rust code scanning alerts, matching the pattern used by all other supported languages. Closes github#21637
832761a to
4160086
Compare
hvitved
reviewed
Apr 7, 2026
Contributor
hvitved
left a comment
There was a problem hiding this comment.
Thanks for your contribution; only two nits.
| private import codeql.rust.elements.Comment as C | ||
| private import codeql.rust.elements.AstNode as A | ||
|
|
||
| class AstNode instanceof A::AstNode { |
Contributor
There was a problem hiding this comment.
nit: A::AstNode should be final, so you can change the instanceof to extends and get rid of the toString predicate.
| string toString() { result = super.toString() } | ||
| } | ||
|
|
||
| class SingleLineComment instanceof C::Comment { |
9 tasks
michelbr84
added a commit
to michelbr84/GarraRUST
that referenced
this pull request
May 1, 2026
…pt (empirical proof PASSED) (#109) * docs(security): GAR-491 — codeql suppressions ledger + reapply script Establishes the suppression convention for Rust CodeQL alerts in GarraRUST. Rust CodeQL still does NOT support inline `// codeql[...]` comments (github/codeql#21638 open without merge), so the project adopts a versioned ledger + REST API dismissal mechanism per amendment-driven plan §15. Deliverables: * docs/security/codeql-suppressions.md — human-auditable ledger (6 rows). * docs/security/codeql-suppressions.json — machine-readable source (schema 1.0.0) consumed by the reapply script. * scripts/security/codeql-reapply-dismissals.sh — POSIX bash with --dry-run/--apply/--check-md/--alert flags. Fail-closed: validates rule_id, path, and start_line against current alert before any PATCH; exit 2 on mismatch (manual re-audit), exit 3 on stale entry, exit 4 on MD/JSON drift. No automatic schedule (per amendment A8). * docs/security/codeql-setup.md — cross-link to the new ledger; replaces the "TBD suppression syntax" placeholder from PR #106. Empirical-proof status (in flight): * Alert #43 (rust/hard-coded-cryptographic-value @ credentials.rs:49, `vec![0u8; SALT_LEN]` immediately overwritten by SystemRandom::fill) dismissed via gh api PATCH at 2026-05-01T12:33:36Z with reason="false positive". State confirmed dismissed. * Pending: CodeQL re-run on this branch must preserve the dismissed state. If it does, apply remaining 5 dismissals (#40, #41, #42, #44, #45). If it does NOT, abort and open new sub-issue (no global query-filter fallback per amendment A3). Operational rules (ledger §3): * No bulk suppression — each row has per-line justification. * 90-day audit expiration (2026-08-01) forces re-triage. * Fail-closed reaplicação: any drift between live alert and ledger surfaces to human, never auto-fixes. * No global rule silencing as fallback — abort instead. Linear: GAR-491 (Wave 2 of GAR-486 umbrella). Status: In Progress. Plan file: ~/.claude/plans/voc-est-no-repo-inherited-robin.md §15-16. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(security): GAR-491 — empirical proof PASSED, all 6 alerts dismissed Empirical proof of the REST-dismissal + versioned-ledger mechanism: the dismissal of alert #43 (credentials.rs:49, false positive) at 12:33:36Z PERSISTED across the CodeQL re-run on this branch (run 25214464719 at 12:35:44Z, success). `state=dismissed` and `dismissed_at` were unchanged when re-queried at ~12:43Z. With the mechanism proven, the batch was applied: * 5 remaining alerts (#40, #41, #42, #44, #45) dismissed via `bash scripts/security/codeql-reapply-dismissals.sh --apply` * Final state of all 6 verified — all `{"state":"dismissed"}`. Script bugfix: the idempotent skip check originally compared the ledger snake_case `dismissed_reason` against the API's space-separated form, causing HTTP 400 "Alert is already dismissed." on re-runs. Fixed to compare against the translated `api_reason` (with spaces). A second `--apply` invocation now reports `6 skipped, 0 applied, 0 errors` — proving idempotency. Ledger §5 updated with the run IDs, timestamps, and final verification results. Section §6 (failure handling) was NOT exercised because the proof passed. Linear: GAR-491 — empirical-proof gate cleared. PR ready to mark for review (next commit / `gh pr ready`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rust/ql/src/AlertSuppression.qlto enable// codeql[...]and// lgtm[...]inline suppression comments for Rust, matching the pattern used by all other supported languages//line comments and single-line/* */block comments, excluding multi-line block commentscodeql/util/suppression/AlertSuppression.qllmodule (already a dependency)Closes #21637
Test plan
codeql test runpasses forrust/ql/test/query-tests/AlertSuppression/// codeql[...]on code lines correctly excluded (only standalone lines suppress)codeql query formatproduces no changes