Skip to content

fix(ci): use the suppression comment form CodeQL honors - #251

Merged
simonvanlierde merged 2 commits into
mainfrom
fix/codeql-suppression-comments
Sep 9, 2026
Merged

fix(ci): use the suppression comment form CodeQL honors#251
simonvanlierde merged 2 commits into
mainfrom
fix/codeql-suppression-comments

Conversation

@simonvanlierde

@simonvanlierde simonvanlierde commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

The AlertSuppression.ql packs and advanced-security/dismiss-alerts in CI have never dismissed an alert: the dismiss step ends at Indexed 11 code scanning alert(s) and closes nothing, because the uploaded SARIF carries zero suppressions. Every dismissal in this repo was done by hand.

The cause is comment placement. In CodeQL's shared AlertSuppression.qll, codeql[query-id] matches only when the comment begins its own line, and then covers the line below it. All nine # codeql[...] comments here are trailing, so none match. lgtm[query-id] covers its own line, which is what a trailing annotation needs.

  • Nine suppressions rewritten as trailing # lgtm[query-id].
  • The two multi-line logger calls in the email service have their arguments split, so the annotations sit on the argument lines: a trailing annotation on the line that opens a call covers nothing.
  • The CodeQL config and CI comment now say which form works.

The own-line # codeql[...] form was tried first and rejected: ruff reports it as ERA001, and inside a call ruff format splits the arguments and moves the flagged expression off the covered line.

prek passes on all touched files. The real check is the merge: the dismiss step should close alerts 164 and 165, both false positives on a masked recipient token. If it doesn't, they stay open and nothing is worse than today.

The in-code suppressions have never dismissed an alert: every dismissal in the
repo was done by hand. CodeQL's shared AlertSuppression library matches
`codeql[query-id]` only when the comment starts its own line, and then covers
the line below it, so all nine trailing `# codeql[...]` comments were inert.

- Rewrite the nine suppressions as trailing `# lgtm[query-id]`, the form that
  covers its own line, so the flagged expression is inside the annotated range.
- Split the two multi-line logger calls in the email service: a trailing
  annotation on the line that opens a call covers no argument.
- Say in the CodeQL config and the CI comment which form works and why.
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@simonvanlierde
simonvanlierde merged commit bb0c003 into main Sep 9, 2026
@simonvanlierde
simonvanlierde deleted the fix/codeql-suppression-comments branch September 9, 2026 16:01
simonvanlierde added a commit that referenced this pull request Sep 9, 2026
Keeps main's `lgtm[py/clear-text-logging-sensitive-data]` on the rate-limit log.
This branch had dropped that marker on the grounds that the in-code form never
suppressed anything, which #251 has since fixed by moving to the form CodeQL
honors. The marker stays; the comment above it still says why the value is safe.
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