Skip to content

fix: mod_security2's regression tests fix #3425

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 15 commits into from
Jul 29, 2025

Conversation

airween
Copy link
Member

@airween airween commented Jul 28, 2025

what

This PR is a set of commits, where I fixed Apache2 mod_security2's regression tests.

We definitely should integrate this regression test framework to mod_security2's CI pipeline.

why

Unfortunately the tests were abandoned, last commits were 12 years ago. Most tests checks log line messages and status codes, and I assume many messages have changed. Also, it seems like the test script (tests/run-regression-tests.pl) itself was not finished, I had to add a few modifications for a working state.

Commits' details:

  • 158084c:
    • perl functionrel2abs() wasn't referenced as it's expected;
    • -S arguments wasn't handled
    • DIST_ROOT was set to parent directory of the whole project
  • 36876ff:
    • had to add modsecurity.conf-minimal - that's almost the same as -recommended, but I removed audit.log settings; that's the script's task
    • also had to add necessary unicode.mapping file
    • set up the correct (and now existing) modsecurity.conf file
  • 575314f:
    • introduced a new environment variable: RUNASUSER; this can be different on different systems (Linux, Windows)
    • ip.pag file stores the IP collections data, but that has changed too: the new format is $USERNAME-ip.pag, eg. www-data.ip.pag, but if we run local, then the user it's me
  • 10659ad:
    • fixed request directives test: had to change the message and response code
  • 33791eb:
    • fixed multipart tests: had to change the messages and response codes
  • bc01714:
    • StatusEngine does not work anymore, I didn't want to remove that completely, just suspended (commented out)
  • 1362a30:
    • SecRemoteRules needs to maintain a remote infrastructure, and as we agreed this feature will be phased out; same as the previous case, I just suspended
  • 780304c, 63af830:
    • these tests also needs remote infrastructure, I temporary suspended them
  • c7cacf8:
    • fixed XML tests: had to change the messages and response codes
  • b6d14b7:
    • added necessary arguments to Makefile.am; Now after the build it's enough to run the command: make test-regression, and all the tests will run. If all tests are success, then make returns 0, otherwise it shows the problems.

How does it work?

If you build the module, you can run the test on two ways:

  • make test-regression in source root directory
  • cd tests; ./run-regression-tests.pl -v -S ., where
    • -v is the verbose flag
    • -S is the server's root path directory; without this the script does not work out of box, but you can set different path - if you know what are you doing

You can run a single test file or just a single test case from a file, eg:

./run-regression-tests.pl -v -S . regression/rule/10-xml.t

or

./run-regression-tests.pl -v -S . regression/rule/10-xml.t 4

where the last 4 means you want to run the 4th test only.

For help, run:

./run-regression-tests.pl -h

Indeed, I'm going to add these information to README.

@airween airween requested review from theseion and fzipi July 28, 2025 16:05
@airween airween added the 2.x Related to ModSecurity version 2.x label Jul 28, 2025
Copy link
Contributor

@fzipi fzipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go!

@airween airween requested a review from theseion July 28, 2025 20:07
Co-authored-by: Max Leske <[email protected]>
@airween airween requested a review from theseion July 29, 2025 07:24
Copy link

@airween airween merged commit e1ea8e5 into owasp-modsecurity:v2/master Jul 29, 2025
122 of 162 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to ModSecurity version 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants