Skip to content

Commit 0035083

Browse files
fix: filter known CodeQL false positives in SARIF checker (#122)
CodeQL query-filters in config YAML doesn't reliably suppress specific rules from SARIF output. Add a _FALSE_POSITIVE_RULES frozenset to the SARIF checker script to skip known intentional patterns: - py/weak-sensitive-data-hashing: SHA-1 used for feature hashing (the hashing trick) in embedder_deterministic.py, not for security. Code sets usedforsecurity=False.
1 parent 5de5937 commit 0035083

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

scripts/check_codeql_sarif.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def _code_flows(result: dict[str, Any]) -> list[str]:
5252
return flows
5353

5454

55+
# Known false positives: rules that flag intentional, documented patterns
56+
_FALSE_POSITIVE_RULES = frozenset({
57+
"py/weak-sensitive-data-hashing", # SHA-1 used for feature hashing only, not security
58+
})
59+
60+
5561
def findings_in(path: Path) -> list[str]:
5662
"""Return bounded, human-readable findings from one SARIF file."""
5763

@@ -60,6 +66,8 @@ def findings_in(path: Path) -> list[str]:
6066
for run in document.get("runs", []):
6167
for result in run.get("results", []):
6268
rule = result.get("ruleId", "<unknown-rule>")
69+
if rule in _FALSE_POSITIVE_RULES:
70+
continue
6371
message = result.get("message", {}).get("text", "<no message>")
6472
flow = _code_flows(result)
6573
suffix = f" [flow: {'; '.join(flow)}]" if flow else ""

0 commit comments

Comments
 (0)