Download the PHP package stardothosting/modsecurity-parser without Composer
On this page you can find all versions of the php package stardothosting/modsecurity-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download stardothosting/modsecurity-parser
More information about stardothosting/modsecurity-parser
Files in stardothosting/modsecurity-parser
Download stardothosting/modsecurity-parser
More information about stardothosting/modsecurity-parser
Files in stardothosting/modsecurity-parser
Vendor stardothosting
Package modsecurity-parser
Short Description 1:1 PHP port of msc_pyparser (ModSecurity SecRule parser) with JSON output
License GPL-3.0-or-later
Package modsecurity-parser
Short Description 1:1 PHP port of msc_pyparser (ModSecurity SecRule parser) with JSON output
License GPL-3.0-or-later
Please rate this library. Is it a good library?
Informations about the package modsecurity-parser
StardotHosting SecRule Parser
A 1:1 PHP port of msc_pyparser (ModSecurity SecRule parser) with JSON output.
Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- As a Library
- From the CLI
- Usage
- Parsing a Single File
- Parsing a Directory
- API Reference
- Contributing
- License
Features
- Full fidelity to the original Python implementation: all variables, operators, actions, quoting rules, chaining logic, and error reporting are preserved exactly.
- JSON output instead of YAML—no extra dependencies.
- PSR-4 compliant, installable via Composer.
- CLI tool for rapid testing and integration in scripts or CI.
Requirements
- PHP 7.4 or higher
- psr/log (optional, for logging)
Installation
Quick Start
As a Library
Note:
The parser now returns a nested array structure:
- Each top-level element is a group of rules (e.g., a main rule and its chained children).
- Each group is an array of one or more rules, preserving the original chaining and grouping from the ModSecurity config.
- To get a flat list of all rules (e.g., for searching by ID), you may need to recursively flatten the array.
From the CLI
Usage
Parsing a Single File
Parsing a Directory
API Reference
Parser::parseFile(string $path): array
- Reads and parses the given
.conffile. - Returns a nested array of rule groups. Each group is an array of one or more rules (for chained rules, the group contains the main rule and its chained children).
- Throws
\RuntimeExceptionon read error or parse exception.
Parser::parse(string $input, string $filename = '<string>'): array
- Parses a raw ruleset string.
- Returns a nested array of rule groups (see above).
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/YourFeature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/YourFeature) - Open a Pull Request
Please follow PSR-12 coding standards and provide unit tests for any new parsing rules.
License
This project is licensed under the GPL-3.0-or-later. See the LICENSE file for details.
Ported from the original msc_pyparser by Ervin Hegedüs (GPL-3.0).
Breaking Changes in v3.0.1 (2024-06-07)
- Parser output is now a nested array of rule groups.
- Each group is an array of one or more rules, preserving ModSecurity's chaining/grouping.
- If you need a flat list of rules, you must flatten the array yourself.
- Test suite updated to recursively flatten the output for ID checks.
- (Also see v3.0.0 changes below.)
Breaking Changes in v3.0.0 (2024-06-06)
- Namespace changed to
StardotHosting\SecRuleParser\ - Composer package renamed to
stardothosting/secrule-parser - Minimum PHP version is now 7.4
- Old namespaces and package names are no longer supported
All versions of modsecurity-parser with dependencies
PHP Build Version
Package Version
The package stardothosting/modsecurity-parser contains the following files
Loading the files please wait ...