Skip to content

Fix catastrophic backtracking in copyright detection - #5591

Open
AKSHAYUJJWAL286 wants to merge 1 commit into
aboutcode-org:developfrom
AKSHAYUJJWAL286:fix-4223-copyright-timeout
Open

AKSHAYUJJWAL286 wants to merge 1 commit into
aboutcode-org:developfrom
AKSHAYUJJWAL286:fix-4223-copyright-timeout

Conversation

@AKSHAYUJJWAL286

Copy link
Copy Markdown

Summary

This PR addresses severe performance issues in ScanCode Toolkit's copyright detection caused by catastrophic regex backtracking.

Changes Made

  • Replaced the backtracking YR copyright regex matcher with a deterministic linear-time matcher.
  • Replaced the backtracking EMAIL regex matcher with a deterministic linear-time matcher.
  • Added regression tests covering valid inputs, invalid inputs, and adversarial cases.
  • Updated CHANGELOG.rst.
  • Added the contributor entry to AUTHORS.rst.

Testing and Validation

  • Full tests/cluecode/ suite: 5,190 passed, 15 xfailed (previous run).
  • tests/cluecode/test_copyrights_basic.py: 66 passed.
  • Copyright doctests: 4 passed.
  • Tested three Brotli-related files:
    • dictionary.bin
    • decode.js
    • decode.min.js
  • All nine ScanCode CLI test runs completed successfully with no scan errors.
  • git diff --check passed.
  • No new Ruff issues were introduced. Two pre-existing D301 findings remain in untouched code.

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

  • Changes include regression tests.
  • Updated CHANGELOG.rst.
  • Added contributor information to AUTHORS.rst.
  • Changes are committed in a dedicated feature branch.
  • PR has a descriptive title and references the related issue.

Signed-off-by: AKSHAY UJJWAL <ujjwalakshay201@gmail.com>

This branch has not been deployed

No deployments
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