Commit Graph

18566 Commits (dbea6607294c2d1d13ae17a06a2d9b3e3630439b)
 

Author SHA1 Message Date
Philippe Antoine dbea660729 detect/transforms: add gunzip transform
Ticket: 7846
6 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
6 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
6 months ago
Philippe Antoine 256c6a99b8 datasets: adds safety check before stack allocation
Even if current caller does not provide too big data.

Ticket: 8001
6 months ago
Victor Julien 336a9d05ca krb5: fix TCP record parsing
A logic error in multi-record parsing meant only the first record was parsed.

Bug: #8278.
6 months ago
Jason Ish eab5931074 github-ci: merge rust.yml into existing builds.yml build
The Rust build in rust.yml was just an AlmaLinux 9 build with some extra
checks.  Instead, use an existing AlmaLinux 9 build in builds.yml, make
it use Rustup (there are other AlmaLinux 9 builds that use the RPM), and
add the checks.

Saves us one build in CI.
6 months ago
Jason Ish 77d96851f5 pfring: use static functions; add void arg to SCPluginRegister
Minor cleanups.
6 months ago
Jason Ish a60e93c2cd pfring: fix typo in StringParseUint16
StringParseUnt16 -> StringParseUint16

Ticket: #8271
6 months ago
Jason Ish 828d105cea pfring: copy cflags over from src/
This should cause the following warning to error out:

runmode-pfring.c: In function 'OldParsePfringConfig':
runmode-pfring.c:118:17: error: implicit declaration of function 'StringParseUnt16'; did you mean 'StringParseInt16'? [-Wimplicit-function-declaration]
  118 |             if (StringParseUnt16(&pfconf->threads, 10, 0, threadsstr) < 0) {
      |                 ^~~~~~~~~~~~~~~~
      |                 StringParseInt16

Ticket: #8271
6 months ago
Jason Ish d230a760e6 examples/altemplate: update to use jsonbuilder from ffi crate 6 months ago
Jason Ish 6b850dddb8 rust/ffi: JsonBuilder wrapper around C JsonBuilder API
For use by plugins that need to work with JsonBuilder.
6 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.
6 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.
6 months ago
Jason Ish f951477461 rust/debug: use functions from ffi crate where possible
It's not possible to use all the functions and macros from the ffi crate
in the main Suricata crate, as there are conditionals around when
running in test mode, and "cargo test" doesn't propagate the "cfg(test)"
to test crates.

Which for now means duplicating the macros and some functions.
6 months ago
Jason Ish 8b69089cb8 rust/ffi: more rust friendly plugin registration
A plugin can now create a "Plugin" struct with Rust strings.  The
`into_raw` method converts it to a raw pointer suitable for returning
during plugin registration.
6 months ago
Jason Ish 0999530726 rust/ffi: rust wrapper around eve filetype registration 6 months ago
Jason Ish 2d0bf9a2ed output-eve: bindgen SCEveFileType callback types 6 months ago
Jason Ish 8e3bd1ca55 examples/altemplate: use suricata-ffi for logging macros 6 months ago
Jason Ish b4db7bdaee rust/ffi: add logging (debug) wrappers
Mostly a copy of Suricata core's logging wrappers into the ffi crate.

These are not yet used by Suricata-core as they do require the
Suricata library to be available, which is not the case with tests. And
the `cfg(test)` parameter is not passed through to sub-crates.

However, this does allow a plugin (or library) to call the logging
macros without depending on the "suricata" crate.

Ticket: #7666
6 months ago
Jason Ish 2c51744ccc rust/ffi: stub out a rust ffi crate
This crate is for Rust wrappers around the -sys crate which includes
only raw bindings. This is the place to add nice wrappers around those
bindings, however it should remain clear of dependencies on the main
Suricata core crates.

Ticket: #7666
6 months ago
Jason Ish e9611a4d7c output-eve: bindgen SCRegisterEveFileType to Rust
Used by Rust output plugins.
6 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.
6 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.
6 months ago
Jason Ish 8ea103031c output-eve: cleanup include guards to reflect filename 6 months ago
Jason Ish 2defd5ae5a userguide/Makefile: don't add "install" to EXTRA_DIST
Adding the directory "install" to EXTRA_DIST, actually triggers make
to run "make install", which is not what we want. Instead, avoid this
magic keyword and list the files in the install directory
individually.

If the user doesn't have permission to install files to the prefix,
like "/usr", then "make dist" can fail. Worse, even they do have
permission to write into the prefix, a "make dist" will install files
there when it shouldn't.

Ticket: #8279
6 months ago
Philippe Antoine a079d1c68a src: remove unused enum values 6 months ago
Philippe Antoine 536242341b detect/smb: move smb.version keyword to rust
Ticket: 8267
6 months ago
Philippe Antoine df495d7e22 rust: bindgen SCDetectGetLastSMFromLists
to use it from rust keywords
6 months ago
Philippe Antoine 697c641400 detect/smb: move smb share and named_pipe keywords to rust
Ticket: 8267
6 months ago
Philippe Antoine 667f8b2eb7 detect/smb: move smb ntlmssp keywords to rust
Ticket: 8267
6 months ago
Philippe Antoine c48819e61f detect/sip: remove obsolete keyword ids
as they are now dynamically generated
6 months ago
Victor Julien e69c801a12 flow: reshuffle fields to avoid mutex in 2 cachelines 6 months ago
Victor Julien 6acef7fa16 flow: move members for more compact layout
Closes a hole.
6 months ago
Victor Julien a2e9ac21f8 flow: turn flags field into uint64_t
Entire space is used.
6 months ago
Victor Julien aff273bb89 flow: move livedev into Flow 'header'
It won't get updated after initial set.
6 months ago
Victor Julien 20afd63cbd flow: move flow_hash field to header
It won't get updated after initial set.
6 months ago
Victor Julien 9864ae23aa flow: improve Flow field docs 6 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
6 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
6 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.
6 months ago
Juliana Fajardini 1fee9b0102 detect: minor - typo fix 6 months ago
Jason Ish b0c912588c mqtt/detect: fix mqtt_parse_bool return type
Previously we were boxing a u8 and returning it as a pointer to a
boolean. While this is probably not an issue itself, the value 2 was
allowed to be converted to a boolean, which is undefined behavior in
Rust.
6 months ago
Jason Ish b9e0f9cc8b rfb/detect: fix rfb_parse_sec_result return type
The data parsed is a u32, but returned as DetectUintData<u8>, then
later free'd as a DetectUintData<u32>.
6 months ago
Jason Ish 8b2a7ac47c nfs/detect: fix nfs_procedure_parse return type
Was returning DetectNfsProcedureData as a pointer to
DetectUintData<u32>, and free'ing it as such.
6 months ago
Jason Ish e474e45429 dns/detect: fix rcode return type
The parsed DNS rcode was being returned as a DetectUintData<u8>, but is
parsed, and free'd as a u16. So return a DetectUintData<u16>.
6 months ago
Victor Julien 571681bc29 github-ci: add namespace bond tests with multiple nets 6 months ago
Victor Julien a8cad83403 github-ci: add namespace af-packet bond test 6 months ago
Jason Ish c7f806a728 rust/sys: allow unknown lints
allow(unpredictable_function_pointer_comparisons) is needed on newer
versions of Rust, but is unknown to our MSRV, so for now, allow unknown
lints.
6 months ago
Shivani Bhardwaj 11b2860f23 rust/cargo: ignore RUSTSEC-2026-0009 for time crate
cargo audit reports this security issue with the time crate but Suricata
remains unaffected as no influenced fn is used by Suricata.
Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0009

The MSRV for newer time crate versions are higher than the MSRV for
Suricata right now: 1.75.0

Hence, the best course of action is to suppress this warning.

Ticket: 8269
6 months ago
Philippe Antoine 364d2c077d rust: bindgen SCAppLayerRegisterParser
Ticket: 7662
6 months ago