crs-toolchain
The crs-toolchain is the CRS developer’s utility belt — the Swiss army knife for CRS development. It provides a single point of entry and a consistent interface for a range of different tools. Its core functionality (owed to the great rassemble-go, which is itself based on the brain-melting Regexp::Assemble Perl module) is to assemble individual parts of a regular expression into a single expression (with some optimizations).
The current stable release is v2.7.0 (as of December 2025).
Setup
Method 1: Pre-built Binaries (Recommended)
The recommended way to get the tool is using one of the pre-built binaries from GitHub. Navigate to the latest release and download the package for your platform along with the crs-toolchain-checksums.txt file.
Available formats:
- Linux:
.deb,.rpm,.tar.gz, and.apkpackages - macOS:
.tar.gzarchives for both Intel and Apple Silicon - Windows:
.zipand.tar.gzarchives
To verify the integrity of the binary/archive, navigate to the directory where the two files are stored and verify that the checksum matches:
The output should look like the following (depending on the binary/archive downloaded):
Method 2: Install with Go
Note
This method requires Go 1.19 or higher installed on your system.
If a current Go environment is present, install the latest version directly:
Provided that the Go binaries are on the PATH (typically ~/go/bin), the toolchain can now be run from anywhere:
Method 3: Self-Update
Once you have crs-toolchain installed, you can update it to the latest version using the built-in self-update command:
This will automatically download and install the latest release for your platform.
Verify Installation
After installation, verify that crs-toolchain is working correctly:
Test the Toolchain
Test the regex assembly functionality by running the following in a shell:
The output should be:
This demonstrates that the tool successfully assembled multiple regular expression alternatives into an optimized single expression.
Configuration and Options
Adjusting the Logging Level
The level of logging can be adjusted with the --log-level global flag. This affects the verbosity of output for all commands.
Available levels (from most to least verbose):
trace- Most detailed, includes all internal operationsdebug- Detailed debugging informationinfo- General informational messages (default)warn- Warning messages onlyerror- Error messages onlyfatal- Fatal errors onlypanic- Panic-level errors onlydisabled- No logging output
Usage:
Global Flags
In addition to --log-level, the following global flags are available for all commands:
Recent Releases and Improvements
Version 2.7.0 (December 2024)
- Release automation improvements
- Bug fixes for semver parsing
- Enhanced meta character escaping
- Security dependency updates for crypto and compression libraries
Version 2.6.0 (September 2024)
- Integrated wordnet database functionality for fp-finder utility
- Improved false positive detection capabilities
- Routine dependency maintenance
Version 2.5.0 (August 2024)
- Command refactoring for better performance
- Enabled stdin support for fp-finder command
- GitHub Actions and Alpine Linux updates
Version 2.4.0 (May 2024)
- New feature:
util fp-findercommand for detecting false positives - Added PR templates
- Improved regex comparison functionality
Version 2.3.x Series (January-April 2024)
- Enhanced format validation to fail on unnecessary uppercase character classes
- Fixed Unicode character hex representation issues
- Added warnings for uppercase in case-insensitive patterns
- Removed mage build tool dependency
- Restricted evasion modifiers usage
Tip
To see the full release history and detailed changelogs, visit the releases page on GitHub.
Getting Help
Built-in Documentation
Read the built-in help text for comprehensive documentation:
Online Resources
- Official Documentation: https://coreruleset.org/docs/development/crs_toolchain/
- GitHub Repository: https://github.com/coreruleset/crs-toolchain
- Issue Tracker: https://github.com/coreruleset/crs-toolchain/issues
- Latest Releases: https://github.com/coreruleset/crs-toolchain/releases
The regex Command
The regex command provides sub-commands for everything surrounding regular expressions, especially the “assembly” of regular expressions from a specification of its components. This is the most commonly used feature of crs-toolchain for CRS development.
For detailed information on how regular expressions are assembled, see Assembling Regular Expressions.
Available Sub-commands
generate
Generates an optimized regular expression from a list of expression components. This command reads from regex assembly (.ra) files and produces an assembled, optimized expression.
Usage:
Example:
compare
Compares the generated expression against the current expression in the rule files. This is useful for verifying that changes to regex assembly files will produce the expected output.
Usage:
The output will show:
- Whether the expressions match
- Differences between current and generated expressions
- Any formatting or optimization changes
update
Updates rule files directly with newly generated expressions. This command modifies the actual CRS rule configuration files.
Warning
This command modifies files in place. Make sure you have committed your changes or have a backup before running update commands.
Usage:
format
Checks and formats regex assembly (.ra) files according to CRS standards. This ensures consistent formatting across all regex assembly files.
Usage:
Format checks include:
- Proper line endings
- Consistent indentation
- Avoiding unnecessary uppercase character classes (added in v2.3.3)
- Warning about uppercase in case-insensitive patterns (added in v2.2.0)
Common Workflow
A typical workflow when modifying regular expressions:
The util Command
The util command includes sub-commands that are used from time to time and do not fit nicely into any of the other groups. Available sub-commands:
renumber-tests
Used to simplify maintenance of the regression tests. Since every test has a consecutive number within its file, adding or removing tests can disrupt numbering. This command will renumber all tests within each test file consecutively.
Usage:
fp-finder
The false positive finder utility helps identify potential false positives in CRS rules. This command analyzes test data and can process input from stdin or files to detect patterns that might trigger false positives.
Added in: v2.4.0 (with wordnet database integration in v2.6.0)
Usage:
This tool is particularly useful for:
- Identifying problematic patterns before deployment
- Testing rule changes against known good traffic
- Validating that rule modifications don’t introduce new false positives
self-update
Updates the crs-toolchain to the latest available version. This command automatically downloads and installs the newest release for your platform.
Usage:
The command will:
- Check for the latest release on GitHub
- Download the appropriate binary for your platform
- Replace the current installation with the new version
- Verify the update was successful
The chore Command
The chore command provides maintenance utilities primarily used by CRS maintainers and release managers.
release
Manages the release process for crs-toolchain, including version tagging and release artifact generation.
Usage:
update-copyright
Updates copyright year information across the project files.
Usage:
The completion Command
The completion command generates shell completion scripts to enable tab completion for crs-toolchain commands in your shell.
Supported Shells
- Bash
- Zsh
- Fish
- PowerShell
Installation Examples
For Zsh (with Oh My Zsh):
For Bash:
For Fish:
For PowerShell:
Tip
After installing shell completion, you may need to restart your shell or source your shell configuration file for the changes to take effect.
How completion is enabled and where completion scripts are sourced from depends on your shell and environment. Please consult the documentation of the shell you’re using for specific details.