Skip to content

Add Redos static analysis utility to labs.regex and RedosVulnerability Error Prone checker - #6035

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_964990494
Open

Add Redos static analysis utility to labs.regex and RedosVulnerability Error Prone checker#6035
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_964990494

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Add Redos static analysis utility to labs.regex and RedosVulnerability Error Prone checker

Implements static AST analysis on RegexPattern to detect Regular Expression Denial of Service (ReDoS) / catastrophic backtracking vulnerabilities.

Features:

  • Functional Stream-based and IntStream-based AST traversal returning ImmutableList with flatMap().
  • Synthesizes the culprit attack witness input string and formula using StringFormat template and Substring.all().replaceAllFrom().
  • Detects nested unbounded quantifiers, overlapping alternations, adjacent overlapping quantifiers, and optional element overlaps.
  • Guards against false positives on possessive quantifiers, bounded limits, and disjoint delimiters.
  • Adds Error Prone BugChecker RedosVulnerability extending AbstractPatternSyntaxChecker, generating RedosVulnerability_refactoring for flumejavac / JavacFlume.
  • Comprehensive test coverage including unit tests, mutation testing (100% kill score), property-based AST and regex grammar fuzzer tests in RedosFuzzTest, and RedosVulnerabilityTest.
  • Tests written with TestParameterInjector, Truth assertThat(), and JUnit4.

…y Error Prone checker

Implements static AST analysis on RegexPattern to detect Regular Expression Denial of Service (ReDoS) / catastrophic backtracking vulnerabilities.

Features:
- Functional Stream-based and IntStream-based AST traversal returning ImmutableList<Finding> with flatMap().
- Synthesizes the culprit attack witness input string and formula using StringFormat template and Substring.all().replaceAllFrom().
- Detects nested unbounded quantifiers, overlapping alternations, adjacent overlapping quantifiers, and optional element overlaps.
- Guards against false positives on possessive quantifiers, bounded limits, and disjoint delimiters.
- Adds Error Prone BugChecker RedosVulnerability extending AbstractPatternSyntaxChecker, generating RedosVulnerability_refactoring for flumejavac / JavacFlume.
- Comprehensive test coverage including unit tests, mutation testing (100% kill score), property-based AST and regex grammar fuzzer tests in RedosFuzzTest, and RedosVulnerabilityTest.
- Tests written with TestParameterInjector, Truth assertThat(), and JUnit4.
PiperOrigin-RevId: 964990494
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