67 Commits

Author SHA1 Message Date
Eduardo Arias
293cd214c7 Removed usage of pthreads and replaced with std C++ features
- Replaced pthread_mutex_t in modsecurity::operators::Pm with std::mutex
- Replaced pthread's thread usage in reading_logs_via_rule_message
  example with std::thread.
  - Simplified and modernized C++ code.
- Removed unnecessary includes of pthread.h
2024-08-09 11:34:40 -07:00
Eduardo Arias
59254fe3bd Simplifiy configuration to build libModSecurity with std C++17
- Leveraged autoconf again to check whether the C++ compiler supports
  the required standard version and build using it.
- Replaced the outdaded `ax_cxx_compile_stdcxx_11.m4` macro with the
  latest version of `ax_cxx_compile_stdcxx` which supports C++17.
  - https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
  - https://raw.githubusercontent.com/autoconf-archive/autoconf-archive/e4e5269db2764b9f53d759c24750ac6ca38e02ea/m4/ax_cxx_compile_stdcxx.m4
- This should also streamline updating to C++20 in the future.
2024-08-08 11:23:35 -07:00
Eduardo Arias
dab9bb6a11 Added methods to free buffers allocated by ModSecurity APIs
- The following methods are introduced to allow clients of
  libModSecurity that are not able to link and call the C/C++ standard
  library to be able to free the buffers allocated by libModSecurity.
- msc_intervention_cleanup: Frees the buffers in a
  ModSecurityIntervention structure that have been allocated by calls to
  msc_intervention.
- msc_rules_error_cleanup: Frees an error message buffer allocated by
  the msc_rules_xxx functions to detail the condition that triggered
  the error.
2024-08-05 12:18:11 -07:00
Eduardo Arias
942c8ba606 Replaced usage of usleep (not available in Visual C++) with C++11's std::this_thread::sleep_for & std::chrono::microseconds.
- disabled build error from warning C4716 because process_request does
  not return a value and Visual C++ doesn't support [[noreturn]]
2024-05-03 23:05:34 -03: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
Eduardo Arias
1f419bba8f Implement sonarcloud suggestions 2024-05-02 17:18:31 -03:00
Eduardo Arias
b872f11f68 Fixed memory leak in examples/reading_logs_via_rule_message 2024-04-28 14:55:06 -03:00
Ervin Hegedus
734646dbf1
Merge pull request #3096 from gberkes/v3/sonar_return_never_will_be_executed
Clean up 'return' never will be executed.
2024-02-27 22:25:05 +01:00
gberkes
64dfe41cec Refactor: Use pthread_exit(nullptr) instead of pthread_exit(NULL) for type safety. 2024-02-27 19:21:58 +00:00
gberkes
bf6042dd16 Marked the process_request() function with the [[noreturn]] attribute, as pthread_exit() does not return. 2024-02-26 15:38:39 +00:00
gberkes
7b56db1811 Clean up 'return' never will be executed. 2024-02-26 08:49:05 +00:00
Mirko Dziadzka
367a871f30 Bump the C++ version from C++11 to C++17
This will allow the usage of more modern features in the future.
2024-02-09 21:57:31 +01:00
Martin Vierula
648cad380e
Address some cppcheck complaints 2022-08-31 13:19:45 -07:00
Liu Dongmiao
a1980c8419 fix argv in examples 2022-03-20 21:26:25 +08:00
Felipe Zimmerle
4cdcc15334
Revert "Adds suppor for HyperScan in the bulid system"
This reverts commit 912704b6d4e45aa601b87c5a4cf4b6061d1bbccb.
2021-02-26 11:33:12 -03:00
Felipe Zimmerle
912704b6d4
Adds suppor for HyperScan in the bulid system 2021-02-26 11:15:02 -03:00
Felipe Zimmerle
2e69ce6ccf
build: Fix curl include path
Issue #2519
2021-02-24 13:20:24 -03:00
Felipe Zimmerle
3748d62f19
Changes copyright dates on the code 2021-01-19 09:24:37 -03:00
Felipe Zimmerle
9b40a045bb
Cosmetics: fix some cppcheck complains to please QA 2021-01-13 13:30:04 -03:00
Felipe Zimmerle
6a742cdf76
Refactoring: Renames RulesProperties to RulesSetProperties 2020-02-17 13:17:03 -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
Victor Hora
5c048e3cc4
Explicitly include time.h to fix building the examples 2018-09-11 20:46:19 -03:00
Felipe Zimmerle
df169ea108
Adds support for libMaxMind 2018-03-22 19:11:42 -03:00
Felipe Zimmerle
854a661a2a
Fix gcc compilation issue 2018-02-27 13:22:50 -03:00
Felipe Zimmerle
0461c1c065
Fix examples compilation while using disable-shared 2018-02-21 22:46:36 -03:00
Felipe Zimmerle
ff782ddfa4
Having LDADD and LDFLAGS organized on Makefile.am 2018-02-21 14:26:47 -03:00
Felipe Zimmerle
3fb71f32d8
Coding style fixes 2017-11-13 22:32:11 -03:00
Felipe Zimmerle
1189e9b0ef
Adds support to LUA in configure scripts 2017-10-31 09:59:12 -03:00
Felipe Zimmerle
7622866f97
Adds support for @fuzzyHash
Issue #997
2017-10-26 17:44:17 -03:00
Felipe Zimmerle
5a32b389b4
chunks example: Sets the freed variables to NULL 2017-06-19 19:08:26 -03:00
Felipe Zimmerle
6d77c76b27
Implements intervention support inside using chunks example
In the example the disruptive action is printed in the console output.
2017-06-19 18:33:51 -03:00
Felipe Zimmerle
e1f52a1cf2
Adds using bodies in chunks example 2017-06-10 09:28:22 -03:00
Felipe Zimmerle
616a95bfe0
Adds -lpthread to the reading_logs_via_rule_message example 2017-06-07 14:22:33 -03:00
Felipe Zimmerle
2a5085255e
Using multiple threads in reading logs via rule message example 2017-06-03 16:40:47 -03:00
Andrei Belov
85f98c8a66
Fix "make dist" after recent changes to parser
In particular, it is now possible to either build ModSecurity
with pre-generated parser, or use "--enable-parser-generation"
configure option to rebuild parser from sources.
2017-03-09 18:18:00 -03: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
027d50b76b
Adds first version of `processContentOffset'
This commit also includes an example application on how to use the
`processContentOffset' method.
2017-03-06 15:02:02 -03:00
Felipe Zimmerle
e95efa05cc
Fix assorted memory and static analysis errors 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
4ced1d18e0
Using full path in the header inclusion 2016-11-04 14:45:01 -03:00
Felipe Zimmerle
c680ddf2cd
Refactoring on rulesProperties class
Among of other things the merge process was improved to detect if
certain properties were set on the origin rule set.
2016-10-05 12:01:15 -03:00
Manish Malik
75e2e9d4dc
Fixing multiprocess_c compile error 2016-07-12 22:05:43 -03:00
Felipe Zimmerle
4078677b7f
Cosmetic changes: applies changes suggested by static analysis 2016-07-12 00:46:12 -03:00
Felipe Zimmerle
20689145dd
Renames examples/multithread_c to multiprocess_c 2016-07-07 10:31:35 -03:00
Felipe Zimmerle
cd5a116ca6
Simplifies the multi thread sample
Now using multi process not multi threads. To be renamed.
2016-07-07 10:31:01 -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
Alexey Zelkin
767289c8da
Fix compilation for libpthread users. 2016-06-16 13:56:54 -03:00
Manish Malik
5728110272 Declaring variable outside the for loop 2016-05-05 15:54:01 -03:00
Felipe Zimmerle
ff165a4035 Adds support to the multithread example 2016-04-26 17:55:05 -03:00