Conversation
This has essentially the same security implications as the existing `match`, so we just extend the existing modelling to also handle `prefixmatch`.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The modeling consistently mirrors match and is covered across affected security and library behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Extends Python regex modeling so Python 3.15’s prefixmatch is handled like match.
Changes:
- Models direct and compiled
prefixmatchcalls, flags, match-object flow, and SSRF sanitization. - Adds coverage for regex injection, ReDoS, SSRF, and stdlib data flow.
- Adds a change note and refreshed expected outputs.
| File | Description |
|---|---|
python/ql/test/query-tests/Security/CWE-918-ServerSideRequestForgery/test_re_prefixmatch.py |
Adds SSRF tests. |
python/ql/test/query-tests/Security/CWE-918-ServerSideRequestForgery/PartialServerSideRequestForgery.expected |
Updates partial SSRF expectations. |
python/ql/test/query-tests/Security/CWE-918-ServerSideRequestForgery/FullServerSideRequestForgery.expected |
Updates full SSRF expectations. |
python/ql/test/query-tests/Security/CWE-730-RegexInjection/RegexInjection.expected |
Updates regex-injection expectations. |
python/ql/test/query-tests/Security/CWE-730-RegexInjection/re_prefixmatch.py |
Adds regex-injection cases. |
python/ql/test/query-tests/Security/CWE-730-PolynomialReDoS/test.py |
Adds ReDoS cases. |
python/ql/test/query-tests/Security/CWE-730-PolynomialReDoS/PolynomialReDoS.expected |
Updates ReDoS expectations. |
python/ql/test/query-tests/Security/CWE-730-PolynomialReDoS/PolynomialBackTracking.expected |
Updates backtracking expectations. |
python/ql/test/library-tests/regex/test.py |
Tests prefixmatch flags. |
python/ql/test/library-tests/regex/Regex.expected |
Updates parsed-regex expectations. |
python/ql/test/library-tests/regex/Mode.expected |
Updates regex-mode expectations. |
python/ql/test/library-tests/frameworks/stdlib/test_re_prefixmatch.py |
Tests stdlib taint summaries. |
python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryCustomizations.qll |
Recognizes successful prefixmatch validation. |
python/ql/lib/semmle/python/regexp/internal/ParseRegExp.qll |
Extracts direct-call flags. |
python/ql/lib/semmle/python/frameworks/Stdlib.qll |
Models execution and match-object flow. |
python/ql/lib/change-notes/2026-09-22-python315-prefixmatch.md |
Documents the analysis improvement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
This has essentially the same security implications as the existing
match, so we just extend the existing modelling to also handleprefixmatch.