]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 years agogithub-ci: remove fedora 34: eol in 2 weeks 7426/head
Jason Ish [Tue, 24 May 2022 17:40:05 +0000 (11:40 -0600)] 
github-ci: remove fedora 34: eol in 2 weeks

Bump F34 to build to F35, and F35 to F36.

3 years agoutil/ebpf: fix deprecation warning 7401/head
Eric Leblond [Thu, 11 Feb 2021 22:32:38 +0000 (23:32 +0100)] 
util/ebpf: fix deprecation warning

The function bpf_program__title has been deprecated in favor of
bpf_program__section_name.

(cherry picked from commit d477d3a8789d55828861c515e609d024e95a0dc8)

3 years agoutil/ebpf: fix compilation
Eric Leblond [Wed, 11 May 2022 07:01:23 +0000 (09:01 +0200)] 
util/ebpf: fix compilation

Bug: #5360

3 years agolog-pcap: remove redundant check 7369/head
Victor Julien [Wed, 27 Apr 2022 09:36:21 +0000 (11:36 +0200)] 
log-pcap: remove redundant check

Check is always true but confuses cppcheck:

src/log-pcap.c:1224:32: warning: Either the condition 'filename' is redundant or there is possible null pointer dereference: filename. [nullPointerRedundantCheck]
    if ((pl->prefix = SCStrdup(filename)) == NULL) {
                               ^
src/log-pcap.c:1421:9: note: Assuming that condition 'filename' is not redundant
    if (filename) {
        ^
src/log-pcap.c:1224:32: note: Null pointer dereference
    if ((pl->prefix = SCStrdup(filename)) == NULL) {
                               ^

Bug: #5291.
(cherry picked from commit 3dfbf0bf1124aab7c7060f46b364877ab25455ee)

3 years agolog/pcap: exit on invalid filename
Eric Leblond [Wed, 10 Feb 2021 15:23:25 +0000 (16:23 +0100)] 
log/pcap: exit on invalid filename

If the filename has to % sign and if pcap logging is using multi
mode, then the pcap capture will fail. So let's exit if ever this
is the case.

(cherry picked from commit 921d44b262f30555ea747653b050dfde4188c042)

3 years agodetect/pcre: assist code analyzer around pointer logic
Victor Julien [Tue, 26 Apr 2022 19:47:37 +0000 (21:47 +0200)] 
detect/pcre: assist code analyzer around pointer logic

cppcheck:

src/detect-pcre.c:381:27: warning: Either the condition 'pcap' is redundant or there is overflow in pointer subtraction. [nullPointerArithmeticRedundantCheck]
            cut_capture = MIN((pcap - regexstr), (fcap - regexstr));
                          ^
src/detect-pcre.c:378:18: note: Assuming that condition 'pcap' is not redundant
        else if (pcap && !fcap)
                 ^
src/detect-pcre.c:381:27: note: Null pointer subtraction
            cut_capture = MIN((pcap - regexstr), (fcap - regexstr));
                          ^

Bug: #5291.
(cherry picked from commit 69b8b48b9422279943c083a24e5baf64e1c4aa94)

3 years agologopenfile: fix minor format string warning
Victor Julien [Wed, 27 Apr 2022 09:39:27 +0000 (11:39 +0200)] 
logopenfile: fix minor format string warning

cppcheck:

src/util-logopenfile.c:743:13: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            snprintf(threaded_name, len, "%s.%d.%s", tname, unique_id, ext);
            ^
src/util-logopenfile.c:752:9: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
        snprintf(threaded_name, len, "%s.%d", original_name, unique_id);
        ^

Bug: #5291.
(cherry picked from commit 07d0ae04d34cdf029729b474fb22598f154fcea6)

3 years agoja3: fix minor format string warning
Victor Julien [Wed, 27 Apr 2022 09:38:37 +0000 (11:38 +0200)] 
ja3: fix minor format string warning

cppcheck:

src/util-ja3.c:197:28: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
        (*buffer)->used += snprintf((*buffer)->data, (*buffer)->size, "%d",
                           ^
src/util-ja3.c:201:28: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
        (*buffer)->used += snprintf((*buffer)->data + (*buffer)->used,
                           ^

Bug: #5291.
(cherry picked from commit 1e13f7278585555623ff0be2d3a98476617b1219)

3 years agoaf-packet/v2: use proper type for ring
Victor Julien [Wed, 27 Apr 2022 09:32:22 +0000 (11:32 +0200)] 
af-packet/v2: use proper type for ring

cppcheck:

src/source-af-packet.c:1762:19: warning: Size of pointer 'v2' used instead of size of its data. This is likely to lead to a buffer overflow. You probably intend to write 'sizeof(*v2)'. [pointerSize]
        ptv->ring.v2 = SCMalloc(ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                  ^
src/source-af-packet.c:1767:26: warning: Size of pointer 'v2' used instead of size of its data. This is likely to lead to a buffer overflow. You probably intend to write 'sizeof(*v2)'. [pointerSize]
        memset(ptv->ring.v2, 0, ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                         ^

scan-build:

CC       source-af-packet.o
source-af-packet.c:1762:24: warning: Result of 'malloc' is converted to a pointer of type 'char', which is incompatible with sizeof operand type 'union thdr *' [unix.MallocSizeof]
        ptv->ring.v2 = SCMalloc(ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                       ^~~~~~~~                           ~~~~~~~~~~~~~~~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
                 ^~~~~~
1 warning generated.

Bug: #5291.
(cherry picked from commit fedced209dc25443ec5eee22bfab6c99f9f652ab)

3 years agodevice: avoid uninit var warning
Victor Julien [Tue, 26 Apr 2022 19:35:29 +0000 (21:35 +0200)] 
device: avoid uninit var warning

cppcheck:

src/util-device.c:455:17: error: Uninitialized variables: *ndev.dev, *ndev.tenant_id_set, *ndev.id, *ndev.next, *ndev.tenant_id, *ndev.offload_orig [uninitvar]
        *ldev = *ndev;
                ^
src/util-device.c:618:36: note: Calling function 'LiveDeviceForEach', 2nd argument '&ndev' value is <Uninit>
    while(LiveDeviceForEach(&ldev, &ndev)) {
                                   ^
src/util-device.c:455:17: note: Uninitialized variables: *ndev.dev, *ndev.tenant_id_set, *ndev.id, *ndev.next, *ndev.tenant_id, *ndev.offload_orig
        *ldev = *ndev;
                ^

Bug: #5291.
(cherry picked from commit 3bc50df9c3397b9ab06376657c5e8c3467fbc7c5)

3 years agodetect: fix bad BUG_ON pattern
Victor Julien [Tue, 26 Apr 2022 19:33:52 +0000 (21:33 +0200)] 
detect: fix bad BUG_ON pattern

cppcheck:

src/detect-engine-uint.c:73:13: warning: Conversion of string literal "unknown mode" to bool always evaluates to true. [incorrectStringBooleanError]
            BUG_ON("unknown mode");
            ^
src/detect-engine-uint.c:328:13: warning: Conversion of string literal "unknown mode" to bool always evaluates to true. [incorrectStringBooleanError]
            BUG_ON("unknown mode");
            ^
src/detect-pcre.c:291:25: warning: Conversion of string literal "Impossible captype" to bool always evaluates to true. [incorrectStringBooleanError]
                        BUG_ON("Impossible captype");
                        ^

Bug: #5291.
(cherry picked from commit 7e2ed11a11cae89bc07e9a25425192581687993d)

3 years agotime: fix warning in timestring creation
Victor Julien [Tue, 26 Apr 2022 19:03:42 +0000 (21:03 +0200)] 
time: fix warning in timestring creation

cppcheck:

src/util-time.c:255:18: warning: Either the condition 'str!=NULL' is redundant or there is possible null pointer dereference: str. [nullPointerRedundantCheck]
        snprintf(str, size, "ts-error");
                 ^
src/util-time.c:252:48: note: Assuming that condition 'str!=NULL' is not redundant
    if (likely(t != NULL && fmt != NULL && str != NULL)) {
                                               ^
src/util-time.c:255:18: note: Null pointer dereference
        snprintf(str, size, "ts-error");
                 ^

Only `t` could possibly be NULL if `localtime_r` fails elsewhere.

Bug: #5291.
(cherry picked from commit 2f48e432cd4465bbb1f42fe7778fee44a5d0aa47)

3 years agodetect/multi-tentancy: minor format string fixes
Victor Julien [Tue, 26 Apr 2022 18:36:36 +0000 (20:36 +0200)] 
detect/multi-tentancy: minor format string fixes

cppcheck:

src/detect-engine.c:3643:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
    snprintf(prefix, sizeof(prefix), "multi-detect.%d", tenant_id);
    ^
src/detect-engine.c:3707:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
    snprintf(prefix, sizeof(prefix), "multi-detect.%d.reload.%d", tenant_id, reload_cnt);
    ^
src/detect-engine.c:4086:17: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
                snprintf(prefix, sizeof(prefix), "multi-detect.%d", tenant_id);
                ^

Bug: #5291.
(cherry picked from commit 4fcb8740e7b98eee1b5e65bd66045c9440cef8b6)

3 years agoreference: remove useless var reset
Victor Julien [Tue, 26 Apr 2022 18:18:28 +0000 (20:18 +0200)] 
reference: remove useless var reset

cppcheck:

src/util-reference-config.c:179:9: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]
        fd = NULL;
        ^

Bug: #5291.
(cherry picked from commit 5a0bbb5289cd0fbf4ef50294127cb1018baf82a2)

3 years agorunmodes: minor format string fixes
Victor Julien [Tue, 26 Apr 2022 18:17:27 +0000 (20:17 +0200)] 
runmodes: minor format string fixes

cppcheck:

src/util-runmodes.c:210:9: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
        ^
src/util-runmodes.c:211:9: warning: %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(qname, sizeof(qname), "pickup%u", thread+1);
        ^
src/util-runmodes.c:455:9: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
        ^
src/util-runmodes.c:457:9: warning: %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(qname, sizeof(qname), "pickup%u", thread+1);
        ^

src/runmode-erf-file.c:188:9: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
        ^
src/runmode-erf-file.c:189:9: warning: %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(qname, sizeof(qname), "pickup%u", thread+1);
        ^
src/runmode-pcap-file.c:201:9: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
        ^
src/runmode-pcap-file.c:202:9: warning: %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
        snprintf(qname, sizeof(qname), "pickup%u", thread+1);
        ^

Bug: #5291.
(cherry picked from commit 2965d809a44817223d3e6bc81e55c2286da5212b)

3 years agompm/ac-ks: address int handling issues
Victor Julien [Tue, 26 Apr 2022 18:14:39 +0000 (20:14 +0200)] 
mpm/ac-ks: address int handling issues

cppcheck:

src/util-mpm-ac-ks.c:1452:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
    printf("Total states in the state table:    %d\n", ctx->state_count);
    ^
src/util-mpm-ac-ks.c:606:34: error: Signed integer overflow for expression '1<<31'. [integerOverflow]
        encoded_next_state |= (1 << 31);
                                 ^

Bug: #5291.
(cherry picked from commit a8d3cd6eb4f181000256986ea7cf83074a0d2b59)

3 years agoclassification: remove useless clear
Victor Julien [Tue, 26 Apr 2022 18:12:20 +0000 (20:12 +0200)] 
classification: remove useless clear

cppcheck:

src/util-classification-config.c:189:9: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]
        fd = NULL;
        ^

Bug: #5291.
(cherry picked from commit 9c672a805fe1fe78591ec0f06da56e23c99d0751)

3 years agodetect/content-inspect: code cleanup
Victor Julien [Tue, 26 Apr 2022 18:06:43 +0000 (20:06 +0200)] 
detect/content-inspect: code cleanup

Rearrange code slightly to make it more clear that `found` cannot
be NULL further down the loop.

cppcheck:

src/detect-engine-content-inspection.c:316:50: warning: Either the condition 'found!=NULL' is redundant or there is overflow in pointer subtraction. [nullPointerArithmeticRedundantCheck]
                match_offset = (uint32_t)((found - buffer) + cd->content_len);
                                                 ^
src/detect-engine-content-inspection.c:308:30: note: Assuming that condition 'found!=NULL' is not redundant
            } else if (found != NULL && (cd->flags & DETECT_CONTENT_NEGATED)) {
                             ^
src/detect-engine-content-inspection.c:316:50: note: Null pointer subtraction
                match_offset = (uint32_t)((found - buffer) + cd->content_len);
                                                 ^

Bug: #5291.
(cherry picked from commit 27e9a871d0f7feeafb8fff266b2bb4d97abd39f3)

3 years agodetect/analyzer: minor format string fixes
Victor Julien [Tue, 26 Apr 2022 18:05:51 +0000 (20:05 +0200)] 
detect/analyzer: minor format string fixes

cppcheck flagged this as:

src/detect-engine-analyzer.c:1359:13: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            fprintf(rule_engine_analysis_FD, "    Rule contains %d content options, %d http content options, %d pcre options, and %d pcre options with http modifiers.\n", rule_content, rule_content_http, rule_pcre, rule_pcre_http);
            ^
src/detect-engine-analyzer.c:1359:13: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            fprintf(rule_engine_analysis_FD, "    Rule contains %d content options, %d http content options, %d pcre options, and %d pcre options with http modifiers.\n", rule_content, rule_content_http, rule_pcre, rule_pcre_http);
            ^
src/detect-engine-analyzer.c:1359:13: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            fprintf(rule_engine_analysis_FD, "    Rule contains %d content options, %d http content options, %d pcre options, and %d pcre options with http modifiers.\n", rule_content, rule_content_http, rule_pcre, rule_pcre_http);
            ^
src/detect-engine-analyzer.c:1359:13: warning: %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            fprintf(rule_engine_analysis_FD, "    Rule contains %d content options, %d http content options, %d pcre options, and %d pcre options with http modifiers.\n", rule_content, rule_content_http, rule_pcre, rule_pcre_http);
            ^

Bug: #5291.
(cherry picked from commit a0847e6c697055b127343cc338029bc69bbc0791)

3 years agodetect/address: remove useless checks
Victor Julien [Tue, 26 Apr 2022 18:04:28 +0000 (20:04 +0200)] 
detect/address: remove useless checks

Cppcheck flagged this:

src/detect-engine-address.c:1035:48: warning: Either the condition 'ghn!=NULL' is redundant or there is possible null pointer dereference: gh. [nullPointerRedundantCheck]
    int r = DetectAddressIsCompleteIPSpaceIPv4(gh->ipv4_head);
                                               ^
src/detect-engine-address.c:1297:17: note: Assuming that condition 'ghn!=NULL' is not redundant
        if (ghn != NULL) {
                ^
src/detect-engine-address.c:1283:44: note: Calling function 'DetectAddressIsCompleteIPSpace', 1st argument 'ghn' value is 0
        if (DetectAddressIsCompleteIPSpace(ghn)) {
                                           ^
src/detect-engine-address.c:1035:48: note: Null pointer dereference
    int r = DetectAddressIsCompleteIPSpaceIPv4(gh->ipv4_head);
                                               ^

Cleanup code could only be reached with non-NULL pointers, so simplify checks.

Bug: #5291.
(cherry picked from commit f8a0f3d9b9f4e1aa758a493e00d38e98a552a0d6)

3 years agodetect/ipv6: remove useless code
Victor Julien [Tue, 26 Apr 2022 18:02:19 +0000 (20:02 +0200)] 
detect/ipv6: remove useless code

Remove useless allocation and free.

Found by cppcheck as a potential issue:

src/detect-engine-address-ipv6.c:385:12: warning: Either the condition 'tmp!=NULL' is redundant or there is possible null pointer dereference: tmp. [nullPointerRedundantCheck]
    memset(tmp,0,sizeof(DetectAddress));
           ^
src/detect-engine-address-ipv6.c:525:13: note: Assuming that condition 'tmp!=NULL' is not redundant
    if (tmp != NULL)
            ^
src/detect-engine-address-ipv6.c:385:12: note: Null pointer dereference
    memset(tmp,0,sizeof(DetectAddress));
           ^

But code turned out not to do anything, so removed.

Bug: #5291.
(cherry picked from commit bad900516133a81afb0a6d3982fa3de5871e6ba7)

3 years agodatasets: fix cppcheck warning
Victor Julien [Tue, 26 Apr 2022 18:01:19 +0000 (20:01 +0200)] 
datasets: fix cppcheck warning

src/datasets.c:107:17: error: Uninitialized variable: hash [uninitvar]
    memcpy(out, hash, outs);
                ^
src/datasets.c:93:26: note: Assuming condition is false
    for (x = 0, i = 0; i < ins; i+=2, x++) {
                         ^
src/datasets.c:107:17: note: Uninitialized variable: hash
    memcpy(out, hash, outs);
                ^

Bug: #5291.
(cherry picked from commit ea2d0ecf08842d52f77d1a88a184a85960999e1e)

3 years agoftp-data: fix direction for active mode commands
Victor Julien [Sat, 30 Apr 2022 14:54:07 +0000 (16:54 +0200)] 
ftp-data: fix direction for active mode commands

Set correct direction for PORT mode, where the server connects
to the client.

The direction is not also strictly enforced. No data in the wrong
direction will be accepted to setup the file or to be added to the
file after setup.

This also fixes files getting closed twice.

Adds some general cleanups.

Bug: #3542.
(cherry picked from commit 07bf9214513e54e04508c055bb8ed29aa3bce60f)

3 years agoippair/storage: use dedicated 'id' type
Juliana Fajardini [Wed, 14 Apr 2021 22:09:02 +0000 (23:09 +0100)] 
ippair/storage: use dedicated 'id' type

- Wrap the id in a new IPPairStorageId struct, to avoid id
confusion with other storage API calls.
- Formatting fixes by clang.

(cherry picked from commit cf516de587d27300cb5af42ae548f54351f7de5d)

3 years agoflow/storage: use dedicated 'id' type
Victor Julien [Fri, 9 Apr 2021 10:56:01 +0000 (12:56 +0200)] 
flow/storage: use dedicated 'id' type

Wrap the id in a new FlowStorageId struct to avoid id confusion with other
storage API calls.

(cherry picked from commit bc667a4a939c887bc298bbb865eda4338f8cea2f)

3 years agoapp-layer/expectation: clean up storage id logic
Victor Julien [Fri, 9 Apr 2021 08:15:39 +0000 (10:15 +0200)] 
app-layer/expectation: clean up storage id logic

(cherry picked from commit 4b3be245065062a3970c6aafa70d25bde969873e)

3 years agodetect/flowbits: remove dead code
Shivani Bhardwaj [Tue, 5 Apr 2022 10:36:08 +0000 (16:06 +0530)] 
detect/flowbits: remove dead code

3 years agodetect/flowbits: add test for bug 5154
Shivani Bhardwaj [Tue, 5 Apr 2022 10:32:41 +0000 (16:02 +0530)] 
detect/flowbits: add test for bug 5154

3 years agodetect/flowbits: use strtok_r for parsing
Shivani Bhardwaj [Wed, 30 Mar 2022 09:45:07 +0000 (15:15 +0530)] 
detect/flowbits: use strtok_r for parsing

Fixes underlying parsing issues by keeping stricter argument checks.

Redmine Bug: 5154

3 years agoftp: truncate first segment if over max length
Jason Ish [Fri, 22 Apr 2022 18:04:37 +0000 (12:04 -0600)] 
ftp: truncate first segment if over max length

The first segment was not limited to the configured maximum line length
allowing it to be up to 65k. This could result in the next input length
being negative, which while handled properly by the code, did trigger a
debug validation assertion.

The fix is to be consistent and apply the limit to the first segment as
well, which does ensure the input_len could never be less than 0.

Ticket #5281

(cherry picked from commit 9645285dff9eb8313db573d8603162a708736236)

3 years agoscripts/bundle: use git instead of tar.gz
Jason Ish [Thu, 29 Oct 2020 23:05:01 +0000 (17:05 -0600)] 
scripts/bundle: use git instead of tar.gz

To better fit with our current CI processes, use git to clone the
suricata-update and libhtp dependencies.  The requirements.txt file has
been modified to take a repo URL and a `-b` command line option for tag
or branch.

For the 6.0.x branch we will use the libhtp 0.5.x branch and the
suricata-update 1.2.4 tag.

Also allows for repo and branch names to be overrided with environment
variables:
- SU_REPO
- SU_BRANCH
- LIBHTP_REPO
- LIBHTP_BRANCH

3 years agodetect: update copyright years
Juliana Fajardini [Thu, 21 Apr 2022 14:51:21 +0000 (11:51 -0300)] 
detect: update copyright years

(cherry picked from commit 192360aa052841f21d22149b049ef94691f9a1f7)

3 years agoassorted: fix low hanging typos
Juliana Fajardini [Thu, 21 Apr 2022 15:47:03 +0000 (12:47 -0300)] 
assorted: fix low hanging typos

(cherry picked from commit 29b5f68bf0770750954780982c46c6fa82eec96b)

3 years agouserguide: explain alert queue behavior and stats
Juliana Fajardini [Wed, 6 Apr 2022 20:06:09 +0000 (17:06 -0300)] 
userguide: explain alert queue behavior and stats

Added sections along packet-alert-max config section explaining
packet alert queue overflow (when Suri reaches packet alert max), when
alerts are discarded etc.

Since from the user perspective it shouldn't matter how we process the
alert queue, the term "replace" is used, even though there's not exactly
a replacing action happening, with the queue bein pre-processed before
being appended to the Packet.

Also described the associated stats and added an explanation on when to
change packet-alert-max.

Task #5178

(cherry picked from commit 1956dc3d5da5dfdc55e0f8304e815b99bd7567e4)

3 years agodetect/stats: log out total of suppressed alerts
Juliana Fajardini [Wed, 20 Apr 2022 16:49:31 +0000 (13:49 -0300)] 
detect/stats: log out total of suppressed alerts

Related to
Task #4943
Task #5179

(cherry picked from commit 877b32c1e42c6edde3fa5f6ab73293e0a4ad27c3)

3 years agodetect/stats: log out total of discarded alerts
Juliana Fajardini [Tue, 5 Apr 2022 19:54:29 +0000 (16:54 -0300)] 
detect/stats: log out total of discarded alerts

Add a counter to our stats log with the total of alerts that have been
discarded due to packet alert queue overflow.

Task #5179

(cherry picked from commit 8616c90fe7573815137a1dbc7fdfeded95f2b38f)

3 years agodetect/alert: move apply-action-flow code to func
Juliana Fajardini [Wed, 27 Apr 2022 22:18:27 +0000 (19:18 -0300)] 
detect/alert: move apply-action-flow code to func

Trying to clean PacketAlertFinalize a bit more.

(cherry picked from commit 9b275d3878643fa27ac4f54d74ba66b51e115459)

3 years agodetect/alert: remove unused functions
Juliana Fajardini [Wed, 20 Apr 2022 20:50:43 +0000 (17:50 -0300)] 
detect/alert: remove unused functions

Since we now only copy the PacketAlerts to the Packet's queue after
processing them, we no longer do packet alert appending from
detect-engine-alert, nor do we remove PacketAlerts from the queue (if
they're discarded by overflow or thresholding, they're not copied to the
final alert queue).

Task #4943

(cherry picked from commit e4e688a9b0add66aa0b97df0f7b1b9e60f68fb90)

3 years agodetect/alert: preprocess then append alert queue
Juliana Fajardini [Tue, 19 Apr 2022 20:43:10 +0000 (17:43 -0300)] 
detect/alert: preprocess then append alert queue

Do all alert queue processing before actually appending
the PacketAlerts to the Packet's alert queue.

Adjusted changes to use macro instead of functions, in cases where the
latter didn't exist in this branch.

Task #4943

(cherry picked from commit 185b43edff7f3f9db0c919663eb02ceb49787a8f)

3 years agodetect/engine: use alert queue from det_ctx
Juliana Fajardini [Tue, 19 Apr 2022 13:58:22 +0000 (10:58 -0300)] 
detect/engine: use alert queue from det_ctx

Task #4943

(cherry picked from commit aa547a8de38d7066d47d83449fba67a0a640260d)

3 years agodetect/alert: add infra for new alert queue
Juliana Fajardini [Mon, 18 Apr 2022 21:14:52 +0000 (18:14 -0300)] 
detect/alert: add infra for new alert queue

Initial work to bring part of the alert queue processing to
DetectEngineThreadCtx.

Task #4943

(cherry picked from commit 88805f03eec038fd67a18599d7d9f037db083941)

3 years agodoc/userguide: explain packet-alert-max config
Juliana Fajardini [Wed, 6 Apr 2022 14:54:52 +0000 (11:54 -0300)] 
doc/userguide: explain packet-alert-max config

Task #4207

(cherry picked from commit 49542d0f1bb35d889f798a50c04f4a257b816695)

3 years agodecode: make packet_alert_max configurable
Juliana Fajardini [Wed, 19 Jan 2022 18:29:39 +0000 (18:29 +0000)] 
decode: make packet_alert_max configurable

The maximum of possible alerts triggered by a unique packet was
hardcoded to 15. With usage of 'noalert' rules, that limit could be
reached somewhat easily. Make that configurable via suricata.yaml.

Conf Bug#4941

Task #4207

(cherry picked from commit 3ace577d5426e2e1afd1cdf0736151022771226c)

3 years agounittests: alloc Packet with PacketGetFromAlloc
Juliana Fajardini [Mon, 2 May 2022 22:22:33 +0000 (19:22 -0300)] 
unittests: alloc Packet with PacketGetFromAlloc

Some unittests used SCMalloc for allocating new Packet the unittests.
While this is valid, it leads to segmentation faults when we move to
dynamic allocation of the maximum alerts allowed to be triggered by a
single packet.

This massive patch uses PacketGetFromAlloc, which initializes a Packet
in such a way that any dynamic allocated structures within will also be
initialized.

Backport: edit a few more files/unittests that were not present in 7.0.x

Related to
Task #4207

(cherry picked from commit a6bda3596bdd1a0ac04afe5553609c6f7cba0023)

3 years agosignal/stack: Default stack-on-signal setting: off 7324/head
Jeff Lucovsky [Tue, 26 Apr 2022 18:47:06 +0000 (14:47 -0400)] 
signal/stack: Default stack-on-signal setting: off

Ticket: 5228

This commit changes the default value of the stack-on-signal feature to
be disabled.

3 years agosignal/stack: Remove redundant initialization
Jeff Lucovsky [Tue, 26 Apr 2022 18:46:06 +0000 (14:46 -0400)] 
signal/stack: Remove redundant initialization

Ticket: 5228

This commit removes the redundant initialization of the stack-on-signal
functionality.

3 years agodetect: fix rule inspection order
Victor Julien [Mon, 25 Apr 2022 16:00:24 +0000 (18:00 +0200)] 
detect: fix rule inspection order

Fix rules from the 'match' list getting added to the tx candidates list
unsorted. In some cases this could lead to the same sid getting inspected
twice leading to a DEBUG_VALIDATION_BUG_ON trigger.

Bug: #5144.
(cherry picked from commit 4bb00964ac22f0f96704cf5befca76d056763142)

3 years agodetect: use bool for uint16_t used as bool
Victor Julien [Tue, 30 Nov 2021 12:35:48 +0000 (13:35 +0100)] 
detect: use bool for uint16_t used as bool

(cherry picked from commit bb3d49d5bf6376756e124a79b4f25799d934617c)

3 years agostream: improve flow end payload logging
Victor Julien [Sat, 23 Apr 2022 11:59:34 +0000 (13:59 +0200)] 
stream: improve flow end payload logging

Use all available data, including un-ACK'd, when in flow timeout
mode.

Bug: #5276.
(cherry picked from commit c40df43609becc467e86d756098829b3174c80c7)

3 years agostream/unittests: fix failures after last_ack fix
Victor Julien [Fri, 22 Apr 2022 17:33:13 +0000 (19:33 +0200)] 
stream/unittests: fix failures after last_ack fix

Work around many tests not setting up stream completely or correctly.

(cherry picked from commit 3d6e733aa7297f64fe87cc3b59fbbd9a527513fa)

3 years agostream: improve last_ack validation check
Victor Julien [Fri, 22 Apr 2022 16:27:15 +0000 (18:27 +0200)] 
stream: improve last_ack validation check

If a packet after the initialization would come with ACK flag set
but a ACK value of 0, the last_ack tracking could get confused. Fix
this by not checking for 0 but instead checking if the ACK flag
has been seen.

Bug: #4549.
(cherry picked from commit 1f43e1477f3c5781381e75f4bed918cbc6c18dfd)

3 years agoversion: start development towards 6.0.6
Victor Julien [Wed, 27 Apr 2022 09:06:22 +0000 (11:06 +0200)] 
version: start development towards 6.0.6

3 years agorelease: 6.0.5; update changelog; require htp 0.5.40 7288/head suricata-6.0.5
Victor Julien [Thu, 21 Apr 2022 06:34:30 +0000 (08:34 +0200)] 
release: 6.0.5; update changelog; require htp 0.5.40

3 years agosmtp: support per-tx file accounting
Victor Julien [Thu, 18 Mar 2021 07:38:03 +0000 (08:38 +0100)] 
smtp: support per-tx file accounting

(cherry picked from commit 0867b0dbcdd9a6973d505714928ea7323a4f5384)

3 years agodetect-file-data: remove SMTP unittests
Modupe Falodun [Fri, 14 Jan 2022 15:53:28 +0000 (16:53 +0100)] 
detect-file-data: remove SMTP unittests

These tests are reimplemented as Suricata-verify tests

Task: 4938
(cherry picked from commit 3dbf74ff1025b843eb09b0e4d5e2c90614d7cc9e)

3 years agosmtp: don't pass partial boundary on to mime parser
Victor Julien [Fri, 15 Apr 2022 13:51:10 +0000 (15:51 +0200)] 
smtp: don't pass partial boundary on to mime parser

If the start of a line looks like it might be a mime boundary we
yield to the get line logic if we don't have enough data to be
conclusive.

(cherry picked from commit e7417a8e96fcd23fa9e3b529d7c2bbd7b3efb928)

3 years agomime: allow partial lines as input
Victor Julien [Fri, 15 Apr 2022 13:49:09 +0000 (15:49 +0200)] 
mime: allow partial lines as input

If we get a zero length delim we assume its a partial line and we
won't append CRLF just yet.

(cherry picked from commit 6e800a8548d9d2699589cac6afca3c0fa7613202)

3 years agosmtp: pre process DATA and BDAT commands
Shivani Bhardwaj [Thu, 14 Apr 2022 15:59:32 +0000 (21:29 +0530)] 
smtp: pre process DATA and BDAT commands

The input data received in DATA and BDAT command modes can be huge and
could have important data, like a legit huge email. Therefore, exempt
these from the line buffering limits which were introduced to regulate
the size of lines that we buffer at any point in time.

As a part of this patch, anything that comes under DATA or BDAT is
processed early without buffering as and when it arrives. The ways of
processing remain the same as before.

(cherry picked from commit cf749fd450ca41dc001c2a1c10d8d17500dcedce)

3 years agosmtp: fix indefinite buffering if no LF in line
Shivani Bhardwaj [Mon, 14 Feb 2022 11:23:52 +0000 (16:53 +0530)] 
smtp: fix indefinite buffering if no LF in line

Issue
-----
So far, with the SMTP parser, we would buffer data up until an LF char
was found indicating the end of one line. This would happen in case of
fragmented data where a line might come broken into multiple chunks.
This was problematic if there was a really long line without any LF
character. It would mean that we'd keep buffering data up until we
encounter one such LF char which may be many many bytes of data later.

Fix
---
Fix this issue by setting an upper limit of 4KB on the buffering of
lines. If the limit is reached then we save the data into current line
and process it as if it were a regular request/response up until 4KB
only. Any data after 4KB is discarded up until there is a new LF char in
the received input.

Cases
-----
1. Fragmentation
The limit is enforced for any cases where a line of >= 4KB comes as diff
fragments that are each/some < 4KB.
2. Single too long line
The limit is also enforced for any cases where a single line exceeds the
limit of buffer.

Reported by Victor Julien.
Ticket 5023

(cherry picked from commit 078c251deacc78b8abb40c5ab89d19c29e31bdf8)

3 years agosmtp: add truncated line event
Shivani Bhardwaj [Wed, 20 Apr 2022 07:25:54 +0000 (12:55 +0530)] 
smtp: add truncated line event

(cherry picked from commit 57a7cf7a0bcc9140a326c91a21e5d21fd2236f49)

3 years agosmtp: use AppLayerResult instead of buffering
Shivani Bhardwaj [Mon, 3 Jan 2022 14:14:53 +0000 (19:44 +0530)] 
smtp: use AppLayerResult instead of buffering

Also, remove tests that check for the removed buffers and any middle
states while parsing and buffering.

Ticket 4907

(cherry picked from commit 8918f53f6bc9b9a858f44964c74ec2dcaa4312fa)

3 years agodoc/userguide: document ftp max-line-length
Jason Ish [Thu, 7 Apr 2022 21:58:58 +0000 (15:58 -0600)] 
doc/userguide: document ftp max-line-length

(cherry picked from commit 7d6bc60abb6eefce3f0d20222b2a843de9ea5a6e)

3 years agoftp: truncate command data that is too long
Jason Ish [Wed, 6 Apr 2022 21:38:35 +0000 (15:38 -0600)] 
ftp: truncate command data that is too long

FTP control commands will be buffered forever until a new line is seen,
this can lead to memory exhaustion in Suricata.

To fix, set an upper bound, 4096 bytes on the size of the command that
is saved in the transaction. The input continues to be parsed to find
the end of the command so the parser can continue to move onto the next
command.

The result is that the command data in the transaction is truncated,
which also shows up in the ftp transaction logs.

This value is configurable with the max-line-length field in the ftp
app-layer.protocols section.

As FTP doesn't have events at this time, add a new fields to eve-log
that specificy if the request, or the response has been truncated.

Ticket #5024

(cherry-picked from commit cf8ed576e09a68886760259055e309e51bf5bec3)

3 years agodetect: config checks alstate before getting tx
Philippe Antoine [Fri, 8 Apr 2022 13:15:23 +0000 (15:15 +0200)] 
detect: config checks alstate before getting tx

Ticket: 4972

As is done in detect-lua-extensions.
We can have a flow with alproto unknown, no state, and therefore
cannot run AppLayerParserGetTx which could try to run a NULL
function

(cherry picked from commit dccf2e4c30b968477d9cc7e7a86b64b97893831c)

3 years agodetect: not an iponly signature if it needs app-layer
Philippe Antoine [Wed, 30 Mar 2022 13:24:32 +0000 (15:24 +0200)] 
detect: not an iponly signature if it needs app-layer

Ticket: 4972

This may happen with `config` keyword which is postmatch,
but may require a transaction

(cherry picked from commit 0cba561fecffe93596d38691561d4316c3b8efb2)

3 years agodetect: makes config keyword really require a flow
Philippe Antoine [Tue, 8 Mar 2022 11:50:16 +0000 (12:50 +0100)] 
detect: makes config keyword really require a flow

Ticket: 4972

Completes commit c3a220647

DETECT_CONFIG is added as DETECT_SM_LIST_POSTMATCH and not
as DETECT_SM_LIST_MATCH as other keywords handled in SignatureCreateMask

(cherry picked from commit 00da0d3420fd6ebbdbe7990b26eebf7650856eca)

3 years agodetect: only apply ConfigApplyTx with app-layers
Philippe Antoine [Mon, 17 Jan 2022 13:47:48 +0000 (14:47 +0100)] 
detect: only apply ConfigApplyTx with app-layers

Ticket: 4972

Otherwise, it makes no sense to look for a tx...

(cherry picked from commit c3a220647b31b453b0fc14ecfb028defad2778dc)

3 years agodns: don't parse a full request during probe if not enough data
Jason Ish [Mon, 28 Feb 2022 22:48:34 +0000 (16:48 -0600)] 
dns: don't parse a full request during probe if not enough data

If there is more data than a header, but not enough for a complete DNS
message, the hostname parser could return an error causing the probe to
fail on valid DNS messages.

So only parse the complete message if we have enough input data. This is
reliable for TCP as DNS messages are prefixed, but for UDP its just
going to be the size of the input buffer presented to the parser, so
incomplete could still happen.

Ticket #5034

(cherry picked from commit 27679a12aa4e03e960112f387640419d29780e5a)

3 years agodns: better error handling when parsing names
Jason Ish [Tue, 1 Feb 2022 21:44:43 +0000 (15:44 -0600)] 
dns: better error handling when parsing names

The DNS name parser will error out with an error even if the
error is incomplete. Instead of manually generating errors,
use '?' to let the nom error ripple up the error handling chain.

The reason this wasn't done in the first place is this code
predates the ? operator, or we were not aware of it at the time.

This prevents the case where probing fails when there is enough data to
parse the header, but not enough to complete name parser. In such a case
a parse error is returned (instead of incomplete) resulting in the
payload not being detected as DNS.

Ticket #5034

(cherry picked from commit 0623ada24df1da99c72bb8cd4959b2cb0e64ccc2)

3 years agosmb: protocol detection on pattern without midstream
Jason Ish [Thu, 31 Mar 2022 18:45:07 +0000 (12:45 -0600)] 
smb: protocol detection on pattern without midstream

To recognize a protocol, Suricata first looks for
patterns, which can be confirmed by a probing parser.
If this does not work, Suricata can try to run
some probing parsers on some ports.

This is the case for SMB.

This commit makes handling the confirming and the probing
paser differently even if they share much code.

The confirmation parser knows that a pattern has been found.
So, it must not do the midstream case of looking for this
pattern in the whole buffer, but only check it at the beginning.
But it must reverse direction if needed.

Ticket #4849

Backported manually by jason.ish@oisf.net.

(cherry picked from commit 464ff80c6a8efd1212b617a80c726173573caf42)

3 years agoftp: do not set alproto if one was already found
Philippe Antoine [Mon, 29 Nov 2021 09:59:10 +0000 (10:59 +0100)] 
ftp: do not set alproto if one was already found

Ticket: 4857

If a pattern such as GET is seen ine the beginning of the
file transferred over ftp-data, this flow will get recognized
as HTTP, and a HTTP state will be created during parsing.

Thus, we cannot override directly alproto's values

This solves the segfault, but not the logical bug that the flow
should be classified as FTP-DATA instead of HTTP

(cherry picked from commit dd32238667f08c7211ae4fa27cfe43af7cffd52d)

3 years agodnp3: check Base64Encode return value for logging
Philippe Antoine [Mon, 29 Nov 2021 12:24:12 +0000 (13:24 +0100)] 
dnp3: check Base64Encode return value for logging

So that NULL pointers do not get logged

Ticket #4849

3 years agoutil: right parenthesises for base64 macro
Philippe Antoine [Mon, 29 Nov 2021 12:20:40 +0000 (13:20 +0100)] 
util: right parenthesises for base64 macro

So that BASE64_BUFFER_SIZE(3) == 5 instead of 7

3 years agotftp: use destate
Philippe Antoine [Mon, 22 Nov 2021 09:37:33 +0000 (10:37 +0100)] 
tftp: use destate

And avoids memory leaks on it

Ticket #4848

3 years agoapp-layer: better warning message when enabling by default
Jason Ish [Wed, 20 Apr 2022 17:10:35 +0000 (11:10 -0600)] 
app-layer: better warning message when enabling by default

The warning message suggests that the configuration section doesn't
exist if when it does, but the "enabled" flag is not set. Clarify the
warning message that the enable status is not set.

3 years agosmb: fix read queue exceeded event and rules
Victor Julien [Wed, 20 Apr 2022 19:58:59 +0000 (21:58 +0200)] 
smb: fix read queue exceeded event and rules

3 years agosmb: log max read/write sizes
Victor Julien [Mon, 18 Apr 2022 20:14:36 +0000 (22:14 +0200)] 
smb: log max read/write sizes

(cherry picked from commit 90d4b8e43804d4a03190ad06b6863c808c8b4acd)

3 years agosmb/rules: add rules for new events
Victor Julien [Tue, 19 Apr 2022 10:35:52 +0000 (12:35 +0200)] 
smb/rules: add rules for new events

(cherry picked from commit b0354437d5064e6843ab05b881929859b0009435)

3 years agodoc/smb: add resource limits section
Victor Julien [Tue, 19 Apr 2022 10:17:31 +0000 (12:17 +0200)] 
doc/smb: add resource limits section

(cherry picked from commit 976748b777fbbbba41491401c73c83e05e0a7c8a)

3 years agosmb2: validate negotiate read/write max sizes
Victor Julien [Tue, 19 Apr 2022 06:13:48 +0000 (08:13 +0200)] 
smb2: validate negotiate read/write max sizes

Raise event if they exceed the configured limit.

(cherry picked from commit fc9b65d8d3188c57016635aef8d7cdfe4552324e)

3 years agosmb2: allow limiting in-flight data size/cnt
Victor Julien [Sat, 16 Apr 2022 04:58:20 +0000 (06:58 +0200)] 
smb2: allow limiting in-flight data size/cnt

Allow limiting in-flight out or order data chunks per size or count.

Implemented for read and writes separately:

app-layer.protocols.smb.max-write-queue-size
app-layer.protocols.smb.max-write-queue-cnt
app-layer.protocols.smb.max-read-queue-size
app-layer.protocols.smb.max-read-queue-cnt

(cherry picked from commit 4be8334c9e95cc520c9c6a63a98d6b160915d07f)

3 years agofiletracker: track total queued data (in_flight)
Victor Julien [Sat, 16 Apr 2022 04:57:56 +0000 (06:57 +0200)] 
filetracker: track total queued data (in_flight)

As well as expose number of chunks.

(cherry picked from commit 2c5ad8858e38fce20155044a06969693fe472d4c)

3 years agosmb2: add options for max read/write size
Victor Julien [Mon, 18 Apr 2022 19:47:39 +0000 (21:47 +0200)] 
smb2: add options for max read/write size

Add options for the max read/write size accepted by the parser.

(cherry picked from commit 5bcc4162f7051194d228ba6c58a665d71c0c047c)

3 years agosmb2: track max read/write size and enforce its values
Victor Julien [Mon, 18 Apr 2022 15:49:58 +0000 (17:49 +0200)] 
smb2: track max read/write size and enforce its values

(cherry picked from commit f28888513ac3be18715f522db253c5753adb94ed)

3 years agosmb: minor function cleanup
Victor Julien [Fri, 15 Apr 2022 18:52:48 +0000 (20:52 +0200)] 
smb: minor function cleanup

Remove used argument from `filetracker_newchunk()`. We're not
using fill_bytes with smb.

(cherry picked from commit 594acec5dc88540dddc18b3ee0ad89af0948ee33)

3 years agofiletracker: make FileChunk private
Victor Julien [Fri, 15 Apr 2022 18:00:55 +0000 (20:00 +0200)] 
filetracker: make FileChunk private

(cherry picked from commit c7a474c7253233ce1117ae4af5a5c1fcc4b4e7f4)

3 years agomqtt: fix consumed bytes computation for truncated msg 7271/head
Philippe Antoine [Mon, 11 Apr 2022 19:29:33 +0000 (21:29 +0200)] 
mqtt: fix consumed bytes computation for truncated msg

Ticket: 5268
(cherry picked from commit 3b13008c1b6b994df0ae3f702c24780fd253ec32)

3 years agomqtt: raise event on parse error 7270/head
Sascha Steinbiss [Tue, 8 Mar 2022 22:18:36 +0000 (23:18 +0100)] 
mqtt: raise event on parse error

3 years agomqtt: ensure we do not request extra data after buffering
Jason Ish [Tue, 19 Apr 2022 19:28:50 +0000 (13:28 -0600)] 
mqtt: ensure we do not request extra data after buffering

This is a minimal backport of 5618273ef4babc2fe8ff6a40848cd92dc4dfcdcf
to address ticket 5018.

Uses the "complete" version of take instead of the macro which is thre
streaming variant.

Ticket #5018

3 years agogithub-ci: pin checkout actions plus other fixups
Jason Ish [Mon, 18 Apr 2022 17:24:20 +0000 (11:24 -0600)] 
github-ci: pin checkout actions plus other fixups

Pin checkout action plus other fixups from master to deal with changes
to the action.

3 years agosmb: rules for messages in the wrong direction 7263/head
Jason Ish [Mon, 28 Feb 2022 21:12:37 +0000 (15:12 -0600)] 
smb: rules for messages in the wrong direction

(cherry picked from commit 1e653249400ec6217af6d3f153f774ec133d5357)

3 years agosmb: handle records in the wrong direction
Jason Ish [Fri, 18 Feb 2022 04:57:30 +0000 (22:57 -0600)] 
smb: handle records in the wrong direction

If an SMB record is seen in the wrong direction, set an event on the PDU
frame and don't process the record in the state.

No error is returned, so the next record will be processed.

(cherry picked from commit 2341f47755c616f9ee3249cd28372eab45889e0d)

3 years agosmb: expose smb1 request/reply flags with a method
Jason Ish [Fri, 18 Feb 2022 17:43:17 +0000 (11:43 -0600)] 
smb: expose smb1 request/reply flags with a method

Adds `.is_request()` and `.is_reply()` to check if a SMB record flags
say the message is a request or a reply.

(cherry picked from commit 09e2d3b216218eaed471b3ddb496873223744cf8)

3 years agosmb: fix smb2 header flag parsing
Jason Ish [Mon, 18 Apr 2022 16:32:25 +0000 (10:32 -0600)] 
smb: fix smb2 header flag parsing

The bits were being parsed in the order they're displayed in Wireshark,
rather than the order they were being seen on the wire, resulting in
direction and async being 0 more often than they should be.

Instead of bits, take the 4 bytes as an le_u32 and just use bit masks to
extract what we need into a struct, I think its easier to reason about
this way when comparing to the Microsoft documentation.

(cherry picked from commit 7b659489c85eaed4921ed9c4b97ecf827560376e)

3 years agotftp: StringToAppProto case
Philippe Antoine [Wed, 20 Oct 2021 08:56:44 +0000 (10:56 +0200)] 
tftp: StringToAppProto case

So, fuzz_applayerparserparse_tftp will fuzz tftp

(cherry picked from commit c9d664b0a0d8e000aa3846e63b2f93b19302161b)

3 years agodetect-content: error on single char hex pairs
Jason Ish [Tue, 22 Mar 2022 15:46:45 +0000 (09:46 -0600)] 
detect-content: error on single char hex pairs

Fix parsing of content like "|aa b cc|" which was parsed as "|aa bc|"
without error or warning. This will now fail out, requiring all hex
values to be 2 chars.

Ticket #5201

(cherry picked from commit 8d1e4a1d0b481b289bcbae619693c4c442e937e1)

3 years agodetect/dataset: cleanup dead code 7227/head
Shivani Bhardwaj [Fri, 28 Jan 2022 13:43:04 +0000 (19:13 +0530)] 
detect/dataset: cleanup dead code

(cherry picked from commit 7366396011227b5e51ca810d86ebf7d310e98f34)

3 years agodetect/dataset: fix space condition in rule lang
Shivani Bhardwaj [Fri, 28 Jan 2022 20:17:17 +0000 (01:47 +0530)] 
detect/dataset: fix space condition in rule lang

If there is a space following a keyword that does not expect a value,
the rule fails to load due to improper value evaluation.
e.g. Space after "set" command
alert http any any -> any any (http.user_agent; dataset:set  ,ua-seen,type string,save datasets.csv; sid:1;)

gives error
[ERRCODE: SC_ERR_UNKNOWN_VALUE(129)] - dataset action "" is not supported.

Fix this by handling values correctly for such cases.

(cherry picked from commit 6d2a2a073120906304f70c0e120565eae96e36b8)

3 years agoflow: fix and simplify locking
Victor Julien [Fri, 8 Apr 2022 20:06:09 +0000 (22:06 +0200)] 
flow: fix and simplify locking

Since:

9551cd053579 ("threading: don't pass locked flow between threads")

`MoveToWorkQueue()` unconditionally unlocks the flow. This allows simpler
locking handling, including of tcp reuse flows.

The simpler logic also fixes a scenario where TCP reuse flows got "unlocked"
twice, once in `FlowGetFlowFromHash()` and once in `MoveToWorkQueue()`.

Bug: #5248.
Coverity: 1494354.
(cherry picked from commit 57533d3e47315e6b96c941fe5fd64149cbeb8b1a)

3 years agolog/stack: Propagate original signal 7215/head
Jeff Lucovsky [Fri, 11 Feb 2022 15:38:45 +0000 (10:38 -0500)] 
log/stack: Propagate original signal

Issue: 4550

This commit modifies the "stack trace on signal" to propagate the
original signal received instead of always raising SIGABRT.

(cherry picked from commit a3443845fbaf5c01bb8758817490bc93b5c039a5)