Skip to content

Regular Expressions Improvements#135

Open
Mzack9999 wants to merge 7 commits intomainfrom
feat-regexp
Open

Regular Expressions Improvements#135
Mzack9999 wants to merge 7 commits intomainfrom
feat-regexp

Conversation

@Mzack9999
Copy link
Copy Markdown
Member

@Mzack9999 Mzack9999 commented May 14, 2025

RE2 brings x2 speed but more allocs. Some pattern cannot be compiled so we fallback to standard library

Closes #112

@Mzack9999 Mzack9999 self-assigned this May 14, 2025
@ehsandeep ehsandeep requested a review from dogancanbakir May 14, 2025 09:32
@Mzack9999 Mzack9999 marked this pull request as draft May 14, 2025 09:34
@ehsandeep ehsandeep removed the request for review from dogancanbakir May 14, 2025 09:36
@Mzack9999 Mzack9999 marked this pull request as ready for review May 14, 2025 15:14
@Mzack9999 Mzack9999 requested a review from dogancanbakir May 14, 2025 15:15
@dogancanbakir dogancanbakir requested a review from ehsandeep May 15, 2025 13:52
@ehsandeep ehsandeep requested a review from Ice3man543 June 20, 2025 13:03
@dogancanbakir
Copy link
Copy Markdown
Member

bump

@neo-by-projectdiscovery-dev
Copy link
Copy Markdown

neo-by-projectdiscovery-dev bot commented Mar 18, 2026

Neo - PR Security Review

No security issues found

Highlights

  • Adds RE2 regex engine for 2x performance improvement with fallback to standard library when patterns cannot be compiled
  • Implements quantifier limiting (+/* → {1,100}/{0,100}) to prevent catastrophic backtracking
  • Regex patterns are compiled from static fingerprints data, not user input
Hardening Notes
  • Consider logging when RE2 compilation fails and fallback occurs in patterns.go:69-71 to track which patterns require stdlib regex — this helps identify potential ReDoS risks during fingerprint updates
  • Add timeout configuration for regex matching operations in patterns.go:108 via context.Context to provide defense-in-depth against potential ReDoS even with quantifier limits

Comment @pdneo help for available commands. · Open in Neo

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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.

go-regexp is slow causing high cpu usage and slowness

3 participants