Commit Graph

14767 Commits (3a6ecab0984745f0cefe3ca3c6dfee1eec7470d8)

Author SHA1 Message Date
Philippe Antoine 3d56472d16 detect: bindgen more functions
To prepare to move dcerpc.stub_data keyword to full rust
6 months ago
Philippe Antoine ef884b009a detect/dcerpc: move dcepayload unit tests to SV
Ticket: 8391
6 months ago
Philippe Antoine cfb1626212 detect/dcerpc: move dce-stub-data unit tests to SV
Ticket: 8391
6 months ago
Jeff Lucovsky 746f471382 transform/subslice: Add subslice transform
Issue: 7672

The subslice transform creates a slice of the input buffer.

Specify the subslice desired -- nbytes and truncate are optional:
        subslice: offset <,nbytes> <,truncate>

offset: Specifies the starting offset for the new subslice. When
negative, expresses how far from the end of the input buffer to begin.

nbytes: Specifies the size of the subslice. When negative, specifies
that the subslice will end that many bytes from the end of the input
buffer. Nbytes must be non-zero.

When nbytes is not specified, the size of the subslice will be the size
of the input buffer - offset.

truncate: Specify behavior when offset + nbytes exceeds buffer length.
When present, trims nbytes such that offset + nbytes equals buffer
length. When not present, an empty buffer is produced.

Examples:
        subslice: 1;     - The subslice will be a copy of the input
            buffer but omits the input buffer's first byte
            "This is Suricata" -> "his is Suricata"
        subslice: 0, 13; - The slice is created from the first 13 bytes
            of the input buffer
            "This is Suricata" -> "This is Suric"
        subslice: 10, -5; - The subslice is created starting at offset 10
            and continues to 5 bytes before the end of the input buffer
            "This is Suricata" -> "r"
        subslice: -3; - The subslice will be the last 3 bytes of the
            input buffer.
            "This is Suricata" -> "ata"
6 months ago
Philippe Antoine 7e326f291a detect: (m)dns keywords even with "alert udp"
Ticket: 8501

(m)dns.*.rrname keywords required the rules to start with
alert (m)dns
and refused to load if the rule started with generic alert ip or
alert udp, with error message
Error: detect-parse: invalid alproto 0
6 months ago
Philippe Antoine 4fc6ca5d6c detect/dcerpc: move iface keyword to rust
Ticket: 8391

Use same buffer dce_generic as for dcerpc.opnum
(name dce_generic is enforced by a SV test currently)
6 months ago
Jason Ish d1481af94e ssl: convert memcpy to strlcpy to avoid flto issue
When using ASAN, flto=auto and compiling on a platform that supports
AVX-512, this memcpy is optimized as its exactly 64 bytes. However, when
using ASAN, there is a fake stack that may not be 64 bytes aligned, and
this AVX write lands on an unaligned byte, causing a crash.

Use strlcpy avoids this optimization as it needs to find the NUL byte.
6 months ago
Philippe Antoine be2d80a8e7 ftp-data: check direction before finished state
Ticket: 6813

So, in the case we have a ftp-data flow with data to client as
expected, but after to_client side completes (with timeout for
example), the client sends some data to server,

In this case, we want to check first the direction, and bail out,
then do the assertion check about the finished state.
6 months ago
Philippe Antoine 40c8620184 detect/http2: fix progress for headers
Ticket: 8451

Do not wait to see a data frame to run detection on http2 headers
6 months ago
Philippe Antoine 898446aee8 detect/doh2: prefilter does not use dns engine progress
to update HTTP2 tx progress

Ticket: 8454
6 months ago
Philippe Antoine 67379b009a detect/dcerpc: move opnum keyword to rust
Ticket: 8391
6 months ago
Philippe Antoine a36af353bc rust: bindgen SCFlowGetAppProtocol 6 months ago
Lukas Sismis 214e47bea1 dpdk: move to native queue-sized mempools
As a legacy from Suricata 7, mempool size was kept even internally
as a global size. Since in Suricata 8, mempool allocation moved to
per queue model, it makes sense to calculate the correct size right
when loading the configuration.

The previous implementation misscalculated in some scenarios the size
of the mempool which prevented Suricata starting successfully.
This happened, e.g. when there were 32k RX descriptors and 64 TX descs.
The resulting mempool was incorrectly deduced as 32767 (2^n-1), which
didn't even hold all RX descriptors. Instead, it should result to 65535.

Ticket: 8370
7 months ago
Victor Julien 9c450d18e7 eve/drop: minor code cleanup 7 months ago
Victor Julien f9b25dc6ec eve/drop: always enable verdict in firewall mode 7 months ago
Victor Julien ff6fb068c7 detect/firewall: fix 'last_for_progress' logic
If the last signature in the candidates list is also the last for the
current progress value, it needs to be considered as the last for that
progress, so that if it doesn't match the default policy is applied.
7 months ago
Philippe Antoine 8f824458c2 detect: helper for buffer register requires progress
Ticket: 8395

For protocols where tx are complete at start, that is
the `tx_get_progress` function returns 1 inconditionnally,
we can use the progress 1, not losing time on detection in ips
mode, and getting ready for firewall mode

For the other protocols (where a tx needs both a request and response
for instance), keep progress 0 as was the case before
7 months ago
Jason Ish 6512be19aa output-eve: rust.h include is no longer needed
output-eve.h pulls it in.
7 months ago
Adam Kiripolsky 0a8e3132c2 bypass: fix BypassManager BypassedCheckFunc check
Switch check whether BypassedCheckFuncInit was registered to
check whether BypassedCheckFunc was registered.

Ticket: 8473
7 months ago
Jason Ish 6a67811a0c conf: make dirname pointer const
Fixes warning:

conf-yaml-loader.c: In function ‘ConfYamlSetConfDirname’:
conf-yaml-loader.c:87:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   87 |     ep = strrchr(filename, '\\');
      |        ^
7 months ago
Jason Ish 73bee2f4fd conf: avoid use-after-free when processing include sequences
Ticket: #8465
7 months ago
Jason Ish a11aaadd86 plugins: add --plugin command line option to load plugins
Add --plugin <PATH> to load an additional plugin from the command
line. This is more convenient than "--set plugins.X" especially when
you may already have a plugins loaded and you want to load an
additional one.

Ticket: 8463
7 months ago
Philippe Antoine 512bbe4de8 detect/template: merge template and template2
Ticket: 7278

Do a single packet match template merging best of both current
templates
7 months ago
Philippe Antoine 8d254f5630 dhcp/output: log app-layer metadata in alerts
Ticket: 6091

log as extended
7 months ago
Philippe Antoine db980daf5f dhcp: standardize output code
To prepare to add metadata in alerts

Ticket: 6091
7 months ago
Philippe Antoine d14af54b3b detect/transforms: constify some callbacks arguments
Ticket: 8298
7 months ago
Philippe Antoine cae749bc58 detect: remove unneeded null check
CID 1645613
Ticket: 7664

We assign and dereference next_s like
        next_s = *match_array++;
        next_sflags = next_s->flags;

So, there is no need to check if next_s is NULL, as it can never
be (otherwise, we could crash before)
7 months ago
Jason Ish 336b50ae9e storage: prefix core API with SC 7 months ago
Jason Ish 3722477319 device/storage: prefix API with SC 7 months ago
Jason Ish 41fd80aa46 ippair/storage: prefix API with SC 7 months ago
Jason Ish 279aa88956 host/storage: prefix API with SC 7 months ago
Jason Ish 67bd09ba2c thread/storage: prefix API with SC
In preparation for Rust bindings.
7 months ago
Jason Ish 137f59f542 flow/storage: prefix API with SC
In preparation for adding Rust bindings.
7 months ago
Philippe Antoine 4f4912c042 rust: bindgen SIGMATCH_ constants 7 months ago
Shivani Bhardwaj 4ec5f22951 ftp: trigger raw stream inspection
Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

FTP parser can handle multiple command lines per direction. Appropriate calls
to trigger raw stream inspection have been added on succesful parsing of each
request line and response line.

Bug 7742
7 months ago
Victor Julien facbb04915 detect: enable pcre and urilen for firewall mode
Ticket: #8397.
7 months ago
Victor Julien 6fbd7483d6 detect/parse: limit pkthdr proto to decoder event rules
`alert pkthdr` was initially just an alias for `alert ip`, as that was
really just a way of stating that "any" should be matched. However with
the Ethernet matching in place, it no long makes sense to treat `alert
ip` as "any". Since `pkthdr` is used to match on decoder events, also
for packets that completely failed to parse, it should no longer be
treated as `alert ip` but rather as it's own distinct logic.
7 months ago
Victor Julien b983ce64ef detect: add track pkthdr as any l2 protocol
To indicate it's not just like `alert ip`.
7 months ago
Victor Julien 61a7f47a69 detect: add ether.hdr keyword
Sticky buffer to inspect the ethernet header.

Example rule:

        alert ether any any -> any any ( \
                ether.hdr; content:"|08 06|"; offset:12; depth:2; \
                sid:1;)

Ticket: #8327.
7 months ago
Victor Julien 232276ac19 detect: ethernet/arp matching
Support `alert ether` for matching all ethernet packets.

Add `alert arp` for matching ARP packets.

Ticket: #8313.
7 months ago
Victor Julien d4f005933a detect/proto: reduce size for common sigs
Make `Signature::proto` an optional member, meaning that if it is
NULL we can skip the check. This can be done for `alert ip`, as no check
is needed, and for `alert tcp` and `alert udp` as having a rule in a sgh
for those means that the protocol matches.

Some exceptions are rules that require:
- ipv4/ipv6 specific matching
- frames, due to sharing prefilter between tcp and udp
- ip-only rules, due to those not being per sgh
7 months ago
Victor Julien dc814aa595 detect/frame: set frame flag during init
Allows for quickly checking if sig operates on frames during parsing.
7 months ago
Jason Ish cd9993c568 storage: remove the size registration parameter
With the Alloc callback gone, the size is no longer needed.
7 months ago
Jason Ish f337cd573b storage: remove alloc callback as its unused
Remove the "Alloc" callback from the storage API, it was only being
used in tests without any real usage.
7 months ago
Jason Ish 332f47d557 host/storage: use fail/pass api in unit tests 7 months ago
Jason Ish 31a4381d30 flow/storage: use fail/pass api in unit tests 7 months ago
Philippe Antoine 267c3baff7 rust/ffi: move STREAM_ constants to ffi crate
Ticket: 7666

reexport them in suricata crate
cbindgen them to C
7 months ago
Philippe Antoine efcc7f9dfc ftp: remove PASS pattern for protocol detection
As FTP must have USER before PASS command
unlike IRC which can begin by PASS command

Ticket: 2978
7 months ago
Jeff Lucovsky 1923ca1aa0 output/flush: Remove flush functions/registration
Remove log flush functions and update registration logic as
context-based flushing doesn't require it.

Issue: 8286
7 months ago
Jeff Lucovsky d0ba1c4c5e output/flush: Remove pkt-based flush logic
Remove packet-based flush logic in favor of simpler solution

Issue: 8286
7 months ago
Jeff Lucovsky a78911fce7 output/flush: Add EVE flushing logic
Add flushing logic driven off of the file contexts. This is a simpler
solution that removes the need for logger registration changes.

Overview:
Use the heartbeat-driven thread to periodically flush all registered EVE
contexts via a global flush list.

The global flush list is a mutex-protected TAILQ of LogFileFlushEntry
nodes; each node points to a LogFileCtx. Mutex = log_file_flush_mutex

Periodic flushing performed by a thread according to the
heartbeat.output-flush-interval [1,60]. LogFileFlushAll() is invoked to
initiate flushing of registered LogFileCtx structs; each struct's
fp_mutex is obtained while the flush occurs to synchronize with
LogFileWrite activity.

Interacts with file-rotation via the fp_mutex.

Deadlock prevention: the log_file_flush_mutex must be obtained before
the fp_mutex.

Issue: 8286
7 months ago
Philippe Antoine d4c036718a detect/geoip: do not require packet
Ticket: 8333

Allows to pass on pseudo packets

So, that a ruleset like
pass ssh any any -> any any (geoip:any,US,IN; sid: 1;)
drop ip any any -> any any (flow:established, to_server; sid:2;)

Does not lead to a drop on the pseudo-packet when we flush
because ssh traffic gets encrypted
7 months ago
Jeff Lucovsky 022a79fdd5 misc/cleanup: Simplify <cond> ? true : false
Simplify statements where there's a conditional statement followed by
return true or return false.

Instead of
    if (conditional)
        return true;
    else
        return false;

Use:
        return conditional
7 months ago
Jason Ish 468a13e052 log-cf-common: let mktime determine proper tz
In some timezones, LogCustomFormatTest01 was failing as we were
specifying the wrong setting for is_dst. Instead set it to -1 so mktime
can make the decision based on the environment. Appears to fix this test
for "Brazil/East" in the summer.

Add GitHub CI tests to test this specific test with a few different
timezones.
7 months ago
Victor Julien 45d94a7726 stream: restore pcap_cnt in debug output 8 months ago
Victor Julien ac1a514c7b stream/reassembly: improve progress tracking for GAP cases
When during raw reassembly it is detected that last ack is moved beyond
the progress and also beyond the data retrieved, update progress to the
last ack value.

Bug: #8272.
8 months ago
Philippe Antoine cb76301581 detect/tls: add null check for tls.alpn keyword
Ticket: 8294

Fixes: 6c1238b7bd ("tls: Integrate ALPNs into HandshakeParams object")

May happen if we analyze TLS without seeing the hello
8 months ago
Philippe Antoine 062f56ddde detect/http2: use ThreadCtx for all headers keywords
Instead of custom inefficient "escaped" Vec

Ticket: 8291
8 months ago
Philippe Antoine 4e538dfa3b detect/http2: use ThreadCtx for http.request_header
And also for http.response_header

Instead of custom inefficient "escaped" Vec

Ticket: 8291
8 months ago
Philippe Antoine 0933e944df detect/http2: use ThreadCtx for http.header.raw
Instead of custom inefficient "escaped" Vec

Ticket: 8291
8 months ago
Philippe Antoine 711de8a5ea detect/http2: use ThreadCtx for http.header
Instead of custom inefficient "escaped" Vec

Ticket: 8291
8 months ago
Philippe Antoine 52a2f2dd19 detect/http2: use ThreadCtx for http.header_names
Instead of custom inefficient "escaped" Vec

Ticket: 8291
8 months ago
Philippe Antoine 61b5461782 app-layer: fix uint overflow in debug assertion
Krb5 can request it needs a 0xFFFFFFFF record
8 months ago
Lukas Sismis 1d06103e08 dpdk: adjust burst size to mempool size
When mempool size was configured really low (<32), Suricata exhausted
the mempool with the rx_burst call, which led to undefined behavior.
The current fix ensures the burst size is at most the size of the mempool,
if the mempool is smaller than BURST_SIZE macro.
8 months ago
Victor Julien 565c1831a0 detect: convert unittest into fail/pass api 8 months ago
Victor Julien 25a8559cd4 pcap/file: add proto check for fuzzing
Based on review it seems p->proto should always be set to the same
value as what `PacketGetIPProto` returns. Add a check to validate
in a decoder that the fuzzer executes.
8 months ago
Victor Julien cb24430a0a firewall: don't overwrite with ips mode
When a capture method set IPS mode, it could overwrite already set Firewall mode.

Ticket #8311.
8 months ago
Philippe Antoine aae154874b src/detect: remove unneeded variables
just use the constant
8 months ago
Philippe Antoine 65993d4a41 util/lua: remove unneeded variable
just use the constant
8 months ago
Philippe Antoine 70bc077433 util: check name length of proposed data directory
Before doing stack allocation

Ticket: 8001
8 months ago
Philippe Antoine 27c28cc456 util: remove unneeded stack allocation in HexToRaw
Ticket: 8001
8 months ago
Philippe Antoine 2cb8ba5bec output: debug validation before stack allocation
A rule size has a global bound, which bounds the references
parsed in it.

Ticket: 8001
8 months ago
Lukas Sismis 6ec9e5c957 hs: address coverity warning in a reference string
Move the locking mechanism outside of the getter function and hold the
lock until the reference string is no longer reused.

** CID 1682023:       Concurrent data access violations  (MISSING_LOCK)
/src/util-mpm-hs-cache.c: 139           in HSGetReferenceDbInfo()
8 months ago
Jason Ish 8c7172e707 lib: remove the built-in library run-mode
This run-mode does not allow for capture ThreadVars to be created at
the appropriate place in the application life cycle. Instead,
applications should register their own custom run-mode.

Ticket: #8259
8 months ago
Victor Julien 56514f3be8 openbsd: pledge before allowing threads to continue
Avoids a race condition with pcap file directory mode.

Ticket: #8300.
8 months ago
Victor Julien 9cecd29fd4 detect/parse: convert test to fail/pass 8 months ago
Philippe Antoine 7e97dfd521 detect: replace stack alloc by member of DetectEngineThreadCtx
To avoid running a big (when many signatures) stack allocation
on each detection loop with postmatches

Ticket: 8001
8 months ago
Philippe Antoine b7a3a6b167 detect/pcre: add debug validations
Before stack allocation

Ticket: 8001
8 months ago
Philippe Antoine 4849d34325 detect/parse: debug validation before stack allocation
A rule size has a global bound

Ticket: 8001
8 months ago
Philippe Antoine db64462b1d detect/metadata: add debug validation
Before stack allocation

Ticket: 8001
8 months ago
Victor Julien a4aa056884 detect/parse: convert test to fail/pass 8 months ago
Jeff Lucovsky 809fb56612 output/log: IPv6 addr display per cfg
When configured, display the compressed form of the IPv6 address.

Issue: 7399
8 months ago
Jeff Lucovsky 4af77975e3 output/log: ipv6-compress member to file context
Issue: 7399

Add compress ipv6 setting to file context.
8 months ago
Jeff Lucovsky 20b8829867 output/eve: EVE output to use IPv6 compress cfg
Issue: 7399

Determine the EVE IPv6 address display and use that when generating
external display representation.
8 months ago
Jeff Lucovsky ed882ede68 output/ipv6: Utility function to compress IPv6 addrs
Issue: 7399

Utility function to compress IPv6 addresses per RFC-5952
8 months ago
Shivani Bhardwaj 0e345c93ca app-layer: check ipproto enabled setting first
If the key `app-layer.protocols.PROTO.enabled` is present, the protocol
is enabled for all carrier protocols. This is not ideal.
Only if the key `app-layer.protocols.PROTO.enabled` is missing, an
attempt is made to look for a setting specific to the ipproto passed
at the time of registration e.g.
`app-layer.protocols.PROTO.udp.enabled`.

By default, check for carrier proto specific setting. If it is not
found, then fall back to the generic setting.
Issue a warning in case an inconsistent combination of global and
ipproto specific setting is found.

Bug 8205
8 months ago
Victor Julien 791e7c1924 detect/tcp.flags: minor code cleanup 8 months ago
Victor Julien e916fc3ba4 detect: add igmp.type keyword 8 months ago
Victor Julien 6a1389acff detect: add igmp.hdr keyword 8 months ago
Victor Julien d652b7ef62 decoder/igmp: detect RGMP (RFC 3488)
RGMP is a dialect of IGMP that uses the same protocol structure,
but with some different values for the fields.

Detect this and log it differently.
8 months ago
Victor Julien 18f699cb97 detect/ipopts: add qs and rtralt options
Reordering of table and switch to match switch in parser.
8 months ago
Victor Julien 190ed2e8ed detect/csum: add igmp-csum keyword to match checksum
Add rule to decoder-events.rules to match on bad checksums.
8 months ago
Victor Julien c54bc8bc8b detect/proto: add igmp support
So 'alert igmp ...' can work.
8 months ago
Victor Julien 1b7cc2b323 decoder/igmp: initial decoder support for IGMP
Basic v1, v2 and v3 header validation.

Ticket: #8262.
8 months ago
Lukas Sismis ecd15a6c7e dpdk: scale mempool size to the number of bond members
DPDK interface which were added to bond and had auto-calculated
mempool size didn't have enough space as the configured
descriptors and the derived mempool only considered one interface
per YAML node entry.

DPDK Bonding PMD allows for multiple interface to cooperate and
therefore, needs more space.

Ticket: 8125
8 months ago
Lukas Sismis ea853e92a3 dpdk: fix mempool sizing to always yield 2^n -1
Following DPDK's recommendation to size mempool to 2^n - 1,
the current implementation was flawed for certain combos,
e.g. mp_size 1023 and 1 queue, which resulted to 1022.
8 months ago
Lukas Sismis 109742932a dpdk: honor cache size setting
Previously, the interface initialization always recalculated
cache size according to the per-queue computed mempool size.

Ticket: 8123
8 months ago
Lukas Sismis d640719413 hs: include HS platform info in cache file hash
Hash Hyperscan installation info (version, CPU features, mode)
into the cache filename. A Hyperscan upgrade or platform change
would now produce a different filename, so stale caches from an
older installation are never opened.

Ticket: 8325
8 months ago
Lukas Sismis 2e7b12dda4 hs: validate cached database against current HS installation
After deserializing a cached Hyperscan database, verify that its
version, CPU features, and mode match the current Hyperscan
installation by comparing hs_database_info output against a
reference database. Reject loading incompatible caches.

Ticket: 8325
8 months ago
Lukas Sismis 0cdc77b707 hs: use binary mode for cache file I/O
HSSaveCache wrote serialized Hyperscan databases using text mode ("w")
while HSReadStream already read them with binary mode ("rb").
Matched file reading modes to the binary format and simplified
write-size check.

Ticket: 8325
8 months ago
Lukas Sismis d754b28717 hs: remove redundant file handle in HSLoadCache
HSLoadCache opened the cache file but never used the resulting handle
for reading. The actual read was done by HSReadStream which opened
the same file independently.

Removed the unused fopen/fclose pair and flattened the control flow.

Ticket: 8325
8 months ago
Victor Julien 569ba3d26f hs/cache: cleaner and more detailed output
Reduce logging level of a minor informational message.

Split tracking of pruning by age and by version and log those
separately, where the logging only appears if something has been
removed.

Ticket: 8322
8 months ago
Victor Julien e69b732d1c af-xdp: address compile warnings
runmode-af-xdp.c:119:52: error: implicit conversion loses integer precision: 'const int' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
  119 |         aconf->threads = (nr_cores <= nr_queues) ? nr_cores : nr_queues;
      |                        ~                           ^~~~~~~~
runmode-af-xdp.c:119:63: error: implicit conversion loses integer precision: 'const int' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
  119 |         aconf->threads = (nr_cores <= nr_queues) ? nr_cores : nr_queues;
      |                        ~                                      ^~~~~~~~~
runmode-af-xdp.c:135:26: error: implicit conversion loses integer precision: 'const int' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
  135 |         aconf->threads = nr_queues;
      |                        ~ ^~~~~~~~~
runmode-af-xdp.c:268:41: error: implicit conversion loses integer precision: 'intmax_t' (aka 'long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  268 |                 aconf->busy_poll_time = conf_val_int;
      |                                       ~ ^~~~~~~~~~~~
runmode-af-xdp.c:275:43: error: implicit conversion loses integer precision: 'intmax_t' (aka 'long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  275 |                 aconf->busy_poll_budget = conf_val_int;
      |                                         ~ ^~~~~~~~~~~~
runmode-af-xdp.c:282:40: error: implicit conversion loses integer precision: 'intmax_t' (aka 'long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  282 |             aconf->gro_flush_timeout = conf_val_int;
      |                                      ~ ^~~~~~~~~~~~
runmode-af-xdp.c:287:43: error: implicit conversion loses integer precision: 'intmax_t' (aka 'long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  287 |             aconf->napi_defer_hard_irqs = conf_val_int;
      |                                         ~ ^~~~~~~~~~~~
7 errors generated.

source-af-xdp.c:426:24: error: implicit conversion loses integer precision: 'int' to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion]
  426 |     ptv->afxdp_state = state;
      |                      ~ ^~~~~
source-af-xdp.c:642:44: error: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to '__u16' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
  642 |     ptv->xsk.cfg.bind_flags = afxdpconfig->bind_flags;
      |                             ~ ~~~~~~~~~~~~~^~~~~~~~~~
2 errors generated.
8 months ago
Victor Julien edc19a15ad detect/parse: convert unittest to fail/pass API 8 months ago
Philippe Antoine d5ea973791 detect/ike: move ike.ike.chosen_sa_attribute keyword to rust
Ticket: 8310

And increases expressivity on the way by supporting other modes
than equality
8 months ago
Philippe Antoine 55333a6ca0 detect/ike: move ike.vendor keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine 14edd66494 detect/ike: move ike.nonce_payload keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine d1213e4440 detect/ike: move ike.key_exchange_payload keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine f23169c924 detect/ike: move ike.nonce_payload_length keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine e85bf5be4d detect/ike: move ike.key_exchange_payload_length keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine 841fe44f34 detect/ike: move ike.exchtype keyword to rust
Ticket: 8310
8 months ago
Philippe Antoine 23032ebc65 detect/ike: move ike spi keywords to rust
Ticket: 8310
8 months ago
Juliana Fajardini 723aa21e6f misc: update copyright years
For files edited during

Task #7885
8 months ago
Juliana Fajardini dc4d805908 exceptions: s/DEBUG/QA_SIMULATION build flag
Task #7885
8 months ago
Juliana Fajardini 5edb5a5d1a build-scopes: add QA_SIMULATION mode
For qa-simulation scenarios, especially for testing purposes.

Task #7885
8 months ago
Victor Julien e7c9be07e6 af-xdp: add missing unlock in error path
CID 1638288: (#1 of 1): Missing unlock (LOCK)
4. missing_unlock: Returning without unlocking xsk_protect.queue_protect.
8 months ago
Victor Julien b84ae80146 affinity: address coverity warning
CID 1667318: (#1 of 1): Structurally dead code (UNREACHABLE)
unreachable: This code cannot be reached: hwloc_obj_t non_io_ancestor....
8 months ago
Philippe Antoine b37b2b6bd6 decode: use compact uint8_t instead of enum in struct
to save memory

also move it to the first cacheline, as there is a 2 byte gap there
and this field should also not change after it has been set.
8 months ago
Philippe Antoine 9807fe4326 decode/xvlan: treat as its own tunnel
Ticket: 7717

Allows for instance to process/log ARP packets over VXLAN.

That means we need to decode the ethernet layer above vxlan
instead of skipping it as part of the vxlan, even if the vxlan
decoder still checks the ethernet layer to avoid FPs.
8 months ago
Philippe Antoine efb6daa1ae decode: use PacketIsTunnelChild
Instead of directly accessing the field

Will allow PacketTunnelType to hold the precise tunnel type like
DECODE_TUNNEL_ERSPANII with a modification of PacketIsTunnelChild
8 months ago
Philippe Antoine dc29ab46ed ebpf: check maps compatibility
ebpf program does not handle 3 layers of vlan
8 months ago
Philippe Antoine d378610e93 stream: non infinite default value for reassembly.depth
So that empty config have a safer default.

Ticket: 8290
8 months ago
Victor Julien db2e97ab5f detect/iprep: mark as supported for firewall mode
Ticket: #8285.
8 months ago
Ofer Dagan e1f9d8a067 pcap: refactor delete-when-done to support non-alerts
Refactor pcap file deletion to use a single delete-when-done option
with three values instead of separate boolean options:
- false (default): No deletion
- true: Always delete files
- "non-alerts": Delete only files with no alerts

Also account for alerts produced by pseudo packets (flow timeout / shutdown flush):
- Introduce small capture hooks and invoke on pseudo-packet creation so the
  capture layer can retain references and observe alerts emitted after the last
  live packet
- Call the hook from both TmThreadDisableReceiveThreads and TmThreadDrainPacketThreads

Key changes:
- Replace should_delete/delete_non_alerts_only bools with enum
- Move alert counter from global to per-file PcapFileFileVars
- Relocate alert counting from PacketAlertFinalize to pcap module
- Ensure thread safety for both single and continuous pcap modes
- Add unit tests for configuration parsing and pseudo-packet alert path

The --pcap-file-delete command line option overrides YAML config
and forces "always delete" mode for backward compatibility.

Documentation updated to reflect the new three-value configuration.

Fixes OISF#7786
8 months ago
Philippe Antoine 539e4ee665 detect/transforms: add zlib_deflate transform
Ticket: 7846
8 months ago
Philippe Antoine dbea660729 detect/transforms: add gunzip transform
Ticket: 7846
8 months ago
Philippe Antoine 751ef1fe9b detect: add debug validation about nlists
To avoid stack overflow

A single signature should not have more than 65k buffers

Ticket: 8001
8 months ago
Philippe Antoine f4d83f29a9 detect: allocate sids_array on the heap
To be able to load 1M signatures and not have a stack overflow

Ticket: 8001
8 months ago
Philippe Antoine 256c6a99b8 datasets: adds safety check before stack allocation
Even if current caller does not provide too big data.

Ticket: 8001
8 months ago
Jason Ish f6b11ac855 output-eve: finish exposing to bindgen
As all out output-eve.h is now exposed, merge output-eve.h and
output-eve-bindgen.h back into one file, output-eve.h.
9 months ago
Jason Ish f79158ae55 rust/sys: generate jsonbuilder bindings in sys
Bindgen the Rust bindings to the C JsonBuilder API along with the rest
of the Rust bindings to C. Breaking it out was probably the wrong
idea.

This should make it easier, and more correct to bindgen C functions
that use SCJsonBuilder types.
9 months ago
Jason Ish 2d0bf9a2ed output-eve: bindgen SCEveFileType callback types 9 months ago
Jason Ish e9611a4d7c output-eve: bindgen SCRegisterEveFileType to Rust
Used by Rust output plugins.
9 months ago
Jason Ish 1b182025bc output-eve: expose SCEveFileType to Rust with bindgen
There is an unfortunate side-affect that one has to read
output-eve-bindgen.h for the documentation on this type, however, I
think we can resolve that in time.
9 months ago
Jason Ish 7bfb63363e output-eve: cleanup usage of output-eve-bindgen.h
As output-eve-bindgen.h exists to support bindgen, its odd to see
other Suricata C files using it. Instead Suricata C code should import
"output-eve.h", which itself includes "output-eve-bindgen.h", only
broken out to support the external tool bindgen.
9 months ago
Jason Ish 8ea103031c output-eve: cleanup include guards to reflect filename 9 months ago
Philippe Antoine a079d1c68a src: remove unused enum values 9 months ago
Philippe Antoine 536242341b detect/smb: move smb.version keyword to rust
Ticket: 8267
9 months ago
Philippe Antoine df495d7e22 rust: bindgen SCDetectGetLastSMFromLists
to use it from rust keywords
9 months ago
Philippe Antoine 697c641400 detect/smb: move smb share and named_pipe keywords to rust
Ticket: 8267
9 months ago
Philippe Antoine 667f8b2eb7 detect/smb: move smb ntlmssp keywords to rust
Ticket: 8267
9 months ago
Philippe Antoine c48819e61f detect/sip: remove obsolete keyword ids
as they are now dynamically generated
9 months ago
Victor Julien e69c801a12 flow: reshuffle fields to avoid mutex in 2 cachelines 9 months ago
Victor Julien 6acef7fa16 flow: move members for more compact layout
Closes a hole.
9 months ago
Victor Julien a2e9ac21f8 flow: turn flags field into uint64_t
Entire space is used.
9 months ago
Victor Julien aff273bb89 flow: move livedev into Flow 'header'
It won't get updated after initial set.
9 months ago
Victor Julien 20afd63cbd flow: move flow_hash field to header
It won't get updated after initial set.
9 months ago
Victor Julien 9864ae23aa flow: improve Flow field docs 9 months ago
Lukas Sismis a50815a249 dpdk: refactor xstats printing with centralized cleanup
Replace duplicated SCFree() calls in error paths with a single
cleanup label using goto pattern. This reduces code duplication
and ensures consistent resource cleanup.

Additional improvements:
- Fix misleading error message when xstats table size changes
  between calls (was passing positive value to rte_strerror)
- Use unsigned int for length/index to match DPDK API semantics
- Initialize xstats_names to NULL at declaration for safe cleanup
- Added "not supported" case when the first call to xstats_get returns 0

Ticket: 8273
9 months ago
Juliana Fajardini bd76c29ed8 stream/tcp: flag 1st seen pkt w stream established
... to account for midstream sessions.

Commit 497394e removed inspection of app-proto txs for packets
without an established TCP connection. But this meant that the
first packet seen in a session pick mid-stream could go without
inspection (previous bug 5510 seemed to point towards this behavior,
too).
If a flow has more packets, the stream will be inspected as part of
the upcoming packets and this would go unnoticed. In a single-packet
flow, however, the inspection for the packed would be skipped. Although
this might not affect alerts -- as they could be processed as part of
the flow timeout logic, the actual traffic could be evaded in IPS, in
case of a drop rule.

From the above, the most visible scenario is when there is only one packet on the flow,
as then the engine doesn't have "more time" to pick-up real-packets to
inspect for that given flow. But certain tests show that this can also
happen for more than one packet scenarios: there will be one less drop
event, or traffic from a packet that should have been already dropped
will be logged.

This led to the possibility of a real packet not being blocked, in IPS,
or matched against rules, as the corresponding portion of the stream
was only inspected later, as part of the stream/flow-timeout logic.

To ensure that we correctly flag the first packet seen for a given mid-stream
session, we must check for the session state and existance *after* we
have dealt with TCP flags and state.

Related to
Bug #5510

As part of
Bug #5180
9 months ago
Juliana Fajardini 9cc678782c detect/build: add more rule types to init report
During initialization, the engine reports how many rules were loaded, as
well as which types. Pkt-only or stream-pkt rules would cause a "hole"
in such stats, as they're not counted.
9 months ago
Juliana Fajardini 1fee9b0102 detect: minor - typo fix 9 months ago
Philippe Antoine 364d2c077d rust: bindgen SCAppLayerRegisterParser
Ticket: 7662
9 months ago
Philippe Antoine 8401417a84 app-layer: remove some obsolete forward declarations
and reorder definitions
9 months ago
Philippe Antoine 8857b78f6a rust: move AppLayerTxData definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerTxData

Move also the free function to C SCAppLayerTxDataCleanup
As suricata-sys crate defines AppLayerTxData for rust,
It must itself implement the Drop trait, and thus,
We need to define a feature surest
9 months ago
Philippe Antoine 8eaced3c1e rust: move AppLayerResult definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerResult

Keep From<> impl in sys crate that defines it
9 months ago
Philippe Antoine 06f78b2a22 rust: move StreamSlice definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses StreamSlice
9 months ago
Philippe Antoine 41f543ca35 rust: move AppLayerGetTxIterTuple definition to C
and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerGetTxIterTuple
9 months ago
Philippe Antoine 64d29fcd1c rust: move AppLayerStateData definition to C
and bindgen it to rust, and use default trait instead of new

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerStateData
9 months ago
Philippe Antoine 76efb8af4d rust: move AppLayerGetFileState definition to C
and bindgen it to rust.

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerGetFileState
9 months ago
Mingyu Jeon 940f691245 parse/tls: fix date format parsing
refs #3065

* Fix to support the date format below
=> tls_cert_notafter:[<|>]YYYY
9 months ago
Philippe Antoine 9a52bbcbe9 detect/quic: move quic.cyu.hash to rust
Ticket: 8255
9 months ago
Philippe Antoine 01610aabe7 detect/quic: move quic.cyu.string to rust
Ticket: 8255
9 months ago
Philippe Antoine ee4d4a14d5 detect/quic: move quic.ua to rust
Ticket: 8255
9 months ago
Philippe Antoine 9ba9fdcb87 detect/quic: move quic.sni to rust
Ticket: 8255
9 months ago
Philippe Antoine 907e71a984 detect/quic: move quic.version to rust
Ticket: 8255
9 months ago
Jeff Lucovsky b872850f16 detect/byte_jump: Support bitmask value
Issue: 6693

Add bitmask support to byte_jump
- Parse
- Calculate shift count
- Apply to value before applying multiplier
- Order items in DetectBytejumpData to reduce holes.

Snort:
See https://github.com/chenkc/snort2.9/blob/master/snort-2.9.11.1/src/detection-plugins/sp_byte_jump.c#L780
9 months ago
Philippe Antoine 4b1b13960d detect/flowbits: align all pointers in the struct
Makes leak sanitizer work without adding LSAN_OPTIONS=use_unaligned=1

Otherwise, leak sanitizer may report the read and black tree pointers
as leaked when it is still owned by some global variable.

Follow-up on d046e82db6
9 months ago
Fupeng Zhao f7ec1c8813 redis: Add authentication support
Add authentication support to the Redis logging output.
It introduces `username` and `password` configuration options for Redis,
allowing Suricata to authenticate with Redis servers that require it.

Ticket: 7062
9 months ago
Philippe Antoine e982dd50d0 smtp: use configured FTP ports in probing parser
To allow users to configure more than port 21

Ticket: 6591
9 months ago
Philippe Antoine 4feacfb889 smtp: refine QUIT protocol detection
with probing parser, failing when it is on port 21 as FTP QUIT

Ticket: 6591
9 months ago
Philippe Antoine 7dbe033ae0 app-layer: function to register ci pattern + probe
Ticket: 6591
9 months ago
Philippe Antoine 81572cb457 detect: simplify code for http.header
reuse generic DetectEngineInspectBufferGeneric
9 months ago
Philippe Antoine cd0e4288c4 detect/http: remove unused function parameter
Will help to use generic DetectEngineInspectBufferGeneric
9 months ago
Philippe Antoine 2cf9a327d5 detect/ssh: move ssh.hassh to rust
Introduces helper SCDetectRegisterBufferLowerMd5Callbacks
9 months ago
Philippe Antoine 14c78d8405 detect: generic setup callback DetectLowerSetupCallback 9 months ago
Philippe Antoine 24e33944aa detect: SetupCallback uses DetectBufferType argument
Will allow for generic callbacks, that can be used from rust
9 months ago
Philippe Antoine 83360cfce0 detect/ssh: move ssh.hassh string to rust
bindgen needed SCSigMatchSilentErrorEnabled on the way
9 months ago
Lukas Sismis 27f398b5f2 dpdk: collect port stats before device stop
Some drivers (e.g. BNXT) fail to report stats after the device is
stopped. Move stats collection (DPDKDumpCounters and PrintDPDKPortXstats)
to run before rte_eth_dev_stop() in HandleShutdown.

Also change PrintDPDKPortXstats error handling from FatalError to
graceful return since stats collection failures during shutdown
should not crash the application.

The commit removes ThreadExitPrintStats callback as the function had no
useful features after the stats were moved.

Ticket: 8251
9 months ago
Lukas Sismis 0fe0390a2f hs: suppress TOCTOU stat use
To explain a bit more the TOCTOU issue found, we can consider
a case where Suricata starts to prune, yet externally somebody also
starts erasing cache files.
Right after Suricata checks the file age with the stat function,
somebody may delete or update the file of our interest.

Suricata aging decision doesn't reflect the actual state of the file.
This commit additionally adds a check for noent failure of the unlink operation
(considered as a success). The code can still delete a file that is recently
updated but was considered stale.

In the documentation-following deployments this should not happen anyway as
one cache folder should only be used by a single Suricata instance (and within
Suricata instance only one thread handles cache eviction).
Additionally, the `stat` and `unlink` command are immediatelly followed, making
this scenario extra unlikely.

Additional comment in the code explains problems of using fstat and potential
issues on Windows.

Ticket: 8243
9 months ago
Ofer Dagan 7627756360 detect/detection_filter: add unique_on option
Add optional unique_on {src_port|dst_port} to detection_filter for
exact distinct port counting within the seconds window.

Features:
- Runtime uses a single 64k-bit (8192 bytes) union bitmap per
  threshold entry with O(1) updates.
- Follows detection_filter semantics: alerting starts after the
  threshold (> count), not at it.
- On window expiry, the window is reset and the current packet's
  port is recorded as the first distinct of the new window.

Validation:
- unique_on requires a ported transport protocol; reject rules
  that are not tcp/udp/sctp or that use ip (protocol any).

Memory management:
- Bitmap memory is bounded by detect.thresholds.memcap.
- New counters: bitmap_memuse and bitmap_alloc_fail.

Tests:
- C unit tests for parsing, distinct counting, window reset, and
  allocation failure fallback.
- suricata-verify tests for distinct src/dst port counting.

Task #7928
9 months ago
Philippe Antoine d046e82db6 detect/flowbits: align pointer in the struct
Makes leak sanitizer work without adding LSAN_OPTIONS=use_unaligned=1

Otherwise, leak sanitizer may report rule_id as leaked
when it is still owned by some global variable
9 months ago
Jason Ish 5d61f5253d lua: don't attempt to garbage collect a null value
When not sandboxed, a script can get access to the metatable and call
`.__gc` with an invalid value like nil, causing a NULL pointer dereference
in Suricata.

Ticket: #8248
9 months ago
Shivani Bhardwaj 9df5fd180e flowbits: add a validation callback during setup
This should make it possible to catch invalid combinations in the same
signature early. This patch covers checking and erroring on the following
invalid cmd combinations:
- set + isset
- unset + isnotset
- set + toggle
- set + unset
- isset + isnotset
- unset + toggle

the same flowbit in the same signature which is basically an unnecessary
operation at runtime.

This also helps bring down the difficulty of handling of actual complex
flowbit chains.

Bug 7772
Bug 7773
Bug 7774
Bug 7817
Bug 7818
Bug 8166
9 months ago
Lukas Sismis b575ae3fd1 pcap-file: move packet counter to PCAP packet structure
Code refactor to gather all PCAP-related structure members
under one structure.

New pcap_v structure guards protect the union variables from
other capture modes trying to access the packet number incorrectly.

Ticket: 7835
9 months ago
Lukas Sismis 400328c3c3 pcap-file: prep codebase for pcap_cnt move refactor
For an easier review process, this is a two-step change process,
in which pcap_cnt is first accessed by functions-to-be, implemented
as simple macros.

In the follow-up commit, the actual refactor is implemented with the new
function. The old macros are deleted.

Ticket: 7835
9 months ago
Lukas Sismis f33f6e7ee5 stream: remove dead commented out code 9 months ago
Lukas Sismis c7058c1a35 stream: guard auxiliary packet counter to debug
Use of t_pcapcnt is only relevant when compiled in debug mode only.
This patch adds additional debug guard to also shield the declaration
and assignment.
9 months ago
Jeff Lucovsky 54bd8edf68 decode/ipv4: Create event on unknown protos
Issue: 7146

Create an event when the IPv4 header contains an unknown IP protocol.
9 months ago
Philippe Antoine c333b28719 http1: marks tx as updated when setting an event
Ticket: 8224

We sometimes set events to the last tx, so we do not have access
to the HtpTxUserData in the caller HTPHandleError
9 months ago
Philippe Antoine 54cc752cf9 ssh: hassh can be truly disabled
Rules will not re-enable it

Ticket: 8223
9 months ago
Philippe Antoine 458211dcf2 detect/ssh: move ssh.proto to rust 9 months ago
Philippe Antoine 9cfc1cc557 detect/ssh: move obsolete keywords to rust 9 months ago
Philippe Antoine ea8ac2a02a detect/ssh: move ssh.software to rust
Adds helper function SCDetectHelperBufferProgressMpmRegister on the way
9 months ago
Philippe Antoine 4b541b39f2 rust: move AppLayerEventType definition to C
and bindgen it to rust.

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerEventType
9 months ago
Philippe Antoine 4e64de3b3b rust: remove wrapper LoggerFlags struct definition
just use an u32 out of the box.
Will make bindgen like easier
9 months ago
Philippe Antoine 327f45ceb3 app-layer: ApplyTxConfigFn does not return bool
It does not return anything.
The only known implementation is in dns where it does not return.
And the C code does not bother to check a return value anyways.
9 months ago
Victor Julien cf7a56dd78 counters: compact public stats context 9 months ago
Victor Julien 711c1193d0 counters: misc cleanups 9 months ago
Victor Julien 6524a3fb5c stats: add derive support; add DERIVE_DIV type
Add basic derive counter support, where a counters value is derived from
2 other counters.

Add DERIVE_DIV that divides the first counter value by the second
counters value.

Convert `decoder.avg_pkt_size` to be derived from `decoder.bytes` and
`decoder.pkts`.

Ticket: #5615.
9 months ago
Abhijeet Singh b145e389ab util/log: fix log file rotation
Fix double log file rotation in presence of both rotation flag and rotate interval

Ticket: https://redmine.openinfosecfoundation.org/issues/8153
9 months ago
Victor Julien 5f92a6cac3 detect/base64_data: reset buffer offset
When in a `base64_decode`-`base64_data` pair the decode was depending
on another match through the relative option, the `buffer_offset` would
be updated to the relative position of the previous match. During the
`base64_data` phase, a relative match would use that offset even though
the match happened in a new buffer.

Example::

        http.request_body; content:"|27|";                              \
                base64_decode:relative;                                 \
                base64_data; content:"|ff ff ff ff|"; within:16;

This use of the `buffer_offset` is incorrect as that value is relative
to a buffer and the `base64_data` points to a new buffer.

This patch addresses this by resetting DetectEngineThreadCtx::buffer_offset
before inspecting `base64_data`.

Bug: #7842.
9 months ago
Philippe Antoine f8ad6904bc features: add UNIX_SOCKET feature
for SV tests to tun conditionnaly on it

Ticket: 3464
9 months ago
Juliana Fajardini 48b15ac152 devguide: add chapter about exception policies
Adds a chapter indicating what are the main steps when adding exception
policies, how is it possible to extend them, as well as main aspects and
files to consider when doing so.

Task #5612
9 months ago
Lukas Sismis 15c83be61a hs: prune stale MPM cache files
Hyperscan MPM can cache the compiled contexts to files.
This however grows as rulesets change and leads to bloating
the system. This addition prunes the stale cache files based
on their modified file timestamp.

Part of this work incorporates new model for MPM cache stats
to split it out from the cache save function and aggregate
cache-related stats in one place (newly added pruning).

Ticket: 7830
10 months ago
Lukas Sismis 08f5abe5e9 detect-engine: make mpm & spm part of MT stub ctx
As a intermediary step for Hyperscan (MPM) caching,
the MPM config initialization should be part of the default
detect engine context for later dynamic retrieval.

Ticket: 7830
10 months ago
Lukas Sismis 7031c26865 hs: touch cache files on use to signal activity
Ticket: 7830
10 months ago
Lukas Sismis fd3847db72 path: signal last use of the file (touch)
To have a system-level overview of when was the last time the file was
used, update the file modification timestamp to to the current time.

This is needed to remove stale cache files of the system.

Access time is not used as it may be, on the system level, disabled.

Ticket: 7830
10 months ago
Lukas Sismis 85f0382072 conf: add time parsing conf function 10 months ago
Lukas Sismis c282880174 hs: change hash in the cache name to SHA256 10 months ago
Lukas Sismis 2a313ff429 hs: reduce cache filename size to max file limit 10 months ago
Lukas Sismis 47fc78eeae hs: update the file description 10 months ago
Philippe Antoine 251d10fa42 util-spm-hs: add missing deallocator
Add missing deallocator when hs_alloc_scratch fails.

Bug: #8146
10 months ago
Sergey Zhidkih 799f01f78f util-spm-hs: add missing deallocator
Add missing deallocator for expr when hs_compile fails.

Bug: #8146
10 months ago
Sergey Zhidkih 11073a0190 hyperscan: move error logging for hs_compile
Move error logging from util-mpm-hs to reuse it in util-spm-hs as it
has proper hs_compile error handling.

Bug: #8146.
10 months ago
Victor Julien c20c7c1dfa detect/content: pretty print pattern directly 10 months ago
Philippe Antoine 374c191268 detect/port: fix use-after-free in case of alloc failure
If recursive call to DetectPortInsert (in case DetectPortCut returned
a c != NULL) failed, we had successfullt inserted `new` but
we return error, leading to freeing DetectPort `new` in
DetectPortParseInsertString but it
will be freed again by DetectPortCleanupList from DetectPortParse

Ticket: 6187
10 months ago
Philippe Antoine fcec08a178 detect/port: remove unused variable 10 months ago
Philippe Antoine 83acf3ca53 detect: remove unset flag PORT_FLAG_ANY 10 months ago
Victor Julien d1c16a0cc8 spm/bs: use memmem when available
Memmem is generally much more optimized.
10 months ago
Victor Julien ddfeef2897 spm: add mm, a memmem based spm
Wrapper around `memmem`.

The case sensitive search is implemented by directly calling `memmem`.

As there is no case insensitieve variant available, a wrapper around
memmem is created, that takes a sliding window approach:

1. take a slice of the haystack
2. convert it to lowercase
3. search it using memmem
4. move window forward
10 months ago
Victor Julien 2a2b98650b firewall: fix rules not loading w/o commandline opts
Firewall rules were supposed to also load when using a config like

        ##
        ## Suricata as a Firewall options (experimental)
        ##
        firewall:
          # toggle to enable firewall mode
          enabled: yes

          # Firewall rule file are in their own path and are not managed
          # by Suricata-Update.
          rule-path: /etc/suricata/firewall/

          # List of files with firewall rules. Order matters, files are loaded
          # in order and rules are applied in that order (per state, see docs)
          rule-files:
            - firewall.rules

But they were not because of a missing check.

Bug: #8206.
10 months ago
Philippe Antoine dd6baccabd src: doc: remove more double-space typos
Found with git grep -E '[a-z]  [a-z]'
10 months ago
Philippe Antoine feea984872 app-layer: test bypass set for udp
Ticket: 8116

quic parsing on udp can request bypass.
But such a bypass was only handled for TCP protocols in
AppLayerParserParse
10 months ago
Philippe Antoine 89b6ab6730 rust: rename EncryptionHandling
as it is no longer specific to SSH
10 months ago
Victor Julien 844f6011b1 datasets: fix compile warnings
datasets-string.c:53:20: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
        return len + 2;
        ~~~~~~ ~~~~^~~
1 error generated.
10 months ago
Jason Ish 2c95f1ff44 dnp3: bound the maximum number of objects per tx
Default to 2048, but provide a user configuration value.

Ticket: #8181
10 months ago
Jason Ish 3a32bb5743 dnp3: set a bound on the number of points per message
16384 is used as the max, but a configuration parameter has been
provided. The reason for setting an upper bound is that bit flags can
create a memory amplification as we parse them into individual data
structures.

Ticket: #8181
10 months ago
Jason Ish a16f087b93 dnp3: reduce flood threshold to 32 and make configurable
Lower the number of unreplied requests from 500 to 32 to consider a
flood. At the very least this is an anomaly given the DNP3 spec mentions
that DNP3 should only have one outstanding request at a time, with an
exception for unsolicited responses, so in practice no more than 2
should be seen.

Additionally make this value configurable by introducing the max-tx
parameter.

Ticket: #8181
10 months ago
Jason Ish d61eef9a8a dnp3: check done state, not complete state for progress
Complete is a flag used to tell if the message was completely parsed,
as not all messages may be completely parsed if we don't know all
their objects. However, they are still "done".

In the alstate-progress callback, check the done flag, not the
complete flag.

Ticket: #8181
10 months ago
Shivani Bhardwaj ac1eb39418 detect/alert: check alert queue capacity before expanding
So far, the alert queue was expanded by doubling in size w/o any
boundary checks in place. This led to situations where doubling
the alert_queue_capacity meant overflow of the very same value
stored in det_ctx.
This led to heap-use-after-free in some conditions where
det_ctx->alert_queue_capacity overflowed.

Fix this by capping the max of alert_queue_capacity by checking if its
expansion could result in an overflow.

Security 8190
10 months ago
Philippe Antoine ab2e128176 output: use tx iterator for finding alert http xff
Ticket: 8156

Allows better performance.
10 months ago
Philippe Antoine 3b1a6c1711 output: optimize loop for finding alert http xff
Ticket: 8156

In case of non-tx alerts, we try to loop over all the txs to find
the xff header. Do not start from tx_id 0, but from min_id
as AppLayerParserTransactionsCleanup to skip txs that were freed
10 months ago
Philippe Antoine d6bc718e30 datasets: allocates on the heap if string base64 is long
Ticket: 8110
10 months ago
Philippe Antoine 0eff242137 datasets: explicitly errors on too long string
Also avoids stack allocation

Ticket: 8110
10 months ago
Shivani Bhardwaj 1d7b0d9b7a tls/subjectaltname: use byte arr instead of string
TLS parsers use x509-parser crate which parses X.509 certificates that
use ASN.1 DER encoding that can allow arbitrary byte sequences. An
attacker could inject null byte in a certificate anywhere to stump the
common language parsers terminating the string at a null byte leading to
a bypass of a possibly malicious certificate.

So far, the rust TLS parser for "subjectaltname" used a pattern that involved:
-> Get ASN.1 DER encoded raw data from the x509-parser crate
-> Convert this raw data to a decoded string (Rust)
-> Convert the Rust string to CString
-- The problem lies here. CString only accepts proper strings/byte
buffers and converts it into an owned C-compatible, null-terminated
string. However, if any null byte occurs in the string passed to the
CString then it panics.
In the rust TLS parser, this panic is handled by returning NULL.

This means that the parser will error out during the decoding of the
certificate. However, Suricata must be able to detect the null byte
injection attack being an IDS/IPS.

Hence, replace all such string patterns w.r.t. TLS SAN with a byte
array.

Bug 7887
10 months ago
Shivani Bhardwaj 9c3ed7d31c tls/sni: use byte array instead of string
Bug 7887
10 months ago
Shivani Bhardwaj 24f5b7dab2 tls/serial: use byte array instead of string
Bug 7887
10 months ago
Shivani Bhardwaj f025e07191 tls/issuerdn: use byte array instead of string
TLS parsers use x509-parser crate which parses X.509 certificates that
use ASN.1 DER encoding that can allow arbitrary byte sequences. An
attacker could inject null byte in a certificate anywhere to stump the
common language parsers terminating the string at a null byte leading to
a bypass of a possibly malicious certificate.

So far, the rust TLS parser for "issuerdn" used a pattern that involved:
-> Get ASN.1 DER encoded raw data from the x509-parser crate
-> Convert this raw data to a decoded string (Rust)
-> Convert the Rust string to CString
-- The problem lies here. CString only accepts proper strings/byte
buffers and converts it into an owned C-compatible, null-terminated
string. However, if any null byte occurs in the string passed to the
CString then it panics.
In the rust TLS parser, this panic is handled by returning NULL.

This means that the parser will error out during the decoding of the
certificate. However, Suricata must be able to detect the null byte
injection attack being an IDS/IPS.

Hence, replace all such string patterns w.r.t. TLS IssuerDN with a byte
array.

Bug 7887
10 months ago
Shivani Bhardwaj 77c21b05d2 tls/subject: use byte array instead of string
TLS parsers use x509-parser crate which parses X.509 certificates that
use ASN.1 DER encoding that can allow arbitrary byte sequences. An
attacker could inject null byte in a certificate anywhere to stump the
common language parsers terminating the string at a null byte leading to
a bypass of a possibly malicious certificate.

So far, the rust TLS parser for "Subject" used a pattern that involved:
-> Get ASN.1 DER encoded raw data from the x509-parser crate
-> Convert this raw data to a decoded string (Rust)
-> Convert the Rust string to CString
-- The problem lies here. CString only accepts proper strings/byte
buffers and converts it into an owned C-compatible, null-terminated
string. However, if any null byte occurs in the string passed to the
CString then it panics.
In the rust TLS parser, this panic is handled by returning NULL.

This means that the parser will error out during the decoding of the
certificate. However, Suricata must be able to detect the null byte
injection attack being an IDS/IPS.

Hence, replace all such string patterns w.r.t. TLS Subject with a byte
array.

Bug 7887
10 months ago
Shivani Bhardwaj c312896be4 tls: remove deprecated tls-log
tls-log was deprecated in Suricata 8. Remove all associated files and fn
calls.

Task 7233
10 months ago
Victor Julien 4cdf0a0549 eve/tls: log client version if no server hello seen
Bug: #5713.
10 months ago
Victor Julien 9075d73e6d tls: delay handshake structure init 10 months ago
Victor Julien 4d9c0bdb19 tls: minor optimization
No need to 0/memset after SCCalloc.
10 months ago
Shivani Bhardwaj 926ef4c49a detect/xbits: parse keywords w strtok_r
Ticket: 4820

Forward ported by Victor Julien from
2c5eead479 ("detect/xbits: parse keywords w strtok_r")
10 months ago
Victor Julien 7ac5d7428e frames: add --list-app-layer-frames option
Lists frames per ip proto and app-layer proto.

Ticket: #8174.
10 months ago
Philippe Antoine df812b7a90 detect: do not exit on allocation failure during rule (re)load
Ticket: 6187
10 months ago
Lukas Sismis b596073a79 src: doc: remove double-space typos 10 months ago
Victor Julien 66e595fb10 detect/ssl_state: minor code cleanups 10 months ago
Victor Julien 5b790f607f detect/ssl_version: minor code cleanups 10 months ago
Victor Julien f17254ab8f detect/tls.version: minor code cleanups 10 months ago
Giuseppe Longo f1b9669ed5 flow: swap MACs when flow direction is swapped
When FlowSwap() reverses the direction of a flow, the MAC address sets
stored in the flow also need to be swapped to maintain consistency with
the new direction. Previously, MAC addresses were not swapped along with
other flow properties like packet/byte counters.

Ticket #8172
10 months ago
Giuseppe Longo 8050738fea util/macset: fix code style
Code style fixed using clang-format.

Ticket #8172
10 months ago
Victor Julien da87bd61d0 detect/luaxform: fix allowed lua rules check
Meant to be enabled by default, but wasn't.
10 months ago
Victor Julien d7866495c2 detect/lua: exclude script setup from the max-bytes limit
Make sure the script can use all bytes configured. So exclude setup like
input buffers that are put on the lua state before script is executed.

Bug #8173.
10 months ago
Victor Julien 1f58bc1a07 detect/luaxform: disable bytes limit during setup
During per inspection setup the buffer could already use up all the budget.

Bug #8173.
10 months ago
Victor Julien 7bc4b7d713 lua/sandbox: allow disabling the bytes limit
Meant for setting up from C, where we may use more bytes than expected.

Bug: #8173.
10 months ago
Shivani Bhardwaj 33a3448f45 detect/flow: add support for elephant flow detection
Expose elephant flow flags on a flow via rule language. The rule keyword
is defined as "flow.elephant: <dir>;" where the <dir> can expand to:
- toserver
- toclient
- either
- both

Feature 8117
10 months ago
Shivani Bhardwaj 0f92583702 flow: split elephant flow detection per dir
The tracking for elephant flow is done per direction however, the flag
was set on the flow whenever either of the directions crossed the
rate-limit defined in the settings. Given that the tracking was already
split, it makes sense to split the detection tracking per direction as
well and allow user to have a better control via rule language.
10 months ago
Shivani Bhardwaj 06eafb79d6 detect/flow-pkts: check for both dir
The functionality of "both" can already be easily achieved by using both
"toclient" and "toserver" in a rule. This just adds the ease of
expression in rule. As it is added now, check the direction for the
pre-existing users of direction as well.
10 months ago
Victor Julien cc2287beb4 tcp/tfo: set PKT_STREAM_EST flag
Detection and logging skip a lot of work if PKT_STREAM_EST is not set. When
a TFO packet with data comes in the TCP state is not yet established, but
the data still needs to be considered.

So for this case set the PKT_STREAM_EST flag.

Bug #6744.
10 months ago
Victor Julien 8247ec65b5 features: use strcmp instead of memcmp 10 months ago
Victor Julien 4a58c84862 string-hash: use strcmp instead of memcmp 10 months ago
Victor Julien c226626a7f counters: use strcmp instead of memcmp 10 months ago
Victor Julien 7a794945c6 proto: use strcmp instead of memcmp 10 months ago
Victor Julien 8f655c7d8d reference: use strcmp instead of memcmp 10 months ago
Victor Julien 3fbce40def classification: use strcmp instead of memcmp 10 months ago
Victor Julien 5a12096dd9 spm: minor unittest cleanup 10 months ago
Victor Julien a16c6ff6a5 memcpy: rename memcpy_tolower
Rename to match coding style. Update callers.

Minor loop cleanup.
10 months ago
Ali Saidi c4360cd515 util: add timing assembly for arm64 10 months ago
Jason Ish b3d45e5507 profiling: log rule profiling as json by default
We've been forcing JSON logging in our default configuration for some
time now, just make it the actual default.
10 months ago
Jason Ish d89b35db56 conf: add SCConfNodeChildValueIsFalse to check for false value
New function to check is a value is actually set to a false value.
10 months ago
Jeff Lucovsky 5c0f95faec gen: Fix typos 11 months ago
Jeff Lucovsky e80e881335 main/options: display level name, not numeric
Issue: 7389

Follow-up change for verbose handling. Instead of displaying the numeric
verbose level, display the level name.

I.e., instead of 4, display Debug
11 months ago
Shivani Bhardwaj a53ba4af94 detect: use PrefilterIsPrefilterableById where possible
cocci script used:

@@
identifier s, sm, DETECT_TYPE;
@@

- for (sm = s->init_data->smlists[DETECT_SM_LIST_MATCH] ; sm != NULL; sm = sm->next) {
-     switch (sm->type) {
-         case DETECT_TYPE:
-             return true;
-     }
- }
- return false;
+ return PrefilterIsPrefilterableById(s, DETECT_TYPE);

followed by some basic cmdline manipulations to get rid of extras left.
11 months ago
Philippe Antoine 726139a539 fuzz: really restrict path for nalloc
Ticket: 4125
11 months ago
Philippe Antoine e305c6c9df conf: do not exit on alloc failure
Ticket: 6188

Just return an error
11 months ago
Philippe Antoine 6882159692 fuzz: set engine stage for conf yaml target
Ticket: 6188

Allows allocations failures not to be fatal as in init
11 months ago
Philippe Antoine b7bd7f7d4c fuzz: allocation failures with nalloc
Ticket: 4125
11 months ago
Philippe Antoine b4d8aea0ae rust: bindgen SCAppLayerRegisterProtocolDetection
Ticket: 7662

Changing the struct passed to it to have the minimal number
of useful fields.
11 months ago
Ambre Iooss 3bcad5f364 windivert: upgrade to 2.0.0
WinDivert 2 was released in 2019. This introduced some minimal
changes to some functions arguments.

Bug: #8138.
11 months ago
Victor Julien 365ed2a2ff af-packet: disable hwtimestamp by default
Add enable-hwtimestamp option to replace disable-hwtimestamp.

Ticket: #7585.
11 months ago
James Kaddu 78d8fd7b9d output/file: validate force-hash YAML values
Previously, the force-hash configuration for file logging silently accepted
unknown or invalid hash types (e.g., 'shanani')
Now, invalid values trigger FatalError.

Bug OISF#4330
11 months ago
James Kaddu 354e9987e4 detect/analyzer: add details for the xbits keyword
Add xbits keyword details. Exposes cmd, name, track, and expire
properties, following the same pattern as byte_jump and flowbits.

Task #6351
11 months ago
Juliana Fajardini e3878042c9 stream/reassemble: use more legible FAIL macros
Use `FAIL_IF_NOT` instead of `FAIL_IF(!` or `FAIL_IF(.... !=`
11 months ago
James Kaddu 1b18081dfb stream/tcp/reassemble: convert unittests to FAIL/PASS API
Updated the stream TCP reassembly unit tests to use the new
FAIL/PASS API instead of the deprecated legacy assertion macros.

Task OISF#6324
11 months ago
Philippe Antoine c93e69830a detect/ssl: properly handle negation in ssl_version keyword
Ticket: 3220

DetectSslVersionMatch did not handle properly negation.
It could never match on a signatrue with ssl_version: !tls1.3
That is because, if we had such a signature and network traffic
with tls1.1, we were looking into DetectSslVersionData field
for tls1.1, which was not set, instead of looking at field
for tls1.3 which was set with negated flag.

Previous DetectSslVersionData was holding redundant information.
It did not need to have it for each ssl version, but just globally.
Also, it did not need to hold the version as a value in the array,
as it was redundant with the index of the array.
11 months ago
Jeff Lucovsky 3d80c7fb19 main/options: Limit verbose option count
Issue: 7389

Continue to recognize multiple 'v' specifications up to the maximum
recognized. The maximum recognized is the number of slots between the
NOTICE and DEBUG levels.

When debug is configured, `-vvvv` is required to set the log level to
debug. Specifying 4 or more `v` will maintain debug level.

When debug is not configured, `-vvvv` and more `v`'s will cause
config messages to be printed.
11 months ago
Philippe Antoine 09e50ac3f4 stream/tcp: check new last_ack stays within base_seq bounds
If we have
- stream->last_ack 0x40021
Then, we call StreamTcpUpdateLastAck with 0x8000fc21

Then we satisfy SEQ_GT((ack), (stream)->last_ack)
But we do not satisfy SEQ_GT(ack, (stream)->base_seq))

and the new last_ack will be compared to base_seq

So, refuse to make such a big update

Ticket: 6865
11 months ago
Philippe Antoine 1329786f84 detect: new command line option : list-rule-protos
To list the protocols we can use a in a rule header

Ticket: 635
11 months ago
Philippe Antoine 69c95f2b7c detect: rewrite DetectProtoParse
To use an array, instead of hard-coded values.
Opens the path to list the rule protocols

Ticket: 635
11 months ago
Victor Julien 18a6a079da af-packet: add disable-hwtimestamp option
HW timestamping is not always reliable, so add an option to disable it.

Bug: #1954.
11 months ago
Victor Julien 7c0776abeb counters: remove ThreadVars from counter registration
Just pass the StatsThreadContext pointer directly.
11 months ago
Victor Julien 419bbc79cc counters: remove unused thread name in counter registration 11 months ago
Victor Julien 5194c877f2 threads: remove thread group name logic
Once used to merge stats. Stats are tracked per thread and merge by counter
name in the current code.

It was set only for autofp modes.
11 months ago
Victor Julien 77ddbbb9c8 counters: regular counter get local API update 11 months ago
Victor Julien 9956f1f3c0 counters: regular counter Decr API update 11 months ago
Victor Julien 78da4cfcae counters: regular counter Incr API update 11 months ago
Victor Julien 045142a1f1 counters: regular counter Set API update 11 months ago
Victor Julien dfbfc81c51 counters: regular counter Add API update 11 months ago
Victor Julien adebfcd4a5 counters: remove ThreadVars from Avg counter API 11 months ago
Victor Julien 379b8ac5a6 counters: remove ThreadVars from Max counter API 11 months ago
Victor Julien ba3a86100b counters: debug code for inspecting counter registration 11 months ago
Victor Julien 72e4275456 app-layer: only register flow counter for detection-only
Other counters are never incremented if no parser is active.
11 months ago
Victor Julien c89d01679f counters: improve thread setup error handling 11 months ago
Victor Julien 33589e6079 unix-socket: don't doubly setup stats private area 11 months ago
Victor Julien 13d2fa6092 counters: minor code cleanup 11 months ago
Victor Julien c27d0b4192 counters: remove ThreadVars from sync API 11 months ago
Victor Julien 3f4af00fdd counters: remove ThreadVars from API 11 months ago
Victor Julien 4234567bb9 counters: unify public and private structs
This way ThreadVars can hold a single stats member.
11 months ago
Victor Julien 3a58c53b93 counters: improve error checking
Implement for unix manager.

Harden against incomplete setup.

More gracefully handle no-stats config
11 months ago
Victor Julien c4551e95bc counters: compress local stats table
To avoid overhead of copies during syncs, compress the local stats table.

Previously all counters had 2 64bit ints: one for the value, one to
track the number of times the counter was updated. The updates field was
only used for counters of type "average" however. Since only a few
average counters were in use, this effectively meant that almost half of
the space used for the table was wasted.

This patch reduces `StatsLocalCounter` to a single i64. Regular counters
simply use this directly by using their id as an index into the table.

For avg counters the logic is similar, however they effectively use 2
indexes, idx and idx+1. The value is at `idx`, the updates are at `idx +
1`.

Ticket: #5613.
11 months ago
Victor Julien 70096873ce counters: threadvar init func
Add initializion.

Also fixes DetectDsizeIcmpv6Test01 using two different ThreadVar
structs.
11 months ago
Victor Julien 6c77c8f371 counters: use spinlock for thread sync
Sync should be short, so no value in getting scheduled away.
11 months ago
Victor Julien 96cabab46b counters: optimize thread stats syncs
Minimize the work done under lock when synchronizing thread stats.

Instead of looping all stats to copy them from the threads private store
to the public store, this patch simply memcpy's the whole array.

When the stats thread then takes the stats from the threads public
store, it now also copies the whole array to a local store before
processing the stats one by one.

This keeps the locking time minimal.

Packet Thread(s)

[ private thread stats          ]

       | lock
       | memcpy
       V unlock

[ copy of thread stats          ]

Stats Thread

[ copy of thread stats          ]

       | lock
       | memcpy
       V unlock

[ private copy of thread stats  ]
11 months ago
Victor Julien 11f214bda8 counters: reduce scope of helper function
Not needed outside of the counters code.
11 months ago
Victor Julien 5f754b11a6 counters: move counter pointer out of thread private data
Ticket: #5613.
11 months ago
Victor Julien 3da562cd1b counters: remove unused elements from StatsThreadStore 11 months ago
Victor Julien 444166ec84 counters: move regular counter id to dedicated type 11 months ago
Victor Julien 0d8c81c062 counters: avoid unneeded 'updates' increment
No longer used now that the counter functions are only for regular counters.
11 months ago
Victor Julien fd9ce24fa3 counters: remove unused id var in local stats counter
Ticket: #5613.
11 months ago
Victor Julien 2e1705e54a counters: minor code cleanup 11 months ago
Victor Julien b474b40d74 counters: use a dedicated type for global counters
Type isn't used by any callers right now.
11 months ago
Victor Julien a8095d8ef5 counters: use a dedicated type for avg counters 11 months ago
Victor Julien e13b4ecbce counters: use a dedicated type for max counters
Also adds a dedicated 'Update' function to match the type.

Avoids unnecessarily incrementing the 'updates' variable.
11 months ago
Victor Julien 888b415257 counters: fix comment for set function
Handles u64, not a double.
11 months ago
Victor Julien 2eb2926cd2 decode: register decoder.erspan and decoder.nsh counters correctly
These are regular counters, not 'max' counters.
11 months ago
Philippe Antoine 15b1bf4865 rust: bindgen SCHTPFileCloseHandleRange
Ticket: 7762
11 months ago
Philippe Antoine cddbd0b906 rust: bindgen more file functions
Ticket: 7762
11 months ago
Philippe Antoine 62fcdf9bff detect: add debug validation check about flags consistency
If a flag is not a uint with a size, it should not have a specific
flag like multi_uint, nor enum nor bitflags
11 months ago
Philippe Antoine 8b9a779a16 file: fix hash computation for small multipart files
Ticket: 8119

Fixes: f68e2f5537 ("files: append data on closing even with
FILE_NOSTORE")
11 months ago
Jhonny Sousa 05a4aaf2c0 util/misc: Change shortening format and add unittests
Ticket: #5583
11 months ago
Jhonny Sousa 626027a456 util/pool: Convert unittests to new FAIL/PASS api
Ticket: #6322
12 months ago
Philippe Antoine 8ca589b5fb detect/tls: get rid of stack allocation
By making the pcre trim the trailing spaces

Ticket: 8001
12 months ago
Philippe Antoine ddb228e839 detect/msg: avoid temporary stack buffer
Just allocate the heap buffer asap and work on it.

Ticket: 8001
12 months ago
Philippe Antoine e3b79c4077 detect/content: avoid temporary stack buffer
Just allocate the heap buffer asap and work on it.

Ticket: 8001
12 months ago
Philippe Antoine 190ae4c6f9 detect/mpm: use fixed constant for stack allocation
instead of smaller run-time value.
Allows easier reading of the code for unbounded stack allocations

Ticket: 8001
12 months ago
Philippe Antoine 71c95fe670 output/frame: remove ifdefed out code
With bad pattern : stack allocation instead of using built-in
jsonbuilder hex printer

Ticket: 8001
12 months ago
Philippe Antoine ca16b4ebf7 detect/parse: debug validation about stack allocation
Ticket: 8001
12 months ago
Philippe Antoine 3337617a5e output: debug validation about stack allocations
Ticket: 8001

For flow variables names
12 months ago
Philippe Antoine 42d6c85757 util/debug: debug validation about stack allocation
Ticket: 8001
12 months ago
Philippe Antoine 6b7c78393c util/classification: check stack allocation size
Ticket: 8001
12 months ago
Philippe Antoine 753ab723b0 datasets: debug validation for stack allocation size
We iterate C substrings of a string whose max size is
SIG_JSON_CONTENT_KEY_LEN

Ticket: 8001
12 months ago
Philippe Antoine 9d164d8794 fuzz/conf: bail out on long sequence of scalars
Ticket: 8105
12 months ago
Olusegun Fajobi 785389aa00 detect/analyzer: add more details for flowint keyword
Ticket: 6311
12 months ago
Cheryl Owala 8120d9dc6c detect-pcre: convert unittests to FAIL/PASS API
Convert unittests to new FAIL/PASS API.

Ticket: #6344
12 months ago
Philippe Antoine cba13ed9b1 rust: bindgen functions needed for datasets
Ticket: 7762
12 months ago
Philippe Antoine 12892ba010 rust: bindgen functions neede for features
Ticket: 7762
12 months ago
Philippe Antoine b21c93d789 util/time: fix TimeDifferenceMicros microseconds computation
Ticket: 8073

Currently only used in pcap logging for flushing
12 months ago
Victor Julien 874a0e8d3d unix-socket/hostbits: fix ipv6 address parsing
In `add-hostbit`, `remove-hostbit` and `list-hostbit` commands, the IPv6
address parsing was not using the correct variable:

                 from /usr/include/dirent.h:25,
                 from suricata-common.h:73,
                 from runmode-unix-socket.c:18:
In function ‘inet_pton’,
    inlined from ‘UnixSocketHostbitAdd’ at runmode-unix-socket.c:1316:13:
/usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning]
   56 |   return __glibc_fortify (inet_pton, __sz, sizeof (char),
      |          ^~~~~~~~~~~~~~~
In function ‘inet_pton’,
    inlined from ‘UnixSocketHostbitRemove’ at runmode-unix-socket.c:1403:13:
/usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning]
   56 |   return __glibc_fortify (inet_pton, __sz, sizeof (char),
      |          ^~~~~~~~~~~~~~~
In function ‘inet_pton’,
    inlined from ‘UnixSocketHostbitList’ at runmode-unix-socket.c:1476:13:
/usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning]
   56 |   return __glibc_fortify (inet_pton, __sz, sizeof (char),
      |          ^~~~~~~~~~~~~~~

Bug: #8102.
12 months ago
Victor Julien 3a0f4dde07 thresholds: fix unittest compile warning
In file included from decode.h:33,
                 from host.h:27,
                 from util-threshold-config.c:34:
util-threshold-config.c: In function 'SCThresholdConfInitContext':
util-debug.h:260:5: warning: '%s' directive argument is null [-Wformat-overflow=]
  260 |     SCLogErr(SC_LOG_WARNING, __FILE__, __FUNCTION__, __LINE__, _sc_module, __VA_ARGS__)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-threshold-config.c:190:9: note: in expansion of macro 'SCLogWarning'
  190 |         SCLogWarning("Error loading threshold configuration from %s", filename);
      |         ^~~~~~~~~~~~
util-threshold-config.c:190:66: note: format string is defined here
  190 |         SCLogWarning("Error loading threshold configuration from %s", filename);
      |                                                                  ^~
12 months ago
Philippe Antoine deb5926609 fuzz: increase some config values
To get better coverage and bug findings

Ticket: 8068
12 months ago
Philippe Antoine a07390573f fuzz: default conf with verdict enabled in alerts 12 months ago
Philippe Antoine d94aea8331 detect: tcp.window is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine 68bb783e97 detect: tcp.seq is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine ed907bbd78 detect: tcp.ack is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine 7a8eb28cae detect: id is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine bff7413488 detect: icmp_seq is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine 79e66f76e6 detect: icmp_id is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine 09531447d1 detect: fragoffset is now a generic integer
Ticket: 7889
12 months ago
Philippe Antoine 85fa894425 detect: dnp3.func is now a generic integer
Ticket: 7889
12 months ago
Victor Julien d45bdb85d5 eve/verdict: more explicit pass handling
Instead of indexing `Packet::alerts` to find out if the action should
be `ACTION_PASS`, add an arguement to make this explicit from the alert
logging logic.

Bug: #7630.
12 months ago
Victor Julien 5b19508661 detect/alert: fully add pass-only rules to alert queue
Pass-only rules were previously stored in Packet::alerts, but not
correctly. The `cnt` wasn't incremented leaving it in a weird state.

This patch changes the logic to have a `pass` entry be added to the
queue as well as incrementing the `cnt`. As a consequence of this the
alert logging needs to explicitly check for `PacketAlert::action` having
`ACTION_ALERT` set now.

Update the alert loggers.

Bug: #8021.
12 months ago
Victor Julien 2a7eb5d062 detect/threshold: set missing alert flag in rate_filter
ACTION_ALERT is supposed to be set now, but wasn't for rate_filter.
This becomes important in a follow up patch where only PacketAlert
entries with `action` `ACTION_ALERT` are logged in alert logging.
12 months ago
Victor Julien bccdb445ff eve/verdict: clean up packet action checking
Get action from packet just once.
12 months ago
Philippe Antoine b8411fcc8d output/http: log content-type like other headers
Ticket: 8056

Avoid stack allocation.
Do not handle null and ; especially
12 months ago
Philippe Antoine acc051ac94 unix-socket: return after closing on too long
Avoids later use after free

Ticket: 8063
12 months ago
Philippe Antoine a84addb771 util/swf: move allocation from stack to heap
As it can overflow the stack

Ticket: 8055
12 months ago
Philippe Antoine eb5a2d646b detect/vlan: move vlan.id keyword to generic integer
Ticket: 7929
12 months ago
Li Heng c141c55bc6 snmp: can be set to detection-only
Realloc alp_ctx.ctxs when a dynamic alproto is registered and
g_alproto_max increases. So dynamic alproto can be treated as
real/normal ones. And app-layer switch can be set to any value
of no/deteciton-only/yes.

Ticket: 8000
12 months ago
Philippe Antoine 439f96dea7 rust: bindgen frames functions
Ticket: 7667
12 months ago
Philippe Antoine 92c7be1cb6 rust: bindgen SCSRepCatGetByShortname
Ticket: 7667
12 months ago
Ezra Adeyinka 368ef839de detect/address: switch tests to FAIL/PASS API
Ticket: #4023
12 months ago
Shivani Bhardwaj bb1ed16408 src: check retval of VarNameStoreRegister
VarNameStoreRegister can return 0 in case of any error conditions.
Handle this case in all the users of this function. It is an unlikely
event so add branch assistance accordingly.

Bug 8054
12 months ago
Shivani Bhardwaj 6b3c21a4e6 detect/xbits: use correct Free fn
Most call sites use a casula SCFree fn to get rid of the DetectXbitsData
in case of an error. However, if a varname is also registered, that must
be unregistered too. Fix all the free calls by replacing them with the
appropriate DetectXbitFree fn.
12 months ago
Shivani Bhardwaj 13c8724ae0 detect/xbits: remove unneeded cast to check ptr validity 12 months ago
Shivani Bhardwaj dad883406d detect/xbits: use calloc to avoid undefined behavior 12 months ago
Shivani Bhardwaj a23add0194 detect/lua: remove extra NULL check
The fn DetectLuaFree checks if the pointer (DetectLuaData) passed to it
is valid. So, the checks for NULL in the call sites can safely be
removed.
12 months ago
Shivani Bhardwaj 71339c459e detect/flowvar: remove extra NULL check
The fn DetectFlowvarDataFree checks if the pointer (DetectFlowvarData)
passed to it is valid. So, the checks for NULL in the call sites can
safely be removed.
12 months ago
Shivani Bhardwaj 7c9fad27fc detect/flowint: clean up free fn 12 months ago
Shivani Bhardwaj bc8bf865ae detect/flowint: remove extra NULL check
The fn DetectFlowintFree checks if the pointer (DetectFlowintData)
passed to it is valid. So, the checks for NULL in the call sites can
safely be removed.
12 months ago
Shivani Bhardwaj 59944c7787 detect/flowint: use calloc to avoid undefined behavior 12 months ago
Shivani Bhardwaj e5994deb23 util/varname: check id before unregister
In case of an error a varname id is set to 0. Ideally, it shouldn't be
found in the hash table lookup but add a check anyway to avoid obtaining
the mutex lock and performing the lookup.
12 months ago
Victor Julien ec65fd430e exception-policy: rename 'reject-both' to 'rejectboth'
To align it with the rule action.
12 months ago
Jason Ish 9fffc09ad7 doc/devguide: document eve file types
Ticket: #4708
1 year ago
Philippe Antoine 7447651fa0 output/jsonbuilder: helper function SCJbSetPrintAsciiString
To replace C PrintStringsToBuffer and avoid a stack alloc
+ copy

Ticket: 8004
1 year ago
Victor Julien 52fd61dffd lua: remove luajit pushlstring workaround
81ee6f5aad ("lua: push correct length back through ScFlowvarGet, work around valgrind warning")
added a workaround for valgrind warnings in pushing a string buffer
into the lua state. This is no longer needed as tested with both
address sanitizer and valgrind.
1 year ago
Victor Julien acb769291a exception-policy: add 'reject-both' option
Allow rejecting both sides of a connection. Has the same support
as regular reject (which is essentially rejectsrc).

Ticket: #5974.
1 year ago
Juliana Fajardini 6b75b937ff output/eve: fix typos
To accompany documentation work done in

Task #4708
1 year ago
Jhonny Sousa 051bc324d6 detect/base64_data: Convert unittests to FAIL/PASS API
Ticket: #6320
1 year ago
Philippe Antoine 854201703e util/var: add NULL check in VarNameStoreRegister
And check return value in entropy keyword setup
1 year ago
Philippe Antoine 6d703af505 detect: fix null deref with entropy keyword
Ticket: 7959

Usage of entropy with base64_data led to NULL dereference
1 year ago
Jason Ish 65e7e93f88 detect/http2: call correct free function on errors
Fix cases where the wrong free function was being called in error
handlers.

DetectHTTP2sizeUpdateSetup was calling DetectHTTP2settingsFree instead
of DetectHTTP2sizeUpdateFree in error case.

Moving http2.priority and http2.window to multi-integers, instead
of basic integers only modified the Free callback, but the
Setup function was still using the direct call to old obsolete free
function.
Using the callback Free abstration in Setup, allows to be
consistent and have less code to change.
1 year ago
Amir Boussejra 56c8db6cb6 flow-timeout: Use yaml config value for CAPTURE_BYPASSED flow
Instead of non configurable constant FLOW_BYPASSED_TIMEOUT

Ticket: #8014
1 year ago
Philippe Antoine 2e9027fd5a plugins: update SC_API_VERSION to 9
So that plugins built for 8 will fail to load with 9 as there
were already breaking changes in the structures and functions
prototypes
1 year ago
Jhonny Sousa 9935af67d6 detect/filestore: Convert unittest to new FAIL/PASS API
Ticket: #6317
1 year ago
Jeff Lucovsky 7e0d6f4a1e detect/ip.src: Allow use with transforms
This commit registers ip.src/ip.dst properly so they can be used with
transforms.

Issue: 8015
1 year ago
Olusegun Fajobi 7455a2c6d7 detect/analyzer: added more details for the ttl keyword
Ticket: #6310
1 year ago
Olusegun Fajobi a16e87beeb detect-urilen: convert unittests to FAIL/PASS APIs
Ticket: #6325
1 year ago
Jhonny Sousa bdf292b816 rule/vars: convert unittests to new FAIL/PASS API
Ticket: #6333
1 year ago
Olusegun Fajobi 52715a00a0 threads: convert unittests for FAIL/PASS APIs
Ticket: #6327
1 year ago
Victor Julien 232f0572e0 detect: address intermittent UT crash on OpenBSD
Add missing flow memset in test SCSigOrderingTest12 to avoid the crash.

Test SCSigOrderingTest12                                          : Info: unittest-helper: Sid 1 matched 1 times, as expected [UTHCheckPacketMatchResults:util-unittest-helper.c:638]
Info: unittest-helper: Sid 2 matched 1 times, as expected [UTHCheckPacketMatchResults:util-unittest-helper.c:638]
bash: line 144: 88567 Segmentation fault      (core dumped) ./src/suricata -u -l /tmp/

Bug: #8008.
1 year ago
Olusegun Fajobi 66d4595349 ippair-storage: convert unittests to FAIL/PASS APIs
Ticket: #6315
1 year ago
Jeff Lucovsky 9a7a30f18e detect/dbv: Assert MT lock held
Add a DBV assert to validate that the master->lock is held.

Suppress missing master->lock warning

Issue: 7819
1 year ago
Jeff Lucovsky 46a53aee73 engine/mt: Ensure master lock held for reload
Issue: 7819

DetectEngineReload must hold the `master->lock`; recent changes changed
the locking usages to avoid deadlock when registering/handling tenants.
These changes added the presumption that the master lock is held at a
higher level. Coverity highlighted that the lock is not held
consistently.
1 year ago
Philippe Antoine dc7874b2ac rust: bindgen more http range functions used in http2
Ticket: 7667
1 year ago
Philippe Antoine 842352c190 rust: bindgen SCHttpRangeFreeBlock
Ticket: 7667
1 year ago
Philippe Antoine 93785ae357 rust: bindgen SCHTTP2MimicHttp1Request
Ticket: 7667
1 year ago
Philippe Antoine 31e9cb55be detect: tcp.flags unit tests improvements
Tests better the ignored flags functionality.
This functionality is only used at detection for default mode,
it is not used for any, plus or not mode.

So, have unit tests about igored flags with default mode with
both matching and non matching cases
1 year ago
Philippe Antoine d8cb00e795 detect/tcp: make tcp.flags a generic integer with bitflags
Ticket: 6724

Allows to use numerical values for example

Also fixes some unit tests that were returning 1 after goto error
FlagsTestParse05 especially took this path as
de->ignored_flags != (TH_SYN|TH_RST) was false
we had de->ignored_flags == 0xff ^ (TH_SYN|TH_RST)
And then, we had a match, instead of what the not-run code
was supposing.
1 year ago
Philippe Antoine 1f9236a6d8 detect/ipv4: make fragbits a generic uint16 bitflags keyword
Ticket: 6724

Allows to use numerical values
1 year ago
Olusegun Fajobi 2db1b93332 ippair-bit: Convert unittests to FAIL/PASS APIs
Ticket: #6323
1 year ago
Shivani Bhardwaj b090fc61fd applayer/tls: do not free SAN for decoding error
SSL connp maintains all the state and certificate data that was
parsed/decoded successfully and it must retain that for later usage.
There should be just one place to free this object which is SSLStateFree
for both the directions. By freeing the connp data during parsing error,
there is room for memory errors.
This works so far because the field parsed after this cannot error out so
if there's an error parsing this, it anyway does not exist. However, this
is incorrect and leaves scope for mistakes.

Remove this extra free and treat SAN like all other TLS keywords.

Bug 7996
1 year ago
Victor Julien 2f633be1a9 pcap-log: fix bpf-filter not set for multi mode
Bug: #8002.
1 year ago
Victor Julien 93c0409292 unittests: move http.cookie tests to FAIL/PASS API 1 year ago
Victor Julien 4af5520496 unittests: move http.stat_code tests to FAIL/PASS API 1 year ago
Victor Julien 8fe931e5ff unittests: convert http_raw_header tests to FAIL/PASS api 1 year ago
Victor Julien eb104389b1 unittests: move http.stat_msg tests to FAIL/PASS API 1 year ago
Victor Julien 5e14e4e58c unittests: move http.server_body tests to FAIL/PASS API 1 year ago
Victor Julien e1d3993659 unittests: clean up memory for host storage tests 1 year ago
Victor Julien 4c126a9d6c unittests: clean up memory for ippair storage tests 1 year ago
Victor Julien b7650a45fa output: fix long logline test
Fixes: 023a2fe9ab ("unittests: fix format-truncation warning")
1 year ago
Victor Julien f176d2ae63 unittests: clean up memory for icmpv4 tests 1 year ago
Victor Julien 0616aa9532 unittests: clean up memory for nsh tests 1 year ago
Victor Julien 89dea0dce5 unittests: clean up memory for ethernet tests 1 year ago
Victor Julien 4e85bcbb5f unittests: clean up memory for ipv6 tests 1 year ago
Victor Julien 6b5323cf81 unittests: clean up memory for ipv4 tests 1 year ago
Victor Julien cf23586027 unittests: clean up memory for vlan tests 1 year ago
Victor Julien 4d81f74b89 unittests: clean up memory for esp tests 1 year ago
Victor Julien 9e3627e14d unittests: clean up memory for raw tests
Convert to FAIL/PASS api
1 year ago
Victor Julien 385ae2d348 unittests: clean up memory for chdlc tests 1 year ago
Victor Julien 12f54164c6 unittests: clean up memory for pppoe tests 1 year ago
Victor Julien b1f4e06719 unittests: clean up memory for gre tests 1 year ago
Victor Julien fda72e6f83 unittests: clean up memory for ppp tests 1 year ago
Victor Julien 4ef810105a unittests: clean up memory for dnp3 tests 1 year ago
Victor Julien 13c3d2e09c unittests: clean up memory for defrag tests 1 year ago
Victor Julien 854cd9834f unittests: clean up memory for detect stream_size tests
Convert tests to FAIL/PASS api
1 year ago
Victor Julien 8fe513d433 unittests: clean up memory for detect dce payload tests 1 year ago
Victor Julien 1cadbe62bf unittests: clean up memory for detect sameip tests 1 year ago
Victor Julien 37012bf722 unittests: clean up memory for detect reference tests 1 year ago
Victor Julien efc19868c6 unittests: clean up memory for detect rpc tests 1 year ago
Victor Julien 12546621b9 unittests: clean up memory for detect replace tests 1 year ago
Victor Julien d08a666b95 unittests: clean up memory for detect quic tests 1 year ago
Victor Julien 2b610deb4a unittests: clean up memory for detect pcre tests 1 year ago
Victor Julien 51b4eccc60 unittests: clean up memory for detect msg tests 1 year ago
Victor Julien b74ebeb9d6 unittests: clean up memory for detect l3_proto tests 1 year ago
Victor Julien 621649299e unittests: clean up memory for detect iprep tests 1 year ago
Victor Julien ffe9f17f32 unittests: clean up memory for detect ipproto tests 1 year ago
Victor Julien 739e93ab9c unittests: clean up memory for detect icode tests 1 year ago
Victor Julien dbdcbd18eb unittests: clean up memory for detect itype tests 1 year ago
Victor Julien 91b7374128 unittests: clean up memory for detect fast_pattern tests 1 year ago
Victor Julien b66592a8b2 unittests: clean up memory for detect flowint tests 1 year ago
Victor Julien 525847c959 unittests: clean up memory for detect fragoffset tests 1 year ago
Victor Julien 640f9b30f7 unittests: clean up memory for detect flow tests 1 year ago
Victor Julien 2e35a99fc7 unittests: clean up memory for csum tests 1 year ago
Victor Julien f00951b875 unittests: clean up memory for base64_decode tests 1 year ago
Victor Julien 63fcbae810 unittests: clean up memory for bytemath tests 1 year ago
Victor Julien e1ff9b1dcc unittests: clean up memory for address tests 1 year ago
Victor Julien ecdec157a1 unittests: clean up memory for tcp.ack tests 1 year ago
Victor Julien d69f5f1b68 unittests: clean up memory for dsize tests 1 year ago
Victor Julien 1a926f5953 unittests: clean up memory for detection filter tests 1 year ago
Victor Julien 5b89c5e0cd unittests: clean up memory for dcerpc tests 1 year ago
Victor Julien dbae5e53a1 unittests: clean up memory for tls tests 1 year ago
Victor Julien 342e54c30e unittests: clean up memory for tag tests 1 year ago
Victor Julien 0e5eae858e unittests: clean up memory for ttl tests 1 year ago
Victor Julien 986d316cc0 unittests: clean up memory for threshold tests 1 year ago
Victor Julien 01c033087a unittests: clean up memory for content inspection tests 1 year ago
Victor Julien 50c5daf769 unittests: clean up memory for content tests 1 year ago
Victor Julien f64989cfd0 unittests: clean up memory for http urilen tests 1 year ago
Victor Julien 346cfe25a1 unittests: clean up memory for http header tests 1 year ago
Victor Julien c4775596bf unittests: clean up memory for http host tests 1 year ago
Victor Julien 14b1928c93 unittests: clean up memory for http method tests
Convert to runtest logic as used in other http tests.
1 year ago
Victor Julien 183f89f991 unittests: clean up memory for http ua tests 1 year ago
Victor Julien ad74c3f115 unittests: clean up memory for http raw header tests 1 year ago
Victor Julien 3ce98143b8 unittests: clean up memory for http detect tests 1 year ago
Victor Julien 09289edf04 unittests: clean up memory for hostbit tests 1 year ago
Victor Julien 43347e3d3d unittests: clean up memory for htp body test 1 year ago
Victor Julien 52aa922735 unittests: clean up memory for detect engine event tests 1 year ago
Victor Julien 21a11b915f unittests: clean up memory for icmpv6 tests 1 year ago
Victor Julien 8a7feff8f2 unittests: clean up memory for ippair bit tests 1 year ago
Victor Julien 650fa191b6 unittests: clean up memory for ipopts tests 1 year ago
Victor Julien 0d2778ed8e unittests: clean up memory for ip-only tests 1 year ago
Victor Julien 2076c11251 unittests: clean up memory for app-layer tests 1 year ago
Victor Julien bcd6481d80 unittests: clean up memory for app-layer proto tests 1 year ago
Victor Julien b85cd8030f unittests: clean up memory for fast.log tests 1 year ago
Victor Julien 4fb6dec8a2 unittests: clean up memory for xbits tests 1 year ago
Victor Julien cdad674702 unittests: clean up memory for action order tests 1 year ago
Victor Julien bb544a7319 unittests: clean up memory for thread storage tests 1 year ago
Victor Julien 44c089ca2b unittests: clean up memory for tcp decode tests 1 year ago
Victor Julien 10a6a0986e unittests: clean up memory for counter tests 1 year ago
Victor Julien 8a8509bf62 unittests: clean up memory for smtp tests 1 year ago
Victor Julien 851ecfd263 unittests: clean up memory for reputation tests
Don't call SRepInit twice.
1 year ago
Victor Julien 948d9a805c unittests: clean up memory for ssh tests
Flow requires IP proto to be set for flow cleanup to work.
1 year ago
Victor Julien b1dacaf394 unittests: clean up memory for mpm tests 1 year ago
Victor Julien 6d54a4e8ba unittests: clean up memory for sigorder tests 1 year ago
Victor Julien f3c7877fb5 unittests: clean up memory for radix tests 1 year ago
Victor Julien a9b2707d62 unittests: clean up memory for reference tests 1 year ago
Victor Julien 14241754ab unittests: clean up memory for host os info tests 1 year ago
Victor Julien c2b391bfe8 unittests: clean up memory for threshold tests 1 year ago
Victor Julien 5b11241a46 unittests: clean up memory for classtype tests 1 year ago
Victor Julien 5ab8b8cd49 unittests: clean up memory for signature tests 1 year ago
Victor Julien d551881a7e unittests: clean up memory for stream tests 1 year ago
Victor Julien e777ccb125 unittests: clean up leaking payload test 1 year ago
Victor Julien c8cb029de9 unittests: disable LogCustomFormatTest01 for MinGW
Test was previously not run so it was missed that it fails.
1 year ago
Victor Julien 8d85777227 unittests: clean up detect port tests
Remove artificial insert test; fix memleaks; use more FAIL/PASS api
1 year ago
Victor Julien 2030f0a527 unittests: clean up magic tests
Remove dead code; Convert to FAIL/PASS API; fix mem leaks.
1 year ago
Victor Julien 8abab3e37e unittests: clean up memory in modbus tests 1 year ago
Victor Julien 68cc96a463 unittests: clean up memory in lua tests 1 year ago
Victor Julien 94397e177c unittests: convert log format test to FAIL/PASS api 1 year ago
Victor Julien 8dd86a0479 unittests: clean memory in tls validity tests 1 year ago
Victor Julien f23385b433 unittests: clean up memory for tcp.flags tests 1 year ago
Victor Julien cbaff02d66 unittests: clean up memory in ftp tests 1 year ago
Victor Julien ce4276bdd9 unittests: clean up memory in fragbits tests 1 year ago
Victor Julien b953c69938 unittests: clean memory flow rate tests 1 year ago
Victor Julien 7c0d94f35e unittests: clean memory in flowbits tests 1 year ago
Victor Julien e2d09fbd5e unittests: clean memory in flow storage tests
Before tests are started an init is already done, so don't overwrite an allocation.
1 year ago
Victor Julien 700e687118 unittests: clean up conf memory in body tests 1 year ago
Victor Julien c06cb8af19 unittests: clean up memory for stateful detect tests 1 year ago
Victor Julien 57d1f20dfa unittests: don't leak memory with --list-unittests 1 year ago
Victor Julien ec6536ba75 unittests: free memory for proto tests 1 year ago
Victor Julien 37ad70ab59 unittests: don't leak memory in affinity tests 1 year ago
Victor Julien 65ba8952b5 unittests: clean stats memory in http.stat_msg tests 1 year ago
Victor Julien 9f0aefed48 unittests: clear stats memory in htp tests 1 year ago
Victor Julien fb4a805c69 unittests: clean stats memory in http.stat_code tests 1 year ago
Victor Julien 1e938cab92 unittests: clean stats memory in http.cookie tests 1 year ago
Victor Julien 73c1c489f7 unittests: don't leak memory in checks
Result of bstr_util_strdup_to_c needs to be freed
1 year ago
Victor Julien 28ae95e8da unittests: fix memory leaks; convert to FAIL/PASS 1 year ago
Victor Julien 87b683ff6d unittests: fix dcerpc.stub_data test testing the wrong issue
Tested missing sid instead of proto mismatch.
1 year ago
Victor Julien 74f629d235 unittests/helper: free memory for IPv6 packets
IPv6 packets have multiple heap allocations in the helper code, so free them all.
1 year ago
Victor Julien 150bee3a46 unittests/helper: free flow memory more thoroughly 1 year ago
Victor Julien 9474c552d2 unittests/helper: free thread stats 1 year ago
Victor Julien b72d44f206 unittests/helper: set mpm-algo properly in tests 1 year ago
Victor Julien 1c30fcfe47 detect/address: make list clean function non-static
To be used to fix a leaky test.
1 year ago
Victor Julien ce9c7a024e detect/content: don't leak replace memory
Replace keyword updates a prior content with a heap allocation of the
pattern the content should be replaced with. Make sure this is freed as
well.

Bug: #7997.
1 year ago
Philippe Antoine 969739d067 detect: http2.errorcode is now a generic integer
Ticket: 7889
1 year ago
Philippe Antoine 401b2fcae6 detect: http2.frametype is now a generic integer
Ticket: 7889
1 year ago
Philippe Antoine 0b63894c5d detect: remove ifdefed out code
engine-proto accepting numerical values should be done with
generic integer framework if wanted

Ticket: 7889
1 year ago
Jeff Lucovsky 0af7793410 output: Display ethertype properly
Ethertype values are now converted from network format to host format
before display occurs. Displayed values are now in hex instead of
integers.

Without this change, ethertype values such as 0xfbb7 are
displayed in decimal as: 47099 (0xb7fb).

The actual value is 64439 (0xfbb7); all logged ether_type values
will be displayed in host order in decimal format. This example
will log the ether type as 64439

Issue: 7855
1 year ago
Victor Julien f0121d8bc2 stats: improve wait loops
Check bail condition before entering conditional wait.

CID 1554236: (#1 of 1): Indefinite wait (BAD_CHECK_OF_WAIT_COND)
dead_wait: A wait is performed without ensuring that the condition is not already satisfied while holding lock ThreadVars_.ctrl_mutex. This can cause unnecessary waiting if the notification happens before the lock is acquired.

CID 1554238: (#1 of 1): Indefinite wait (BAD_CHECK_OF_WAIT_COND)
dead_wait: A wait is performed without ensuring that the condition is not already satisfied while holding lock ThreadVars_.ctrl_mutex. This can cause unnecessary waiting if the notification happens before the lock is acquired.
1 year ago
Philippe Antoine c99e159341 detect/files: support protocols only over udp
Ticket: 7973

Files were supported on both TCP and UDP. But file detection keywords
such as file.data made signatures loading fail if the signature
was using an app-layer protocol that enabled on udp only, even
if the signatures could run smoothly.
1 year ago
Lukas Sismis 27383f878d dpdk: supress a warning of the bond function
DPDK Bonding API has been changed in DPDK version 23.11 where
the old *slave* API was marked as deprecated and the new *member*
API was marked as experimental.
This was unfortunately executed by marking both API variants
at the same time. The deprecated version is removed from the follow
up versions while the experimental version will become stable
in the next DPDK releases. This is based on a policy in DPDK where
an API change needs to merged in main for 1 stable release before
removing the experimental flag.

In DPDK 24.11 this has been fixed and warning supression is not
added.

Ticket: 7009
1 year ago
Lukas Sismis 8f63094744 dpdk: fix the CPU exclude logic
The exclude function incorrectly performs a XOR operation. While it
works when the worker cores occupy all cores, it is not the correct
operation. For example, when a core is affined to only management
and not worker threads, the XOR operation affines it to the worker set.
(1 XOR 0 -> 1, where in fact the desired outcome is 0)

Ticket: 7975
1 year ago
Philippe Antoine fa322e3dc2 rust: remove unneeded cbindgen exclusions 1 year ago
Philippe Antoine 958344787f rust: bindgen FileAppendData
Ticket: 7667
1 year ago
Philippe Antoine 811d28cc6b rust: bindgen util-spm-bs.h
for SCBasicSearchNocaseIndex

Ticket: 7667
1 year ago
Juliana Fajardini b6283ad05f decode/ipv6: apply clang-format changes 1 year ago
Juliana Fajardini a247801743 decode/ipv6: minor clean-ups
Remove unused debug-like statements (commented out 'printf's).
1 year ago
Juliana Fajardini ee7f01c83f decode/ipv6: flag invalid pkt w/ wrong ip ver event
When the decoder finds a packet with wrong IP version for
IPv4|IPv6-in-IPv6 tunnels, it would set an event, but wouldn't flag the
packet invalid. This fixes that.

Bug #7964
1 year ago
Juliana Fajardini 6f441ee435 decode/ipv4: minor clean-ups
Remove unused debug-like statements (commented out 'printf's).
1 year ago
Victor Julien 4764152567 output/filestore: reformat 1 year ago