Skip to content

Regex cross-language compatibility#367

Merged
tsellers-r7 merged 1 commit intorapid7:masterfrom
tsellers-r7:adjust_flags
Jul 28, 2021
Merged

Regex cross-language compatibility#367
tsellers-r7 merged 1 commit intorapid7:masterfrom
tsellers-r7:adjust_flags

Conversation

@tsellers-r7
Copy link
Copy Markdown
Contributor

@tsellers-r7 tsellers-r7 commented Jul 28, 2021

Description

The intent of this PR is to improve cross language compatibility for the regex patterns used.

The changes:

  • Moves inline flags such as (?i) and (?m) to the beginning of the regex. In Python these flags have global meaning and use of them anywhere other than the start of the pattern is deprecated. This does not change the function of these flags in current patterns for other languages.

  • Replaces the use of POSIX character class indicators ([[:alnum:]], [[:digit:], and [[:space:]) with either the short backslash version (\d, \s) or a character range (a-zA-Z0-9). The reason for this is that certain languages (Java, Python, Javascript) don't support the use of POSIX character classes.

How Has This Been Tested?

rspec, 3rd party regex testors.

Types of changes

Fingerprint construction

Checklist:

  • I have updated the documentation accordingly (or changes are not required).
  • I have added tests to cover my changes (or new tests are not required).
  • All new and existing tests passed.

@tsellers-r7
Copy link
Copy Markdown
Contributor Author

CC @hdm @pberry25 @dabdine

@hdm
Copy link
Copy Markdown
Contributor

hdm commented Jul 28, 2021

Seems great here! Any chance we can get a test case to scan new regexes for the incompatible variants? ([:digit:], non-leading ?i, etc).

@tsellers-r7
Copy link
Copy Markdown
Contributor Author

tsellers-r7 commented Jul 28, 2021

@hdm - I'm leaning towards an effort to separate the fingerprint databases into their own repo and then have language/tool specific tests that ensure that we know that patterns are valid in the standard/common regex libs for Ruby, Go, Java, etc and also pass the build in tests vs examples.

@gschneider-r7
Copy link
Copy Markdown
Contributor

See #138 for when tests for this can be accomplished 😃

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.

4 participants