fix(ci): scope the code scan instead of annotating it, and drop a duplicated MCP constant block - #1383
Draft
lusoris wants to merge 1 commit into
Draft
fix(ci): scope the code scan instead of annotating it, and drop a duplicated MCP constant block#1383lusoris wants to merge 1 commit into
lusoris wants to merge 1 commit into
Conversation
lusoris
force-pushed
the
fix/code-scanning-alert-sweep
branch
2 times, most recently
from
September 7, 2026 09:11
42c5564 to
a082828
Compare
6 tasks
lusoris
force-pushed
the
fix/code-scanning-alert-sweep
branch
from
September 7, 2026 10:16
a082828 to
98f6a30
Compare
…licated MCP constant block The Security tab carries 20 alerts that never clear. The scanners are not off: CodeQL analysed refs/heads/master at 2026-09-07T06:52:38Z with 57 results, Semgrep uploads both SARIF categories on every master push, and `default-setup: not-configured` is correct because the *advanced* workflow is in use. Two mechanical causes, neither visible from the code. 1. `# nosemgrep` does not remove a result from the SARIF. Semgrep's docs: the comment "still generates findings records that are automatically set to Ignored triage state, rather than excluding code from scanning entirely." That state lives on the Semgrep platform; this workflow writes SARIF and hands it to upload-sarif, so GitHub sees a result and keeps the alert. Four alerts sit on correct, already-annotated code for this reason -- three SHA-1 memoisation cache keys that already pass usedforsecurity=False, and an 0o660 Unix-domain socket shared with a same-group Go peer. 2. `paths` / `paths-ignore` are inert for compiled languages that are BUILT. GitHub limits them to interpreted languages and to build-less compiled analysis; the CodeQL job builds C/C++ with meson + ninja, so every TU it compiles is extracted regardless. `core/test` is listed and still produces alerts. Compounding it, a bare `build` matches only a TOP-LEVEL directory, and the fork's build trees are core/build, core/build-cuda, ... -- which is how alert 1018 landed on a meson probe file under core/build/meson-private/. Fixed here: `paths-ignore` becomes `**/build`, `**/build-*`, `**/builddir`, and the config records the built-language limitation inline with the doc link so the next reader does not add entries expecting them to work. The one alert that pointed at a real defect was bigger than it said. `py/unused-global-variable` flagged _VALID_AOM_CTCS / _VALID_NFLX_CTCS in mcp-server/.../server.py; they turned out to be part of a duplicated constant block. Five further names -- _VALID_TINY_DEVICES, _VALID_TINY_RESIZES, _VALID_BACKENDS, _VALID_PIXFMTS, _VALID_BITDEPTHS -- were defined twice with identical values, the second binding silently winning, so editing the first was a no-op. CodeQL cannot flag those because the names *are* used, just not the first binding. The dead block is removed and _VALID_OUTPUT_FMTS, the one live name in it, is folded into the canonical block. 318 MCP tests pass; the 3 failures in test_score_extras_adr1117.py are pre-existing on master (path allowlist ordering when run from a non-standard root) and unchanged by this. No alert was dismissed. Every remaining one has a written disposition in ADR-1222: 1005 is deliberately unfixed (widening it breaks the ADR-0138 bit-exactness invariant and the overflow is unreachable), 1002/1003 and 951 are query false positives, 168/927, 908/943/955, 917/918, 946 and 947-949 are correct as written, and 1/3 are Scorecard repo-process metrics. Dismissal is the maintainer's call. ADR-1222. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
fix/code-scanning-alert-sweep
branch
from
September 7, 2026 11:13
98f6a30 to
5625c13
Compare
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
CodeQL is not off. It analysed
refs/heads/masterat2026-09-07T06:52:38Zwith 57 results; Semgrep uploads both its SARIF categories on every master push;
code-scanning/default-setupreportingnot-configuredis correct, becausethe repo uses the advanced workflow and the two are mutually exclusive.
The 20 alerts never clear for two mechanical reasons, neither of which is
visible from the code.
1.
# nosemgrepdoes not remove a result from the SARIFSemgrep's docs: a
nosemgrepcomment "still generates findings records thatare automatically set to Ignored triage state, rather than excluding code
from scanning entirely." That triage state lives on the Semgrep platform. This
workflow writes SARIF and hands it to
upload-sarif, so GitHub sees a resultand keeps the alert open.
Four alerts sit on correct, already-annotated code for this reason: three
SHA-1 memoisation cache keys in
compat/python-vmaf/tools/decorator.pythatalready pass
usedforsecurity=False, and an0o660Unix-domain socket inai/sidecar/online_trainer.pyshared with a same-group Go peer. Writing morenosemgrepdirectives will never close them.2.
paths-ignoreis inert for compiled languages that are builtGitHub limits
paths/paths-ignoreto interpreted languages and to compiledlanguages analysed without building. The CodeQL job builds C/C++ with meson
is why
core/testis listed inpaths-ignoreand still produces alerts.Compounding it, a bare
buildmatches only a top-level directory. Thefork's build trees are
core/build,core/build-cuda, … — which is how alert1018 landed on
core/build/meson-private/tmpu2z1n35e/testfile.c, a probe filemeson generates to test compiler features.
Fixed here:
paths-ignorebecomes**/build,**/build-*,**/builddir,and the config records the built-language limitation inline with the doc link so
the next reader doesn't add entries expecting them to work.
The one alert that pointed at a real defect
py/unused-global-variableflagged_VALID_AOM_CTCS/_VALID_NFLX_CTCSinmcp-server/.../server.py. Following it upstream found a duplicated constantblock:
_VALID_TINY_DEVICES_VALID_TINY_RESIZES_VALID_BACKENDS_VALID_PIXFMTS_VALID_BITDEPTHS_VALID_AOM_CTCS/_VALID_AOM_CTC_VALID_NFLX_CTCS/_VALID_NFLX_CTCCodeQL could only see the two whose names differ. The other five are shadowed
rebindings — the second definition silently wins, so adding a backend at line
391 would have changed nothing. Values agree today, so there is no live wrong
behaviour; it is a trap that surfaces later as "I added it and it didn't take
effect". The dead block is removed and
_VALID_OUTPUT_FMTS, the one live namein it, is folded into the canonical block.
Reproducer / smoke test
318 passed, 42 skipped. The 3 failures intest_score_extras_adr1117.pyarepre-existing on master — verified by running the same file on a pristine
origin/mastercheckout, which fails identically. They come from the pathallowlist being checked before parameter validation when the repo sits at a
non-allowlisted root; unrelated to this change and left alone.
No alert was dismissed
Every remaining alert has a written disposition in the ADR's table — 1005 is
deliberately unfixed (widening the multiply breaks the ADR-0138 bit-exactness
invariant, and the overflow is unreachable), 1002/1003 and 951 are query false
positives, 168/927, 908/943/955, 917/918, 946 and 947–949 are correct as
written, and 1/3 are Scorecard repo-process metrics. Per the standing project
rule, agents analyse and fix; dismissal is the maintainer's call. The ADR
also lays out the two options that would actually clear the "correct as written"
alerts — a SARIF post-processing allowlist, or manual dismissal — and takes
neither.
Deep-dive deliverables (ADR-0108)
docs/research/2039-why-code-scanning-alerts-never-clear.md: both mechanisms with the doc quotes, the shadowed-constant table, and the four generalisable points.docs/adr/1222-code-scanning-alert-triage-and-scope.md## Alternatives considered(five options; the runner-up "post-process the SARIF" is a dismissal mechanism in different clothes and is left to the maintainer)..github/codeql-config.ymland a fork-local MCP module, neither of which the upstream rebase story reads.changelog.d/fixed/1222-code-scanning-scope.md.docs/rebase-notes.md— entryADR-1222 — code-scanning scope, not code-scanning annotations (2026-09-07).Docs (rule 10)
Bug status (rule 13 / ADR-0165)
docs/state.md— closesT-CODE-SCANNING-ALERTS-NEVER-CLEAR-2026-09-07.🤖 Generated with Claude Code