Commit Graph

19705 Commits (df5f3feb1da788f2aca051f543fb6e27841c653a)
 

Author SHA1 Message Date
Jason Ish df5f3feb1d rust/derive: add Makefile for Cargo.toml regeneration
To automatically update Cargo.toml when Cargo.toml.in is updated.
4 days ago
Philippe Antoine 3da75f1385 ci: add new suricata-verify replay step to xdp build
so as to run ebpf replay tests
4 days ago
Adam Kiripolsky 5cb7a0d7be xdp: fix vlan byte order
Change the byte order of vlan TCI when extracting it
from vlan_hdr in xdp_filter.c. This fixes xdp bypass for vlan tagged
packets, as without the fix flows that are supposed to be bypassed by
the xdp filter are not bypassed.

Ticket: 8699
4 days ago
Philippe Antoine 9ab8fa19d2 flow: update bypassed flows on shutdown/recycle 4 days ago
Victor Julien a6740d021a detect/pcre: accept a relative pcre after byte_jump
A rule whose relative pcre follows a keyword that moves the detection
pointer is refused at load time with "pcre with /R (relative) needs
preceding match in the same buffer":

  alert tcp any any -> any any (msg:"x"; byte_jump:4,0; pcre:"/^x/R"; ...)

The search for the preceding match only asked for content and pcre
sigmatches, so a rule that anchors a relative pcre on a byte_jump had
nothing to find even though byte_jump leaves the detection pointer at
the jump target.

Add the keywords that update det_ctx->buffer_offset to the search:
byte_jump, byte_extract and byte_math. byte_test and isdataat only read
that pointer, so they stay rejected; a relative pcre after them alone
would silently match from the start of the buffer.

Ticket: #7987.
4 days ago
Samaresh Kumar Singh 73095bb089 github-ci: run netmap unit tests
Build the netmap job with unittests and run the netmap tests so the
multi-slot packet handling stays covered.

Ticket: #8777
4 days ago
Samaresh Kumar Singh e886d2d030 source/netmap: fix multi-slot packet over-read
A packet that netmap delivers across several ring slots was handed to the
rest of the code as the first slot buffer together with the summed length
of all the slots. When those slot buffers were not next to each other in
memory this read past the first buffer, which could crash the process or
leak bytes from unrelated buffers into inspection, pcap output and IPS or
tap forwarding.

Multi-slot packets are now copied slot by slot into a per-thread buffer so
the caller always gets one addressable frame, and such packets are always
copied into the Packet instead of being referenced zero-copy. Single-slot
packets keep the zero-copy path. The walk over the fragment slots is bounded
by the slots we own and the total length is capped, so a broken or over-long
chain is dropped as one unit and the ring keeps moving forward.

Adds unit tests that build a fake ring and cover single-slot, adjacent,
non-adjacent, ring-wrap, empty-fragment, over-size and never-ending chains.

Ticket: #8777
4 days ago
Samaresh Kumar Singh 77e980c783 source/netmap: read one packet in its own function
NetmapReadPackets walked the slots of a single packet inline while also
driving the per ring iteration. Move the slot walk into
NetmapReadOnePacket so the ring loop only picks the next packet and the
slot handling can be changed on its own.

No functional change.

Ticket: #8777
4 days ago
Jason Ish 9451642a28 eve: fix C logger signatures for generic callbacks
Several C loggers are registered through a cast to
EveJsonSimpleTxLogFunc, which has an incompatible signature. Clang's
function sanitizer reports this as a call through a pointer to an
incorrect function type.

Change these loggers to the generic callback signature and register them
without casts.

Ticket: 9226
1 week ago
Philippe Antoine 37cc354809 http1: only disable decompression after too many bombs
Ticket: 9200

And to do so, reinit the content_encoding, so that
we do not try to take a decompressor
1 week ago
Jason Ish b717c481d3 psl: update to 2.1.241
Update the embedded public suffix list for the upcoming release.

Ticket: 9025
1 week ago
Jeff Lucovsky db36f39632 ftp: drop null checks from the response line free
SCFTPFreeResponseLine gated the release of the code buffer on a null
test of the response pointer, so the code buffer had no check of its
own. Neither check could fire: parse_response_line sets both pointers
from Box::into_raw on a boxed slice, which never returns null, and C
code obtains an FTPResponseLine only from SCFTPParseResponseLine. The
comment on the code field claimed the pointer may be null; a line with
no status code gets an empty buffer with code_length 0 instead.

Remove both null checks, note why they are unnecessary, and correct the
field comment.

Ticket: 8803
1 week ago
Jeff Lucovsky 2054e9bfcf ftp: free the response code as a boxed slice
parse_response_line allocates the code buffer with Box::into_raw on a
boxed slice, but SCFTPFreeResponseLine released it by rebuilding a
Vec<u8> with capacity code_length. Vec::from_raw_parts accepts any
global-allocator pointer whose size and alignment match, and both paths
compute the same layout for a byte slice, so the old free was sound. It
differed only from how the response buffer is released.

Release the code buffer through Box::from_raw on a slice pointer, so
both buffers are freed the same way they were allocated.

Ticket: 8803
1 week ago
Shivani Bhardwaj 0c534c9ccd detect/iponly: warn on threshold track by flow
IP Only rules are only evaluated once per direction per flow for a
standard rule and twice at the most for a bidirectional rule. Using
threshold or detection_filter with track by_flow does not make much
sense for higher count as the rule may never fire.

Issue a warning for this case in engine analysis mode for now.

Ticket: 9170
1 week ago
Shivani Bhardwaj 8d46226a59 detect/iponly: carry on dotted netmask
For calculating the address space to be matched against, the CIDR
netmask is taken to account by the IP Only Engine. However, this netmask
was not set properly for dotted netmasks. Fix it.

Ticket: 9166
1 week ago
Juliana Fajardini 98e205be0b docs: note about no config action support in fw mode
For Threat Detection rules

Part of
Ticket: #9041
1 week ago
Juliana Fajardini 893ccda1e1 firewall: do not support config action in TD rules
In firewall mode.
Second part: rule action.

Ticket: #9041
1 week ago
Philippe Antoine 46aa14f61c datasets: do not accept char devices
Such as /dev/zero

Ticket: 9106
1 week ago
Juliana Fajardini 4badfd13f4 docs: note about no support of config kw in fw mode
For Threat Detection rules.

Part of
Ticket: #9041
3 weeks ago
Juliana Fajardini cc84baf1dd detect/config: do not support keyword in TD rules
First part: rule keyword.

Ticket: #9041
3 weeks ago
Juliana Fajardini d4aa40df61 detect: allow banning kw from td in firewall mode
In case a keyword should work in firewall mode, with firewall rules
only. The engine errors out if threat detection rules use the given keyword.

Part of
Ticket #9041
3 weeks ago
Juliana Fajardini 3e3dcf4c9f firewall: don't use 'banned' when no fw support
Banned isn't the right messaging here, we decided.
Instead, go with "not supported".
3 weeks ago
Jason Ish f9f3c2082a pcap-file: clear directory current_file after cleanup
On PcapFileDispatch() failure, pv->current_file was left pointing at freed file
vars, which were then cleaned up again on thread teardown.

Generally unreachable, as no pcap-file pipeline slot fails on real input.

Ticket: #9162
3 weeks ago
Jason Ish cffd9cd62d app-layer: don't include decode.h from app-layer-frames.h
Including decode.h pulls inline functions that use SCLogDebug and SCLogError
into the bindgen input, but util-debug.h hides those macros from bindgen,
breaking "make update-bindings". Only forward declarations are needed.
3 weeks ago
Jason Ish 5f8d1beddf rust: fail check-bindgen-bindings if bindgen fails
Even on failure before, due to the ';', the make target was still
exiting success.
3 weeks ago
Lukas Sismis a329e0a3b9 firewall: reject flow scope for the pre-flow hook
Action scopes for packet hook default policies were validated per hook
class, so `flow` was accepted for every packet hook. The pre_flow hook is
a special case as it is evaluated before Suricata obtains a flow record.
Firewall rules on the pre_flow hook were not validated at all, so `flow`
and `tx` scopes were accepted there as well.

This commit adds extra validation to scope parsing for the pre_flow
hook default policy and validates pre_flow firewall rules against the
same scopes.

Ticket: 8967
3 weeks ago
Lukas Sismis 6fe3a3dfc3 firewall: apply flow scope to the default packet policy drop
The packet default policy runtime only applied the action scope for
`accept`. For `drop:flow` and `reject:flow` it dropped the packet and left
the flow untouched, so the flow scope had no effect.

Ticket: 8969
3 weeks ago
Lukas Sismis 3a6ecab098 github-ci: add OpenBSD 7.9 build
Ticket: 8975
3 weeks ago
Lukas Sismis 9d88976dfa ci: migrate to FreeBSD 15.1
As FreeBSD 15.0 hit EOL, Rust dependencies started to fail.
Upgrading to 15.1 to move from EOL release.

Ticket: 9172
3 weeks ago
Victor Julien 8998fbacc5 threads: add unit tests for TmThreadsWaitForUnpause
Covers the killed-during-initial-pause case (mgmt thread returns so the
main loop runs once; non-mgmt returns false and skips it, THV_PAUSED
cleared on both paths) and the unpause-while-spinning path, driven from
a helper thread.

Ticket: #9168.
3 weeks ago
Victor Julien 1ff8de029a threads: run the main loop once when a mgmt thread is killed during the initial pause
Every thread is created paused (THV_PAUSE) and the main thread unpauses
them all before the main loop. A thread that has not yet been scheduled
spins in TmThreadsWaitForUnpause() until it sees the unpause. Under
heavy thread oversubscription (many short offline runs in parallel) a
management thread can be descheduled across the whole run: by the time
it runs again the shutdown has set THV_KILL while it is still in the
initial pause. TmThreadsWaitForUnpause() then returned false, so the
thread skipped its main loop entirely and never did its final shutdown
work - for the stats thread that means the last stats event is never
written to eve.json. This intermittently fails suricata-verify tests
that assert on the final stats.

Mgmt threads (tv->type == TVT_MGMT) now return so the main loop still
runs once: it tests THV_KILL and exits after the pass, but the thread
gets the single pass it needs for final work (e.g. the last stats
output). THV_PAUSED is cleared on that path. RX, worker and other
non-mgmt threads keep the previous behaviour: their loops do not test
THV_KILL at the top - the RX loop exits only on the PktAcqLoop return
value and suricata_ctl_flags, and a pcap-file pass would dispatch
packets into a pipeline that is being torn down.

The log-maintenance thread breaks before its first sleep slice when it
is already being killed: on that pass no rotation or flush can happen
(their wait counts need a full second of slices), so the fixed 500 ms
sleep would be pure shutdown latency - the slice exists to react to
shutdown quickly, and a first wake into a KILL must not wait out a full
slice. A kill arriving after the first slice keeps the normal
behaviour, including the final rotation check.

Ticket: #9168.
3 weeks ago
Philippe Antoine b8275da9d0 dns/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 895347aff2 kerberos/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine dfc42274ab ntp/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 6abd9e9540 ldap/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine b39514269a rfb/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine fc36553629 mqtt/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine e6231074b2 enip/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 72afcb301f websocket/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 8a6359662c nfs/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 5a5dcdab3e http2/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine c23ff8695b sctp/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 49aefe7093 ci: check for enum integer keywords
And generic documentation about it

Ticket: 8675
3 weeks ago
Philippe Antoine b47bde6cda dnp3/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine f3d8af65cb snmp/doc: list possible values for enum keywords
Ticket: 8675
3 weeks ago
Philippe Antoine 5f068793d3 doc: string enum derive has a function listing the enum values
Ticket: 8675
3 weeks ago
Philippe Antoine 6f57427977 doc: keywords can register a callback for further info
Ticket: 8675

Will be used by enum uint keywords to print the list of possible
enum values
3 weeks ago
Philippe Antoine a269d8635f doc: list-keywords with json output
suricata --list-keywords=json outputs json for all the keywords

Ticket: 8675
3 weeks ago
Philippe Antoine 04c066977a smtp: apply max-tx to live txs
Instead of the cumulative tx count

Ticket: 9038
3 weeks ago
Philippe Antoine 8461e3f3e7 src: do not include "util-unittest.h" directly
It is included in suricata-common.h

Ticket: 945
3 weeks ago