8000 Don't cook hex escapes by theseion · Pull Request #2215 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't cook hex escapes #2215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
path = docs/OWASP-CRS-Documentation
url = https://github.com/coreruleset/owasp-crs-documentation
branch = master
[submodule "util/regexp-assemble/lib"]
path = util/regexp-assemble/lib
url = git@github.com:coreruleset/Regexp-Assemble.git
branch = master
depth = 1
25 changes: 25 additions & 0 deletions util/regexp-assemble/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# How to use regexp-assemble.pl

## Set up
1. You will need a Perl environment and Perl version >= 5.10
2. Initialize the Git submodule with the Regexp::Assemble Perl module by running:
```bash
git submodule update --init util/regexp-assemble/lib
```
3. You should now be able to use the script. Try running something like the following:
```bash
printf "(?:homer)? simpson\n(?:lisa)? simpson" | util/regexp-assemble/regexp-assemble.pl
```
You should see:
```bash
(?:(?:homer)?|(?:lisa)?) simpson
```

## Example use
To generate a reduced expression from a list of expressions, simply pass the name of a data file to the script of pipe the contents to it:
```bash
util/regexp-assemble/regexp-assemble.pl util/regexp-assemble/regexp-942170.data
# or
cat util/regexp-assemble/regexp-942170.data util/ | regexp-assemble/regexp-assemble.pl
```

# Data file format
The data files (`.data` suffix) contain one regular expression per line. The contents of these files can be piped to [regexp-assemble.py](regexp-assemble.py) directly.

Expand Down
1 change: 1 addition & 0 deletions util/regexp-assemble/lib
Submodule lib added at 78d230
7 changes: 6 additions & 1 deletion util/regexp-assemble/regexp-assemble.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
#

use strict;
use FindBin qw( $RealBin );

# load Regexp::Assemble from the submodule, not from any other location
use lib "$RealBin/lib/lib";
use Regexp::Assemble;

my $ra = Regexp::Assemble->new;
# cook_hex: disable replacing hex escapes with decodec bytes
my $ra = Regexp::Assemble->new(cook_hex => 0);
my $flags = '';
my $prefix = '';
my $suffix = '';
Expand Down
0