Skip to content

Conversation

@hnakamur
Copy link
Contributor

what

  • Stop adding newline to each line of request or response body in regression tests.
  • Add format subcommand to regression_tests command.
  • Support updating Content-Length header by running (cd test; UPDATE_CONTENT_LENGTH=1 ./regression_tests format)
  • Update regression test JSON files:
    • Add newlines to request bodies where needed.
    • Add Content-Length headers.
    • Adjust test casses to pass after above modifications.

why

  • Enable to test edge cases (such as request body lines with newline except the last line). This is important for multipart request bodies.

references

This is needed to test edge cases like a body missing the final newline,
for example:

[
  "a\r\n",
  "b\r"
]

And it is clearer than to add implicit newline to each line except the
final line.
when UPDATE_CONTENT_LENGTH env var is set
by running the following command:
```
(cd test; ./regression_tests format)
```
by running the following command:
```
(cd test; UPDATE_CONTENT_LENGTH=1 ./regression_tests format)
```
@hnakamur hnakamur force-pushed the v3/do_not_add_newline_to_test_body_lines branch from 8fefe12 to 9b49187 Compare January 25, 2026 23:59
@hnakamur
Copy link
Contributor Author

I found JSON was corrupted since some of http_version was empty. I fixed it and force pushed.
However some of tests do not pass right now. I am trying to fix them.

@hnakamur
Copy link
Contributor Author

I fixed tests at aefd4a4 and now all tests pass again.

@airween
Copy link
Member

airween commented Jan 27, 2026

Hi @hnakamur,

thank you for this improved PR.

Unfortunately there are two warnings from cppcheck:

2026-01-26T00:29:37.2162370Z warning: test/regression/regression.cc,444,style,shadowVariable,Local variable 'test' shadows outer variable
2026-01-26T00:29:37.2943530Z warning: test/regression/regression_test.cc,366,style,functionConst,The member function 'modsecurity_test::RegressionTests::toJSON' can be made a const function. Making this function 'const' should not cause compiler errors. Even though the function can be made const function technically it may not make sense conceptually. Think about your design and the task of the function first - is it a function that must not change object internal state?

Also, SonarCloud reported a few new issues (some of them are same as cppcheck found):

https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&pullRequest=3486&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true

As I mentioned previously, I don't expect to fix all Sonar issues. If the cppcheck will be passed, I'll review all Sonar issues and try to mark the "old" issues as accepted.

Thank you again.

@airween airween added the 3.x Related to ModSecurity version 3.x label Jan 27, 2026
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Related to ModSecurity version 3.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants