Commit Graph

17638 Commits (8425eed8cdabdcb08310269eff38902e7af01efd)
 

Author SHA1 Message Date
Victor Julien 0246668de7 flow-worker: use explicit type for DetectEngineThreadCtx 11 months ago
Victor Julien 860bb11692 detect: only reset packet alert things in unittest mode 11 months ago
Victor Julien afa88757fe detect: pass de_ctx around as const 11 months ago
Victor Julien a90938c55a detect/bsize: constify signature pointer in callback 11 months ago
Victor Julien 325f0cc02a detect/absent: constify signature pointer in callback 11 months ago
Victor Julien 17ed70dcb5 eve/schema: reformat with clang-format 11 months ago
Jason Ish 1aaf5cb7d2 rust: allow some lints in suricatactl and suricatasc
These are lints we allow in the Suricata Rust source code for style
reasons.
11 months ago
Jason Ish 89ba53272c suricatasc: reconnect on loss of connection
If the connection is lost (for example, Suricata is restarted), try to
re-open the connect and re-execute the command.

This was the behavior of the Python implementation.

Ticket: #7746
11 months ago
Lukas Sismis da03461f71 affinity: avoid zero-division in the CPU selector
Ticket: 7747
11 months ago
Lukas Sismis b71bb41bc5 runmodes: remove redundant NULL check
Ticket: 7747
11 months ago
Jeff Lucovsky cd4e728b77 detect: Ensure byte* variable usages is for same buffers
Issue: 7549

Use the active buffer list to fetch SM variables to ensure that they are
part of the same list so a variable created with bytemath or byteextract
will have context when used with bytejump, e.g

Not needed for content modifiers.
11 months ago
Jason Ish f7a05f1e8e dns: log addresses in order of packet
DNS logs have always been logged in flow direction, this can be
confusing as DNS responses have a src_ip of the client, but it makes
more sense to have the src_ip for the server, as that is the src_ip of
the response packet.

As this is a breaking change, limit it DNS v3 logging which was
introduced, and is the default for Suricata 8.0.

Ticket: #6400
11 months ago
Jason Ish 25e32f4f7a output: delayed initialization for custom loggers
When a plugin is first initialized, it is too early to register
transaction loggers. Instead, a plugin can register a callback to be
called when Suricata is ready for outputs like transaction loggers to
be registered.

Likewise for library users, there is a window in SuricataInit where
transaction loggers can be registered that library users don't have
access to. So a lifecycle callback useful here as well.

Ticket #7236
11 months ago
Juliana Fajardini 656b24004e pgsql: install rules 11 months ago
Shivani Bhardwaj ab01a1b211 smtp: 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.

SMTP parser can handle multiple command lines per direction, however an
SMTP transaction comprises of the full communication starting from HELO
till there's a RST or QUIT request. Appropriate calls to trigger raw stream
inspection have been added on succesful parsing of each full request and response.

Task 7026
Bug 7004
11 months ago
Shivani Bhardwaj 16eb56aa73 sip: fix inspection direction 11 months ago
Shivani Bhardwaj 8bf7e9abcc dnp3: 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.

DNP3 parser creates a transaction per direction. Appropriate calls to trigger
raw stream inspection have been added on succesful parsing of each request and
response.

Task 7026
Bug 7004
11 months ago
Lukas Sismis f48f808f33 threading: add unittests for cpu affinity YAML parsing 11 months ago
Lukas Sismis daca1d1a24 affinity: error out on defining CPUs outside valid range 11 months ago
Lukas Sismis ba7a42b4eb threading: let cpu set building callback return a value 11 months ago
Lukas Sismis 8817a959e8 threading: support thread autopinning and interface-specific affinity
Using the new configuration format, it is now possible to set CPU affinity
settings per interface.

The threading.autopin option has been added to automatically use CPUs from the
same NUMA node as the interface. The autopin option requires
hwloc-devel / hwloc-dev to be installed and --enable-hwloc flag in configure
script.

Ticket: 7036
11 months ago
Lukas Sismis 1a1789eb29 doc: remove title in threading section with no content 11 months ago
Lukas Sismis 6c654e30ac threading: support previous threading configuration format
Provide backward compatibility with the previous configuration
format to allow smooth transition to the new format.
The commit adds docs about the new format and the introduced changes.
11 months ago
Lukas Sismis 733cf34ad7 threading: transform *-cpu-set nodes from list items to nodes
Part of Ticket 2321 work to remove unnecessary lists from
the config file.

Ticket: 2321
11 months ago
Lukas Sismis 390baad7dc util-affinity: move properties of *-cpu-set node one layer up in YAML 11 months ago
Lukas Sismis fbfced12f2 threading: refactor CPU affinity code
Split the code into multiple functions for easier readability.
11 months ago
Lukas Sismis 35c86ce800 actions: test hwloc build 11 months ago
Lukas Sismis 49cd1206e8 github-ci: install hwloc as a mandatory dependency 11 months ago
Lukas Sismis e471972a5b dpdk: move DPDK socket retrieval to utils 11 months ago
Lukas Sismis 44948b9e28 runmodes: query the active runmode with a function call 11 months ago
Jason Ish f0411c079d rust: fix compiler warning for confusing lifetimes
For example:

error: lifetime flowing from input to output with different syntax can be confusing
   --> htp/src/headers.rs:475:16
    |
475 | fn null(input: &[u8]) -> IResult<&[u8], ParsedBytes> {
    |                ^^^^^             -----  ----------- the lifetimes get resolved as `'_`
    |                |                 |
    |                |                 the lifetimes get resolved as `'_`
    |                this lifetime flows to the output
    |
note: the lint level is defined here
   --> htp/src/lib.rs:3:9

This currently only happens when using the Rust nightly compiler, which
we use for our fuzz builds.
11 months ago
Lukas Sismis f865b7cc97 hs-cache: adjust printing directive to match uint64_t 11 months ago
Jason Ish b83c2dacd4 lua: update to Lua 5.4.8
Also uses a proper Lua tagged version that is not a pre-release.

Ticket: #7632
11 months ago
Jason Ish e7366e43b5 rust: update deps
Update all deps with cargo update. Additionally, apply the updated
versions to the Cargo.toml, which while not stricly required, does
make it more clear what the version in use is.
11 months ago
Jason Ish 332bc6a05b rust: fix new clippy issues with MSRV update 11 months ago
Jason Ish 7de03a5ef3 rust: update clap and rustyline
With a MSRV of 1.75.0 we can now use current Clap. Rustlyline is
updated, but still needs to be held back from the most current
release.
11 months ago
Jason Ish 55a0d403cb rust: unpin once_cell from old version
We can now update to the current version of once_cell with Rust 1.75.
11 months ago
Jason Ish f0eaebe3a6 rust: set MSRV to 1.75.0
This is the Rust version found on Ubuntu LTS releases as of today, and
is the oldest we need to support.

Ticket: #6573
11 months ago
Jeff Lucovsky a8a3780276 doc/entropy: Document the entropy log output 11 months ago
Jeff Lucovsky a292670443 detect/entropy: Add calculated entropy value to flowvars
When the entropy keyword is used, record the calculated entropy value to
a flow variable for logging use.
11 months ago
Jeff Lucovsky 62e3c02914 doc: Add missing contributors to ack file
Add missing contributors as identified by
    git shortlog -s -n --no-merges -- .
11 months ago
Juliana Fajardini 9614770483 doc/lua: document request_host lua lib
Seems that we missed bringing this one, when documenting HTTP lua lib
functions.
11 months ago
Philippe Antoine 9054187659 pop3: install rules 11 months ago
Philippe Antoine 966b833113 pop3: fix event rule 11 months ago
Philippe Antoine 79544d0f1e rust: remove some unneeded cbindgen:ignore
Ticket: 7667
11 months ago
Philippe Antoine 7bb0c94ae9 rust: bindgen app-layer-detect-proto.h
Ticket: 7667
11 months ago
Jeff Lucovsky ace0d37636 detect/content: account for distance variables
Under some cases (below), the depth and offset values are used
twice. This commit disregards the distance variable (if any), when
computing the final depth.

These rules are logically equivalent::
1. alert tcp any any -> any 8080 (msg:"distance name"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:option_len; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:1;)
2. alert tcp any any -> any 8080 (msg:"distance number"; flow:to_server; content:"Authorization:"; content:"5f71ycy"; distance:0; byte_extract:1,0,option_len,string,relative; content:!"|38|"; distance:7; within:1; content:"|37|"; distance:-1; within:1; content:"|49|"; distance:option_len; within:1; sid:2;)

The differences:
Rule 1: content:!"|38|"; distance:option_len; within:1; //option_len == 7

Rule 2: content:!"|38|"; distance:7; within:1;

Without this commit, rule 2 triggers an alert but rule 1 doesn't.

Issue: 7390
11 months ago
Lukas Sismis 5dcd0a36f9 flow: convert flow_id to uint64 as no signdess is necessary 11 months ago
Lukas Sismis a90f0c96b5 dpdk: change thread_id field to uint16_t 11 months ago
Lukas Sismis 4dfd44d350 dpdk: update types to avoid type-warnings 11 months ago