76 Commits

Author SHA1 Message Date
Eduardo Arias
7267c1dc21 Added support to run regression tests without libxml2
- Annotated regression tests that depend on libxml2 support
- Added Windows build without libxml2
2024-05-19 18:55:34 +00:00
Eduardo Arias
e6e2989bd5 Configure test fixture using CTest for Windows build
- Added new test/test_suite.in with list of regression and unit tests
  previously in Makefile.am, to be shared between Unix and Windows
  builds.
- Updated regression.cc & unit.cc to return the number of failed tests
  to indicate to CTest that the test failed. Similarly, a crash or
  unhandled exception terminates the process with a non-zero exit code.
  - This change doesn't affect running the tests with autotest in Unix
    builds because this processes test output from custom-test-driver &
    test-suite.sh, and ignores the exit code of the test runner.
- Removed comment in test/test-cases/regression-offset-variable.json as
  this is not supported by JSON and prevents strict parsers to read and
  process the file.
- Minor change in regression.cc's clearAuditLog to replace std::ifstream
  with std::ofstream as the mode to open the flag applies to an output
  stream.
- Minor change in unit.cc to simplify code that deletes tests.
- Minor changes to test/custom-test-driver to correct usage information.
2024-05-13 10:22:12 -07:00
Eduardo Arias
a48856822c Updated included headers to support compilation on Windows (using Visual C++)
- most of posix related functions and constants in unistd.h can be
  found in io.h in Visual C++
- introduced src/compat/msvc.h to adjust for compiler differences (and
  avoid updating code with #ifdef blocks for Windows support)
- removed some included headers that are not needed (both on Unix and
  Windows builds)
2024-05-03 23:05:34 -03:00
Martin Vierula
a9edee3dbe
const-ify some references in test folder 2023-10-27 11:39:08 -07:00
Felipe Zimmerle
3748d62f19
Changes copyright dates on the code 2021-01-19 09:24:37 -03:00
Felipe Zimmerle
e6bdadeb69
tests: Prints test number on segfault 2021-01-13 13:38:38 -03:00
martinhsv
a1547eaa32
Regression tests: audit log compare support and test cases 2020-03-31 15:01:26 -03:00
Felipe Zimmerle
7495675d54
Refactoring: Renames Rules to RulesSet
RulesSet does not only contain rules but alse properties
2020-02-11 14:26:47 -03:00
Felipe Zimmerle
357c140003
Changens copyright year 2020-01-31 10:32:37 -03:00
Felipe Zimmerle
fe98ce4c7d
Cosmetics: address cppcheck warnings 2020-01-30 18:19:34 -03:00
Felipe Zimmerle
4f13fecbaf
cppcheck: make static analysis more pedantic 2020-01-22 09:16:10 -03:00
Felipe Zimmerle
86a5f471a9
Cosmetics: fixed static analysis issues. 2020-01-15 20:35:59 -03:00
WGH
bd6a02d69b
Fix test issue-1831.json on LMDB
When LMDB is enabled, ModSecurity stores its persistent variables in
"./modsec-shared-collections" file. Since this file wasn't cleared between
tests, tests behaved differently on "in-memory per-process" and LMDB backend.

This test never worked in LMDB configuration. It hasn't been discovered
until now because Travis CI didn't test LMDB configuration when test was
introduced.
2019-01-28 16:20:02 -03:00
WGH
ad28de4f14 Refactor regex code
This commit fixes quite a few odd things in regex code:
 * Lack of encapsulation.
 * Non-method functions for matching without retrieving all groups.
 * Regex class being copyable without proper copy-constructor (potential UAF
   and double free due to pointer members m_pc and m_pce).
 * Redundant SMatch::m_length, which always equals to match.size() anyway.
 * Weird SMatch::size_ member which is initialized only by one of the three matching
   functions, and equals to the return value of that function anyways.
 * Several places in code having std::string value instead of reference.
2019-01-18 10:34:01 -03:00
Felipe Zimmerle
b736f0292d
Regression: Sets MODSECURITY env var during the tests execution 2018-11-29 15:19:58 -03:00
Felipe Zimmerle
b05901e8ae
Changes the regression test client to read the interception msg 2018-10-25 21:51:23 -03:00
Felipe Zimmerle
ef7f65db90
Changes debuglogs schema to avoid unecessary str allocation 2018-10-23 17:00:16 -03:00
Felipe Zimmerle
c721e101c0
Adds request IDs and URIs to the debug log 2018-09-24 21:07:11 -03:00
Felipe Zimmerle
df169ea108
Adds support for libMaxMind 2018-03-22 19:11:42 -03:00
Felipe Zimmerle
cd30509f3a
Fix the debuglogs for the regression tests 2018-02-20 13:39:59 -03:00
Felipe Zimmerle
7fa5ca9ba0
Makes lua optional 2017-11-06 00:44:54 -03:00
Felipe Zimmerle
e6106ae0eb
Fix regression tests for fuzzyHash 2017-10-27 14:47:04 -03:00
Felipe Zimmerle
9d4ed52518
test: Counts the disabled tests as skiped on the test summary 2017-08-20 19:33:53 -03:00
Lasse Karstensen
d66f0c7e0d
Add support for disabled test cases.
This commit adds support for skipping test cases that have enabled=0 in
their JSON body.

A separate counter is kept and reported in the final non-automake
output, detailing disabled as a separate field.

Ref: #1513
2017-08-20 19:28:26 -03:00
Lasse Karstensen
ab14b7c083
Add support for disabling test cases.
The JSON test case format has an "enabled" key that is not
currently being honored. This trivial patch adds support for skipping
test cases that has enabled set to 0.
2017-08-20 19:28:21 -03:00
Felipe Zimmerle
9ce7d022c2 Fix memory leak in the regression utility 2017-07-04 11:01:11 -07:00
Felipe Zimmerle
e2af60e765
Expands log_cb to share ruleMessage structure instead text
Text version still available and it is the default options
2017-03-06 15:02:04 -03:00
Felipe Zimmerle
4ad3574cf2
Adds offset regression tests and assorted fixes on var's offsets 2017-03-06 15:02:02 -03:00
Felipe Zimmerle
795994bb0e
Adds support to error_log in the regression tests 2017-03-06 15:02:02 -03:00
Felipe Zimmerle
c06daba398
Adds support for curl resource on the regression tests 2017-03-06 15:02:01 -03:00
Felipe Zimmerle
a88dc8efa9
Changes the check script to detect segfaults 2017-03-06 15:01:59 -03:00
Felipe Zimmerle
8bd5f03a3d
Fix memory leak on the regression tests 2016-12-28 20:01:12 -03:00
Felipe Zimmerle
88fb456a16
Cosmetics: Reduces the static analysis warnings 2016-12-28 17:46:47 -03:00
Felipe Zimmerle
64e2927922 Moves debuglog stuff inside the debug_log namespace 2016-12-09 09:52:01 -03:00
Felipe Zimmerle
4ced1d18e0
Using full path in the header inclusion 2016-11-04 14:45:01 -03:00
Felipe Zimmerle
4cf6c714ac
Cosmetics: Fix coding style 2016-07-12 21:59:17 -03:00
Felipe Zimmerle
4078677b7f
Cosmetic changes: applies changes suggested by static analysis 2016-07-12 00:46:12 -03:00
Felipe Zimmerle
df1f7c5e08
Adds support to the RESPONSE_PROTOCOL variable 2016-06-21 10:52:18 -03:00
Felipe Zimmerle
b8bd0c5960
API CHANGE: response status is now set on processResponseHeaders
That change was needed to move the variable attribution to earliest
as possible. We also have a new field for HTTP_PROTOCOL version used
on the response.
2016-06-21 09:24:46 -03:00
Felipe Zimmerle
9919026620
Fixes regarding memory management
Fixes assorted issues identified by valgrind.
2016-06-16 00:03:57 -03:00
Felipe Zimmerle
f0155e3f32 Adds support to make check
The regression and unit tests are now integrated with `make check`.
It is possible to use make check -jN to have multiple tests running
in parallel.
2016-06-14 09:47:41 -03:00
Felipe Zimmerle
a51e707517 Renames class Assay to Transaction 2016-01-13 15:57:00 -03:00
Felipe Zimmerle
2a950a435b Fix various minor bugs in the regression test suite
Now if a test fails it keep testing the others tests from the same
family. The output was also improved.
2015-12-10 18:36:20 -03:00
Felipe Zimmerle
b5a43871e6 Changes library namespace from ModSecurity to modsecurity 2015-12-01 10:55:59 -03:00
Felipe Zimmerle
18c862a84a Adds the concept of `resources' to the regression test utility
If a given resource is not available the test is skipped. Useful
to test operators that depends on 3rd party libraries that may
not be available, for instance: GeoIP.
2015-11-20 13:39:57 -03:00
Felipe Zimmerle
3c45a57130 Fix regression tests structure : using method instead of protocol 2015-11-18 11:14:49 -03:00
Felipe Zimmerle
95a707964d Warn about parser error during the regression test 2015-10-19 17:18:27 -03:00
Felipe Zimmerle
b0089cfde9 Adds MODSEC_NO_LOGS option to be part of the configure 2015-10-15 15:47:52 -03:00
Felipe Zimmerle
b497091017 Cosmetics: Fix coding style 2015-09-28 16:32:59 -03:00
Felipe Zimmerle
2c39f83b5f Fix the regression test regexp validation 2015-09-24 12:33:37 -07:00