122 Commits

Author SHA1 Message Date
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
Felipe Zimmerle
c97db2f361
Adds verbose message when a resource is not found.
Fix #1309
2017-05-02 13:39:37 -03:00
Felipe Zimmerle
ba070c9eaa
Speeds up utils::string::toupper function 2017-03-31 14:35:26 -03:00
Felipe Zimmerle
eb12b15146
Flush [shared-] file after write it 2017-03-24 18:08:13 -03:00
Felipe Zimmerle
53485c7f74
Fix pcre_exec offset values 2017-03-06 15:02:04 -03:00
Felipe Zimmerle
d2c5b31b17
Uses FILE instead of _IO_FILE 2017-03-06 15:02:04 -03:00
Felipe Zimmerle
7f9cd76619
Improvements on the SharedFiles class
examples/multiprocess_c/multi
2017-03-06 15:02:03 -03:00
Felipe Zimmerle
01c13da510
Fix segfault due to invalid memory access on SharedFiles class
Issue #1318
2017-03-06 15:02:03 -03:00