Repository navigation
fix: clear the 12 high code-scanning alerts - #12
Merged
Merged
Conversation
The OSV reference check used `"cve.mitre.org" in url` / `"nvd.nist.gov" in url`, so a URL that merely embeds a catalogue name in its path (or a host prefix like nvd.nist.gov.evil.example) was accepted as a CVE catalogue reference. Compare urlsplit(url).hostname against the catalogue hosts instead, and add a regression test covering both bypass shapes plus the legitimate mitre URL. Co-Authored-By: Claude Code <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.
What
Clears the 12 open HIGH code-scanning alerts (CodeQL default setup, Python): 2 are real and fixed in code; 10 are proven false positives / test-only and were dismissed with per-alert evidence.
name, aScanEngineenum id, never a secret; SARIF taint source is the enum member NAMEDETECT_SECRETSname(engine id)name(engine id)realpath+commonpath-contained before the flaggedisfile;../NUL rejected earlier by_escaping_paths"crates.io" in ecosystemsis set membership over ecosystem ids, not URL validationcve.mitre.org)urlsplit(url).hostnamewith the catalogue host, not a substringnvd.nist.gov)Fix (alerts 6–7)
src/services/osv_scanner.pydecided whether a reference URL carried a CVE id withif "cve.mitre.org" in url or "nvd.nist.gov" in url:. A URL that only embeds a catalogue name in its path (https://evil.example/nvd.nist.gov/CVE-…) or as a host prefix (https://nvd.nist.gov.evil.example/…) was accepted as a catalogue reference._is_cve_reference_url()now compares the parsedurlsplit(url).hostnameagainst the catalogue hosts, andtests/unit/test_osv_scanner.pycovers both bypass shapes plus a legitimate mitre URL.Alerts 1–3 and 8–12 are dismissed with per-alert comments quoting the exact flagged expression. Alerts 6–7 remain open until this fix is on
mainand the next default-branch CodeQL analysis runs — a PR analysis does not close default-branch alerts. The fix does not weaken any security behaviour; the reference check is strictly more precise.Gate
uv run ruff check .— exit 0uv run ruff format --check .— exit 0uvx ty@0.0.104 check src— exit 0uv run pytest— exit 0 (2911 passed, 5 skipped, 66 deselected; coverage 93.18%)🤖 Generated with Claude Code