Skip to content

Read finding severities with ast instead of a backtracking regex - #52

Merged
binary-knight merged 1 commit into
mainfrom
fix-codeql-redos
Nov 10, 2026
Merged

binary-knight merged 1 commit into
mainfrom
fix-codeql-redos

Conversation

@binary-knight

Copy link
Copy Markdown
Owner

Resolves CodeQL alert #5 (py/redos, high) in tests/test_compatibility.py, added in #51.

_constructed() found each _f(...) call in scoring.py with a regular expression whose nested repetition can backtrack exponentially. It now walks the parsed source with ast, which also reads a computed severity directly instead of inferring it from the text. The result is the same: 32 finding IDs, with FS-001 and PRIV-003 the only ones whose severity is computed.

The only input was this repository's own source, so nothing could have supplied a hostile string. The change clears the alert and makes the test less fragile.

Locally 512 tests pass and 13 skip without network.

🤖 Generated with Claude Code

test_compatibility.py found each _f(...) call in scoring.py with a
regular expression whose nested repetition CodeQL flags as able to
backtrack exponentially (py/redos). It now walks the parsed source, which
also reads a computed severity directly rather than inferring it from
text. The result is unchanged: 32 finding IDs, two with computed
severities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@binary-knight
binary-knight merged commit 53b86a6 into main Nov 10, 2026
18 checks passed
@binary-knight
binary-knight deleted the fix-codeql-redos branch November 10, 2026 06:34
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