Commit Graph

12932 Commits (c587e90ebccfe8883ea951e723be461dc58dcc06)

Author SHA1 Message Date
Victor Julien b23fa51e33 detect: fix decoder only events
Add missing setup part of the decoder event sgh.

Bug: #7414.
8 months ago
Philippe Antoine 09ba69cfb0 output/http: log invalid status as a string
Ticket: 7311

If response_status_number is not a valid poisitive integer,
we should not try to parse it again, and fail again,
but just log the raw string.
8 months ago
Victor Julien 923ad6af77 af-packet: speed up thread sync during startup
Threads are initialized sequentially to allow for a predictable mapping
of threads and queues. Not all parts of the start up need to be done
sequentially. The setting up of the rings can be very expensive, taking
of a couple of hundred milliseconds. The ring setup doesn't need to be
done sequentially though.

This patch releases the thread early, after bind but before the ring
setups.

Ticket: #7272.
8 months ago
Jason Ish 8bcc844b6f sigtable: add function to test for a keyword
To be used by the requires keyword to check for keyword support.

Ticket: #7403
8 months ago
Jason Ish 287d8360e7 util-buffer: expand by multiples of 4k 8 months ago
Jason Ish 2e2eaac0b2 output-json: cleanup, have OutputJsonBuilderBuffer return void
The return value was never used.
8 months ago
Jason Ish d39e42728a output-json: drop eve records that are too long
In the situation where the mem buffer cannot be expanded to the
requested size, drop the log message.

For each JSON log context, a warning will be emitted once with a partial
bit of the log record being dropped to identify what event types may be
leading to large log records.

This also fixes the call to MemBufferExpand which is supposed be
passed the amount to expand by, not the new size required.

Ticket: #7300
8 months ago
Philippe Antoine 4ec90bd227 detect: absent keyword to test absence of sticky buffer
Ticket: 2224

It takes an argument to match only if the buffer is absent,
or it can still match if the buffer is present, but we test
the absence of some content.

For multi buffers, absent matches if there are 0 buffers.

For file keywords, absent matches if there is no file.
8 months ago
Philippe Antoine 7682816ef9 http1/detect: code simplification
- DetectEngineInspectBufferHttpHeader is only used with ALPROTO_HTTP1
- engine->progress should be HTP_REQUEST_HEADERS or HTP_RESPONSE_HEADERS based on the direction
8 months ago
Victor Julien 13f420c793 detect/ip-only: code cleanups
Move repeated pattern into helper function.
8 months ago
Victor Julien a8c63992fb detect/sigorder: remove data structs from global namespace
Rename types enum to reflect it is not using a radix tree anymore.
8 months ago
Victor Julien 4aeb606a97 detect/ip-only: remove dead code 8 months ago
Victor Julien 3eb2f6a584 radix: remove old radix tree implementation
No longer used.
8 months ago
Victor Julien 0ea6fe668e detect/iponly: reimplement with radix4 for ipv6
Use a more compact ipv6 specific structure.
8 months ago
Victor Julien 4b6296c848 detect/iponly: reimplement with radix4 for ipv4
Use a more compact ipv4 specific structure.
8 months ago
Victor Julien 8536dd51b5 host-os-policy: switch to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
8 months ago
Victor Julien 82cd053fc8 htp: switch config tree to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
8 months ago
Victor Julien 46fb7bb162 defrag/config: switch to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
8 months ago
Victor Julien c75b29c74f reputation: switch cidr handling to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
8 months ago
Victor Julien 8f03a2eb9b radix: implement more compact trees
Implement a more compact set of trees specifically for IPv4
and IPv6 addresses. This allows for more compact data structures
and fewer memory allocations.

Based on the existing radix tree implementation.
8 months ago
Victor Julien e9a2352b99 host-os-info: test cleanup 8 months ago
Eric Leblond be7cea4d32 suricata: fix list-keywords option
The list keywords option was crashing due to improper init.

Ticket: 7397
8 months ago
Shivani Bhardwaj d0427a2833 detect/smb: fix the sigmatch table for url
sigmatch_table for url entry was incorrectly set to DETECT_FLOW_AGE.
9 months ago
Jason Ish 5d766df12b make: install-headers: rust-bindings.h
rust-bindings.h was not being installed with "make install-headers",
and its now pulled in by a header used for plugin support, so make
sure its installed.

We first attempt to install the "dist" version if exists, otherwise
install the "gen" one. Also install the "gen" even if the "dist" one
exists, as its going to be newer.
9 months ago
Jason Ish 2ac16ee1a6 detect: break apart sigtable setup and initialization
Allows initialization to be done early, so the table is ready for
dynamic registration by plugins which are loaded before signature
setup.
9 months ago
Jason Ish b660ff8aff eve: user callbacks for adding additional data
Provide a way for library/plugin users to register a callback that
will be called prior to an EVE record being closed. The callback will
be passed ThreadVars, Packet, and Flow pointers if available, as well
as private user data.
9 months ago
Jason Ish 30bd2a27ff threads: add initialization callbacks
For library users and plugins that need to hook into the thread life
cycle, perhaps to initialize some thread storage.
9 months ago
Jason Ish fa230efccb threads: add storage api, based on flow storage 9 months ago
Jason Ish a6fc37c90a flow: add callbacks for flow init and flow updates
Adds user registerable callbacks for flow initialization, flow
update and flow finish.

Some plugins, such as other DPI libraries like nDPI need a way to hook
into these flow lifecycle events.

Ticket: #7319
Ticket: #7320
9 months ago
Jeff Lucovsky b30df19f1a app-layer/stats: Expand memuse/memcap handling
This commit adds memcap/memuse handling to the unix-socket interface:
- ftp
- http-byterange
- host

New stats:
- ippair: memuse, memcap
- host: memuse, memcap
- http-byterange: memuse, memcap
9 months ago
Jeff Lucovsky 83bdcda932 thash/memcap: Use atomics for memcap
Issue: 845

Maintain the memcap as an atomic counter so changes through the
unix-socket interface can be supported.
9 months ago
Jeff Lucovsky f23fec0c64 memcap/socket: Improve memcap array support
Remove hard-coded value for the memcap array and substitute compile-time
value for array sizing.

Issue: 845
9 months ago
Philippe Antoine 63324b7368 transforms: move urldecode to rust
Ticket: 7229
9 months ago
Philippe Antoine 8984bc6801 transforms: move xor to rust
Ticket: 7229
9 months ago
Philippe Antoine 45e0acf772 transforms: move http headers transforms to rust
Ticket: 7229
9 months ago
Philippe Antoine f0414570d2 transforms: move casechange to rust
Ticket: 7229
9 months ago
Philippe Antoine 0e5b49d20f transforms: move hash transforms to rust
md5, sha1 and sha256

Ticket: 7229
9 months ago
Philippe Antoine 71da38e702 transforms: move dotprefix to rust
Ticket: 7229
9 months ago
Philippe Antoine 966f659201 transforms: move compress_whitespace to rust
Ticket: 7229
9 months ago
Philippe Antoine 4985ebc0e0 transforms: move strip_whitespace to rust
Ticket: 7229
9 months ago
Philippe Antoine dd71ef0af2 suricata/bpf: fix -Wshorten-64-to-32 warning
Ticket: 7366
Ticket: 6186
9 months ago
Philippe Antoine cca59cdaa9 detect/http: fix progress for headers keywords
Ticket: 7326

Having a lower progress than one where we actually can get
occurences of the multibuffer made prefilter
bail out too early, not having found a buffer in the multi-buffer
that matiched the prefilter.

For example, we registered http_request_header with progress 0
instad of progress HTP_REQUEST_HEADERS==2, and if the first
packet had only the request line, we would consider
that signatures with http_request_header as prefilter/fast_pattern
could not match for this transaction, even if they in fact
could have a later packet with matching headers.

Hence, we got false negatives, if http.request_header or
http.response_header was used as fast pattern, and if the request
or response came in multiple packets, and the first of these packets
did not have enough data (like only http request line),
and the next packets did have the matching data.
9 months ago
Nancy Enos 56e10fd3b2 misc: Remove duplicate function declarations
Ticket: #7297
9 months ago
Nancy Enos 98cd2411b6 detect/analyzer: add more details for the tcp window keyword
Ticket: 6352
9 months ago
Jason Ish b1e7917d4f eve: threadinit/deinit callbacks are optional for filetypes
Only call ThreadInit and ThreadDeinit for custom eve filetypes if they
exist. They are not required by all filetypes.

Ticket: #7359
9 months ago
Philippe Antoine 292c218a48 app-layer: remove ALPROTO_TEST and tests
These tests purpose seems to have been lost.
Registering a alproto with a parser function that always fails,
and just testing that AppLayerParserParse returned -1...
We would get the same result  without registering a parser function,
or using ALPROTO_FAILED as argument to AppLayerParserParse

The comment says "Test the deallocation of app layer parser memory
on occurrence of error in the parsing process."
but I do not see how this is tested.
9 months ago
Eric Leblond 9ffb2cd7dd misc: fix build of rules profiling
The patch a0fc2b8628 has removed the
declaration of functions used when building with ruleset profiling
only (without --enable-profiling). This is causing a build failure.

This patch moves the declaration to the rules profiling section to
be sure it is always there.
9 months ago
Nancy Enos a0fc2b8628 misc: Remove duplicate function declarations
Ticket: #7297
9 months ago
Victor Julien e44b2effd0 util/var-name: switch to SCTime_t 9 months ago
Victor Julien 0e21c71490 threads: track wall clock time precisely
Issue warning if thread sleeps for a long time.
9 months ago
Victor Julien 5bb2132bb8 time: add SCTIME_CMP_EQ 9 months ago
Victor Julien f0c4f9d64b util/hash-string: fix compile warning
Clang 19:

util-hash-string.c:41:16: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
   41 |     int len1 = strlen((char *)data1);
      |         ~~~~   ^~~~~~~~~~~~~~~~~~~~~
util-hash-string.c:42:16: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
   42 |     int len2 = strlen((char *)data2);
      |         ~~~~   ^~~~~~~~~~~~~~~~~~~~~
2 errors generated.
9 months ago
Victor Julien 270e19191b time: add gettimeofday wrapper for SCTime_t 9 months ago
Victor Julien bdc0df8454 time: remove unused function
It tripped up cppcheck:

src/util-time.h:124:35: error: syntax error [syntaxError]
    return !timercmp(first, second, >);
9 months ago
Victor Julien 3f85addaac stream: track pcap log segments timestamp with SCTime_t
This is a more compact time format.
9 months ago
Jason Ish a739d7623b eve/tls: don't construct const from other const
Some compiler/platform combinations don't like creating one const from
another as it can't guarantee the other is defined, resulting in the
following compile error:

output-json-tls.c:102:5: error: initializer element is not constant
     BASIC_FIELDS |
     ^~~~~~~~~~~~

Fixes commit 377989df6c
9 months ago
Adam Kiripolsky 175e690222 dpdk/hw_offload: add support for vlan stripping
Utilize DPDK API for hardware vlan stripping if supported by NIC.

Ticket: 7330
9 months ago
Nancy Enos e22c2a2332 applayer/htp: convert to new FAIL/PASS API
Ticket: #6935
9 months ago
Jason Ish d4a3ee163d misc: remove unneeded headers
Remove unneeded headers from worked on in previous commits, just
simple ones flagged by clangd.
9 months ago
Jason Ish ab6dcb3fc1 app-layer: use uint8_t consistent for event IDs
Introduce a common function for mapping names to IDs that performs
bounds checking.

Note: For event IDs in the enum that are larger than a uint8_t, -1
will be returned instead of -4. -4 has special meaning during
signature parsin that means requirements were not met. -4 has no
special handling prior to requirements, or the meaning has been lost.
9 months ago
Alice Akaki 5e563b0c8b detect/analyzer: add more details for flow_age
Ticket: #6312
9 months ago
Sascha Steinbiss 285cc29ec0 redis: add automatic trimming support for streams 9 months ago
Sascha Steinbiss d3d9f1c395 redis: implement XADD stream support
Ticket: #7082
9 months ago
Jason Ish 30806ce2b7 eve/tls: use BIT_U64 for flags
Minor cleanup.
9 months ago
Jason Ish 2462d9d4cf eve/tls: remove unused SC_ATOMIC_EXTERN 9 months ago
Jason Ish 714ada136c eve/tls: cleanup headers; update copyright year 9 months ago
Jason Ish 377989df6c eve/tls: reimplement basic and extended logging in terms of custom
Will prevent custom logging options getting out of sync with whats
available in extended.

Ticket: #7333
9 months ago
Jason Ish 2e788408c0 eve/tls: remove broken check for ja3 being enabled
During EVE TLS setup, a broken check for Ja3 being enabled led to Ja3
being disabled, but only in custom mode. This check is not needed, if
Ja3 is disabled, it won't be available, and won't be logged.

This is required to implement "extended" in terms of "custom" fields.
9 months ago
Jason Ish 6a185a8f96 eve/tls: add alpn logging to custom output
Adds custom fields "client_alpns" and "server_alpns".

Ticket: #7333
9 months ago
Jason Ish 3ddd9e2512 eve/tls: disable clang formatting around tls_fields array 9 months ago
Jeff Lucovsky 799822c3db profiling: Correct profiling data array size
The profiling arrays are incorrectly sized by the number of thread
modules. Since they contain app-layer protocol data, they should be
sized by ALPROTO_MAX.
9 months ago
Juliana Fajardini 69fe5121a1 tls: fix duplicate EVE field (issuerdn)
Wrong function call caused `issuerdn` to be logged when
`subjectaltname` was enabled, for custom logging, only.

Bug #7332
10 months ago
Shivani Bhardwaj 37fa2a6775 detect: rename port whitelisting to priority
This was done following the fact that this setting was historically
named incorrectly. The purpose of the setting was always to define the
ports that will be prioritized and have rule groups associated w them on
priority. Rename all occurences of this to correctly reflect the purpose
of the setting.
10 months ago
Shivani Bhardwaj abbdeed931 detect/engine: rename fn, add comments 10 months ago
Shivani Bhardwaj f8a5c91448 detect/proto: use BIT macros instead of expr 10 months ago
Shivani Bhardwaj 86c1e458f9 detect/engine: use combined flags for TCP 10 months ago
Alice Akaki fa1addae64 detect/analyzer: add more details for icmp_id
Ticket: #6360
10 months ago
Philippe Antoine 378f678d95 fuzz/detect: forbid rule with pcre only on stream
to avoid fuzzing blocks on timeouts with known bad rules

Ticket: 4858
10 months ago
Philippe Antoine 81f7ef89c4 stream: fix -Wshorten-64-to-32 warnings
Ticket: #6186
10 months ago
Philippe Antoine 58f7af8a31 output: fix -Wshorten-64-to-32 warnings
Ticket: #6186
10 months ago
Jason Ish 15c4eb3d16 threads: move wait for unpause outside of loop
Threads are only set to paused upon initialization and never again, we
should only have to wait once, so move the wait before any loop that
was waiting before.

Additionally, if the thread was killed while waiting to be unpaused,
don't enter the loop.
10 months ago
Jason Ish 7492fb6a91 threads: merge unpause test into wait for pause function
TmThreadTestThreadUnPaused was only being used by
TmThreadsWaitForUnpause and is still enough to just become one
function.
10 months ago
Jason Ish 3f8c3698db threads: helper function TmThreadsWaitForUnpause
The pattern of checking the pause flag, setting to paused then
waiting to unpause was done enough times to factor out into its own
function. This is also needed by library users who bring their own
packet acquisition threads.
10 months ago
Philippe Antoine 96c8470cdd template: move detect keywords to pure rust
Ticket: 3195

Also remove unused src/tests/detect-template-buffer.c

Completes commit 4a7567b3f0
to remove references to template-rust
10 months ago
Zemeteri Kamimizu 87e6e9374f conf: init parser after check with stat()
Commit changes are made to avoid possible memory leaks. If the parser
is initialized before configuration file checking, there was no deinit
call before function return. Do check config file existance and type
before YAML parser initialization, so we don't need to deinit parser
before exiting the function.

Bug: #7302
10 months ago
Jeff Lucovsky d32b28c85e napatech: bring back command line argument
Re-introduce support for command line argument "--napatech"

Issue: 7165
10 months ago
Jeff Lucovsky 330c408930 napatech: remove, to make room for plugin
Issue: 7166
10 months ago
Philippe Antoine 58556b7f8b template: remove -rust references
Ticket: 7315

Completes commit 4a7567b3f0

Allows keyword template.buffer to work properly when template
protocol is enabled
10 months ago
Jeff Lucovsky c9e4524b3c misc: Eliminate compiler warnings
Issue: 7314

Fixup macro usages to eliminate compiler warnings.
10 months ago
Philippe Antoine 76527dde79 http: fix condition check
Ticket: 7309

Do not use a constant expression in a condition
10 months ago
Alice Akaki d5dd549bcd detect/address: convert ipv4 unittests to FAIL/PASS
Ticket: OISF#6318
10 months ago
Philippe Antoine 40e97423b4 transform/base64: check for 0-sized buffer
So as to avoid undefined behavior with a 0-sized variable length
array

Ticket: #7296
10 months ago
Zemeteri Kamimizu adcac9ee0f detect: add new_de_ctx release in case of errors in initialization
Detect engine tenant reloading function hasn't got engine release call
under error label, so it is possible memory leak in case of errors in
further new detect engine initialization.

Bug: #7303
10 months ago
Jason Ish d8f73c9215 tm-modules: minor code cleanups
- includes
- loops
10 months ago
Jason Ish 415c5786de threading: remove TM_FLAG_LOGAPI_TM as its not used
This flag is never set, remove.
10 months ago
Shivani Bhardwaj 501f79c0ed detect/engine: deduplicate fn definitions 10 months ago
Alexey Simakov c72404e554 yaml: Add check of allocation for node object
Fix potential dereference of nullptr in case
of unsuccessful allocation of memory for
list node

Bug: #7270
10 months ago
Jason Ish 3b6f709331 threads: don't drop capabilities for packet threads
Remove the call to SCDropCaps for packet processing threads. This
logic in this function is required to setup packet processing even
when the thread is provided by a library user, in which case Suricata
should not be touching is capabilities.

As SCDropCaps is currently a no-op its clear this feature needs to
be (re)designed properly, taking into consideration library users as
well.

Related ticket: https://redmine.openinfosecfoundation.org/issues/2375
10 months ago
Ilya Bakhtin 976dec7f33 detect: pseudo-packets inherit inspect flags from parent packet
Instead of inheriting from flow, because encrypted protocols like TLS
and SSH may have just set the flow flags to indicate rest of stream is
encrypted and does not need to run stream inspection. But inspection
still needs to be run detection on this last flushing packet.

Ticket: #7235.
10 months ago
Philippe Antoine 26da953f6d util/hash: use randomized hash algorithm
For datasets and http ranges

Ticket: 7209

Prevents abusive hash collisions from known djb2 algorithm
10 months ago