Skip to content

Quiet known-noise CodeQL alerts without losing coverage - #807

Merged
jeremy merged 2 commits into
mainfrom
codeql-quiet-known-noise
Aug 22, 2026
Merged

Quiet known-noise CodeQL alerts without losing coverage#807
jeremy merged 2 commits into
mainfrom
codeql-quiet-known-noise

Conversation

@jeremy

@jeremy jeremy commented Aug 21, 2026

Copy link
Copy Markdown
Member

The security-alert cleanup sweep found 58 of this repo's 66 open CodeQL alerts came from three noise sources, none of them defects. This mutes each at the source rather than by perpetual dismissal:

  • Generated Python (24× py/unused-import, all in generated/services/): handled exactly as the config file's own comment prescribes — the SARIF filter now strips python/src/basecamp/generated/ with a (?!services/_) lookahead, so the hand-written services/_base.py and services/_async_base.py stay scanned. Regex verified against representative paths (generated files stripped, the two _ files and auth.py untouched).
  • python/tests/ (26 alerts: empty excepts, unreachable statements, unused locals, plus two false-positive py/incomplete-url-substring-sanitization highs on \"https://3.basecamp.com\" in url assertions): added to paths-ignore under the existing test-infrastructure entries.
  • py/ineffectual-statement (8 alerts): every hit is a ... Protocol/overload stub body in auth.py/async_auth.py — idiomatic typing code the query mistakes for a defect, growing with every future Protocol method. Excluded via query-filters, mirroring the existing java/class-name-matches-super-class precedent.

The existing open alerts in these categories were already dismissed with matching reasons; this change keeps them from coming back. The remaining 8 open alerts (Scorecard process findings) are untouched.


Summary by cubic

Quiets 58 known-noise CodeQL alerts without losing coverage of the hand-written Python service bases. Previously, generated Python, tests, and the py/ineffectual-statement query reopened false positives; now they are filtered or excluded.

  • SARIF filter: centralized in .github/codeql/sarif-filter.jq and used by the workflow; the test now runs the same program. Drops python/src/basecamp/generated/ results except generated/services/_ via a lookahead so _base.py and _async_base.py stay scanned; fixture asserts both are kept.
  • Ignore tests: add python/tests/ to paths-ignore.
  • Query exclusion: add py/ineffectual-statement to query-filters to avoid Protocol/overload ... stub false positives.
  • Existing dismissed alerts in these categories will not return; the remaining 8 Scorecard alerts are unchanged. No migration required.

Written for commit 2a41aab. Summary will update on new commits.

Review in cubic

Three sources produced 58 of the repo's 66 open CodeQL alerts, none of
them defects:

* py/unused-import fired in every generated Python service. Take the
  path the config file itself prescribed for this case: strip generated
  Python in the SARIF filter, with a lookahead sparing the hand-written
  services/_base.py and _async_base.py that paths-ignore cannot express.
* python/tests/ produced empty-except/unreachable/unused-local lint and
  two false-positive URL-sanitization highs. Ignore it alongside the
  other test infrastructure (conformance/).
* py/ineffectual-statement flags the `...` bodies of Protocol and
  overload stubs in auth.py and async_auth.py — idiomatic typing code,
  and every future Protocol method would add another. Exclude the query.
Copilot AI balanced review requested due to automatic review settings August 21, 2026 17:33
@github-actions github-actions Bot added the github-actions Pull requests that update GitHub Actions label Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Sensitive Change Detection (shadow mode)

This PR modifies control-plane files:

  • .github/workflows/codeql.yml

Shadow mode — this check is informational only. When activated, changes to these paths will require approval from a maintainer.

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.

Pull request overview

Reduces recurring CodeQL noise from generated Python, tests, and typing stubs.

Changes:

  • Extends SARIF filtering to generated Python.
  • Ignores Python tests.
  • Excludes py/ineffectual-statement.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/codeql.yml Filters generated Python SARIF findings.
.github/codeql/codeql-config.yml Adds Python test and query exclusions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +54 to +55
- exclude:
id: py/ineffectual-statement

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doing this — the repo-wide reach is real, but the false-positive axis is Protocol/overload stubs, not these two files. A path-scoped SARIF clause reopens this thread the first time a Protocol lands in a new file, and inline suppressions need the alert-suppression query pack plus eight annotations on idiomatic lines. What the query protects after this change is the small hand-written Python surface (auth plumbing and services/_*), fully typed, where its output to date is 8/8 false positives — same trade the config already documents for java/class-name-matches-super-class. Leaving unresolved for a human call.

Comment thread .github/workflows/codeql.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc05b2e538

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# that this query flags as a defect. auth.py and async_auth.py alone produced
# eight such alerts, and every future Protocol method adds another.
- exclude:
id: py/ineffectual-statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope the Python suppression to protocol stubs

When an ordinary hand-written Python module contains a genuinely ineffectual expression, this rule will no longer report it because query-filters excludes the query by ID from the entire suite, not merely from the eight Protocol declarations. GitHub's query-filters documentation describes these filters as selecting queries by metadata and provides no file or line scope. Keep py/ineffectual-statement enabled and suppress or post-filter only the known stub locations so future runtime defects remain detectable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doing this — you are right that query-filters has no file scope, and that is the point of contention: the false-positive axis is Protocol/overload stubs anywhere, not the two files currently affected, so a location-scoped SARIF post-filter goes stale on the next Protocol and inline suppressions cost a query-pack change plus annotations on idiomatic code. On the remaining hand-written Python surface this query has produced only false positives, so the repo-wide exclusion follows the config's existing precedent (java/class-name-matches-super-class). Leaving unresolved for a human call.

Review caught that test-sarif-filter.sh embedded its own copy of the
filter regex — still the old one — so it kept passing without exercising
the new generated-Python exception. Updating the copy would fix this
round and leave the next edit to drift the same way.

Extract the program to .github/codeql/sarif-filter.jq and point both the
workflow (jq -f) and the test at it, so the test always runs exactly what
the workflow runs. Add fixture cases for the Python paths: generated
services and models are dropped, hand-written services/_base.py and
_async_base.py are kept. Verified the test fails when the lookahead is
removed.
@jeremy
jeremy merged commit 065de1a into main Aug 22, 2026
50 checks passed
@jeremy
jeremy deleted the codeql-quiet-known-noise branch August 22, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github-actions Pull requests that update GitHub Actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants