179 Commits

Author SHA1 Message Date
martinhsv
2de14cb000
Merge pull request #2635 from Mesar-Ali/patch-1
Adjust confusing variable name in setRequestBody method
2021-12-30 11:29:37 -05:00
Mesar ali
f82b98c04d
Confusing variable name in setRequestBody method 2021-12-30 08:55:51 +05:30
Martin Vierula
19d50f4da4
Add a const to satisfy cppcheck 2021-12-20 09:41:38 -08:00
Mesar ali
5aec781d39
Confusing variable name in setRequestBody method 2021-11-02 12:35:29 +05:30
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
f18595f428
Makes regular expression selection on collections key case insensitive
This issue was initially reported by @michaelgranzow-avi on #2296.

@airween made an initial attempt to provide a fixed at #2107; As a
consequence of the pull request review - provided by @victorhora,
@zimmerle, and @michaelgranzow-avi - @airween made a second attempt
at #2297. After reviewing by @martinhsv, @zimmerle, I have absorbed
the essential pieces from @airween patch into this one.

This patch differs from @airween's because @airween's patches were
partially working: Key exclusions with regex weren't covered, same
for anchored variables (e.g. ARGS). During the review, I have
highlighted the importance of having elementary test cases. A simple
test case on ARGS could spot the issue. Since that is an important
fix, I don't want to hold this for one more review cycle; therefore,
I am committing the fix myself.

Thank you all involved in the solution of this very own issue.
2020-12-10 10:05:07 -03:00
martinhsv
2672db103e
Add support for new operator rxGlobal 2020-10-26 08:55:07 -03:00
Felipe Zimmerle
4b425850cf
Cosmetics: fix cppcheck warnings 2020-10-23 08:29:07 -03:00
Andrei Belov
fe12385148 GeoIP: switch to GEOIP_MEMORY_CACHE from GEOIP_INDEX_CACHE
Using GEOIP_INDEX_CACHE on some older versions of libGeoIP (e.g. 1.5.0
which is the default version on CentOS 7) leads to "Error reading file"
error while opening completely valid GeoIP.dat:

    # cat test.c
    #include <stdio.h>
    #include "GeoIP.h"

    int main(void) {
      GeoIP *g;

      g = GeoIP_open("/tmp/GeoIP.dat", GEOIP_INDEX_CACHE);

      if (g == NULL) {
        printf("error!\n");
      }

      GeoIP_delete(g);

      exit(0);
    }
    # cc -lGeoIP -o test test.c
    # ./test
    Error reading file /tmp/GeoIP.dat
    error!
    # sed -i -e 's,GEOIP_INDEX_CACHE,GEOIP_MEMORY_CACHE,' test.c
    # cc -lGeoIP -o test test.c
    # ./test
    # geoiplookup -f /tmp/GeoIP.dat -v 8.8.8.8
    GeoIP Country Edition: GEO-106FREE 20180327 Build 1 Copyright (c) 2018 MaxMind Inc All Rights Reserved

Also tested with recent GeoLite databases converted from new format
into legacy format, distributed here:

    https://mailfud.org/geoip-legacy/
2020-07-30 13:48:40 -03:00
martinhsv
b9620c26a0
rx:exit after full match; fix TX population after unused group 2020-06-29 06:13:45 -07:00
Felipe Zimmerle
9c526b3647
Avoids copy on the transformation operation 2020-03-27 16:12:55 -03:00
Felipe Zimmerle
f1d22f9b02
Fix version check 2020-03-24 17:20:22 -03:00
Felipe Zimmerle
357c140003
Changens copyright year 2020-01-31 10:32:37 -03:00
Felipe Zimmerle
ff9152ed74
Cosmetics: address cppcheck warnings on src/utils 2020-01-23 08:51:45 -03:00
Felipe Zimmerle
ff590174da
Cosmetics: address cppcheck warnings on src/operators 2020-01-23 08:10:05 -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
martinhsv
9cac167faf Fix argument key-value pair parsing cases 2019-11-05 13:06:29 -03:00
Felipe Zimmerle
beedddd6c6 Fix @pm lookup for possible matches on offset zero 2019-10-02 08:05:14 -07:00
Ervin Hegedus
ccd90c51c5
Increment OVECCOUNT value for bigger regex's 2019-02-12 10:08:47 -03:00
Felipe Zimmerle
df3c3f62b7 Cosmetics: coding style 2019-01-18 11:02:22 -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
Andrei Belov
ae02076340
Fixed buffer overflow in Utils::Md5::hexdigest()
Found via failed test (auditlog.json) on Alpine Linux 3.8.2.
2019-01-14 16:29:07 -03:00
Ervin Hegedus
77854ed1b5
Fix inet addr handling on 64 bit big endian systems 2018-12-10 15:03:09 -03:00
Fred Nicolson
3d2030426c
Replaced log locking using mutex with fcntl lock
When reloading Nginx, there is a race condition which is visible under high
load. As the logging mutex is shared between multiple workers, when a worker
is sent a stop signal during a reload, and the log mutex is held, write()
will never return, which means that the mutex will never unlock. As other
workers share this mutex, they will deadlock.

fcntl does not suffer from this issue.
2018-11-27 10:09:29 -03:00
Felipe Zimmerle
120108fd33
Adds support for /32 in @ipMatch cidr notation.
/32 is the representation of the ip itself. Not sure if it is needed,
but there is a complaint for that: #849
2018-10-23 16:37:53 -03:00
Victor Hora
0c0b09ec52
Use glob.h when using OpenBSD 2018-09-11 20:45:58 -03:00
Felipe Zimmerle
d7b9726357
good practices: Initialize variables before use it
Original author: Marc Stern (#1889)
2018-09-05 23:35:24 -03:00
Victor Hora
fd8e72fd97
Allow empty strings to be evaluated by regex::searchAll 2018-06-18 22:11:48 -03:00
Reed Morrison
95048d5fcf
Fix ip tree lookup on netmask content 2018-06-07 14:29:27 -03:00
Wenfeng Liu
45e531236a
Return false in SharedFiles::open() when an error happens 2018-05-24 10:21:37 -03:00
Robert Paprocki
e4c822e663
Code cleanup: Initialize variables and others good practice
- initialize invalid_countin UrlDecode :: evaluate
- Free resources before the process die (good practice)
2018-05-13 17:08:07 -03:00
Robert Paprocki
cd1a058c33
Code cosmetics: Clean up MD5 hexdigest
The null terminator is not necessary when using this form of the
std::string constructor, and its use was confusing given the extra
indent.
2018-05-03 13:41:49 -03:00
Andrei Belov
268f34bbcc
Fix memory leak in modsecurity::utils::expandEnv()
Found by ASAN.
2018-04-23 22:54:13 -03:00
Andrei Belov
5e65d560f8
Fix utils::string::ssplit() to handle delimiter in the end of string
This closes #1743.
2018-04-22 11:37:30 -03:00
Felipe Zimmerle
df169ea108
Adds support for libMaxMind 2018-03-22 19:11:42 -03:00
Felipe Zimmerle
dca642369e
Fix on top of #1677 2018-02-26 17:53:18 -03:00
Andrei Belov
ccc1f2031a
Fix "include /foo/*.conf" for single matched object in directory 2018-02-23 14:01:41 -03:00
Athmane Madjoudj
968d83f1ff
Fix build on non x86 arch build failed on ppc64/ppc64le/arch64/armv7hl/s390x due to how this arch represent chars 2017-10-25 16:44:27 -03:00
Felipe Zimmerle
119a6fc074
test-only: Placing a mutex while evaluating the pm operator
Performing an earlier optimization of the tree (before threads creation)
2017-09-26 16:33:26 +00:00
Mirko Dziadzka
43e3ff91e8
Fixes a bug with an unitialized variable.
new_debug_log was unitialized during an error code path.

Fixed this by explicit initializing it to NULL and fixing the order of
the error labels. They now present the correct (reverse) order of the
goto statements.
2017-08-23 23:53:46 -03:00
Felipe Zimmerle
4b9bd499eb
Fix to_hex_if_need function on string utils
This fix issue #1535. Solution was the same suggested on #1523.
2017-08-21 22:47:49 -03:00
Felipe Zimmerle
9ee412735d parser: Improves the reading for the url in the redirect action 2017-08-15 15:18:52 -03:00
Felipe Zimmerle
49b7ea99e6 Adds a set of sanity checks to validate API inputs (1 of 2) 2017-06-21 12:59:19 -07:00
Felipe Zimmerle
3ebc2d61fb
Enables random number generation 2017-06-16 23:20:28 -03:00
Felipe Zimmerle
e795253ecf
Fix crash on SecRuleRemoveById malformated parameter
Fix issue #1440
2017-06-06 22:14:13 -03:00
Felipe Zimmerle
a90b2a3ff7
Code cosmetics: init a vector. 2017-05-28 22:27:10 -03:00
Felipe Zimmerle
c49688fd7d
Verify if a certain resource exists before do any other sanity check 2017-05-28 22:10:15 -03:00
Felipe Zimmerle
0e05b7bb8a
Avoids to load a directory structure as a rules file 2017-05-02 16:42:22 -03:00