Repository navigation
Fix catastrophic backtracking in copyright detection - #5591
AKSHAYUJJWAL286 wants to merge 1 commit into
Conversation
Signed-off-by: AKSHAY UJJWAL <ujjwalakshay201@gmail.com>
|
I reviewed the changes in src/cluecode/copyrights.py, ests/cluecode/test_copyrights_basic.py, CHANGELOG.rst, and AUTHORS.rst. Replacing the backtracking YR and EMAIL lexer regexes with explicit linear-time matchers cleanly eliminates ReDoS timeouts on long/adversarial tokens while keeping lexer token classification intact. A few specific observations from inspecting the implementation and tests:
Solid fix for #4223. |
|
Thank you for taking the time to review the implementation and tests! I really appreciate the detailed feedback, especially your observations on preserving YR grammar equivalence, deterministic email matching, and adversarial test coverage. I'm glad the changes address the timeout issue. I'll be happy to address any further feedback on PR #5591. |
Summary
This PR addresses severe performance issues in ScanCode Toolkit's copyright detection caused by catastrophic regex backtracking.
Changes Made
YRcopyright regex matcher with a deterministic linear-time matcher.EMAILregex matcher with a deterministic linear-time matcher.CHANGELOG.rst.AUTHORS.rst.Testing and Validation
tests/cluecode/suite: 5,190 passed, 15 xfailed (previous run).tests/cluecode/test_copyrights_basic.py: 66 passed.dictionary.bindecode.jsdecode.min.jsgit diff --checkpassed.Scope and Limitations
The original approximately 103 MB binary mentioned in the issue was not available for direct testing. The shared Brotli-related reproducer files were tested successfully.
Related Issue
References #4223
Contributor Checklist