]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
9 months agodoc/userguide: generate eve documentation 11895/head
Jason Ish [Mon, 5 Jun 2023 19:56:59 +0000 (13:56 -0600)] 
doc/userguide: generate eve documentation

Add EVE documentation for QUIC and Pgsql to their respective sections of
the userguide.

Also add a complete EVE reference as an appendix.

Other protocols can be done, but its a manual process to document in the
schema, then add the glue to pull them into the documentation.

The documentation is generated during "make dist", or if it doesn't
exist, "conf.py" will attempt to generate the eve documentation for
building on Readthedocs.

9 months agoevedoc.py: script to generate rst doc from eve schema
Jason Ish [Mon, 5 Jun 2023 19:55:54 +0000 (13:55 -0600)] 
evedoc.py: script to generate rst doc from eve schema

Also supports a "--flat" command line option to produce a "dot"
separated version of all the fields in the EVE schema.

9 months agogithub-ci: run macos python jobs in virtualenv
Jason Ish [Mon, 7 Oct 2024 15:52:30 +0000 (09:52 -0600)] 
github-ci: run macos python jobs in virtualenv

With the latest brew changes, a virtualenv is required to install
pyyaml.

9 months agotm-modules: minor code cleanups 11880/head
Jason Ish [Fri, 4 Oct 2024 23:21:34 +0000 (17:21 -0600)] 
tm-modules: minor code cleanups

- includes
- loops

9 months agothreading: remove TM_FLAG_LOGAPI_TM as its not used
Jason Ish [Fri, 4 Oct 2024 23:02:36 +0000 (17:02 -0600)] 
threading: remove TM_FLAG_LOGAPI_TM as its not used

This flag is never set, remove.

10 months agorust: unpin serde 11875/head
Philippe Antoine [Thu, 3 Oct 2024 14:10:29 +0000 (16:10 +0200)] 
rust: unpin serde

As oss-fuzz uses a newer compatible rustc version

10 months agogithub-ci: add rpm build job 11855/head 11865/head
Jason Ish [Tue, 1 Oct 2024 16:08:01 +0000 (10:08 -0600)] 
github-ci: add rpm build job

Build RPMs for Fedora 40 and EPEL 9 (using AlmaLinux).

10 months agoebpf: include llvm_bpfload.h in distribution
Jason Ish [Tue, 1 Oct 2024 17:43:33 +0000 (11:43 -0600)] 
ebpf: include llvm_bpfload.h in distribution

Otherwise we fail to build ebpf from a release archive.

10 months agogithub-ci: cache deb packages on Ubuntu dist builder
Jason Ish [Tue, 1 Oct 2024 17:11:37 +0000 (11:11 -0600)] 
github-ci: cache deb packages on Ubuntu dist builder

Should speed up setup a little.

10 months agodetect/engine: deduplicate fn definitions 11858/head
Shivani Bhardwaj [Wed, 2 Oct 2024 07:07:34 +0000 (12:37 +0530)] 
detect/engine: deduplicate fn definitions

10 months agogithub-actions: bump actions/checkout from 4.1.7 to 4.2.0
dependabot[bot] [Tue, 1 Oct 2024 19:14:46 +0000 (19:14 +0000)] 
github-actions: bump actions/checkout from 4.1.7 to 4.2.0

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
10 months agogithub-actions: bump codecov/codecov-action from 4.5.0 to 4.6.0
dependabot[bot] [Tue, 1 Oct 2024 19:14:41 +0000 (19:14 +0000)] 
github-actions: bump codecov/codecov-action from 4.5.0 to 4.6.0

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/e28ff129e5465c2c0dcc6f003fc735cb6ae0c673...b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
10 months agogithub-actions: bump github/codeql-action from 3.26.6 to 3.26.10
dependabot[bot] [Tue, 1 Oct 2024 19:14:37 +0000 (19:14 +0000)] 
github-actions: bump github/codeql-action from 3.26.6 to 3.26.10

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.6 to 3.26.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.26.6...v3.26.10)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
10 months agoyaml: Add check of allocation for node object
Alexey Simakov [Mon, 23 Sep 2024 18:24:48 +0000 (21:24 +0300)] 
yaml: Add check of allocation for node object

Fix potential dereference of nullptr in case
of unsuccessful allocation of memory for
list node

Bug: #7270

10 months agoconfigure: clear cached header value
Liam Wilson [Wed, 25 Sep 2024 21:31:31 +0000 (09:31 +1200)] 
configure: clear cached header value

Unset ac_cv_header_hs_h before checking for header. This allows
hyperscan to be included in compilation when switching from a non-hs
build to a hs build.

10 months agothreads: don't drop capabilities for packet threads
Jason Ish [Thu, 26 Sep 2024 17:08:57 +0000 (11:08 -0600)] 
threads: don't drop capabilities for packet threads

Remove the call to SCDropCaps for packet processing threads. This
logic in this function is required to setup packet processing even
when the thread is provided by a library user, in which case Suricata
should not be touching is capabilities.

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

Related ticket: https://redmine.openinfosecfoundation.org/issues/2375

10 months agodetect: pseudo-packets inherit inspect flags from parent packet
Ilya Bakhtin [Sat, 31 Aug 2024 11:44:25 +0000 (13:44 +0200)] 
detect: pseudo-packets inherit inspect flags from parent packet

Instead of inheriting from flow, because encrypted protocols like TLS
and SSH may have just set the flow flags to indicate rest of stream is
encrypted and does not need to run stream inspection. But inspection
still needs to be run detection on this last flushing packet.

Ticket: #7235.

10 months agoutil/hash: use randomized hash algorithm
Philippe Antoine [Sun, 22 Sep 2024 19:38:50 +0000 (21:38 +0200)] 
util/hash: use randomized hash algorithm

For datasets and http ranges

Ticket: 7209

Prevents abusive hash collisions from known djb2 algorithm

10 months agohttp: have a headers limit
Philippe Antoine [Mon, 9 Sep 2024 07:34:39 +0000 (09:34 +0200)] 
http: have a headers limit

Ticket: 7191

So as to avoid quadratic complexity in libhtp.
Make the limit configurable from suricata.yaml,
and have an event when network traffic goes over the limit.

10 months agoja4: handles non alphanumeric alpn
Philippe Antoine [Mon, 23 Sep 2024 09:30:19 +0000 (11:30 +0200)] 
ja4: handles non alphanumeric alpn

Ticket: 7267

Follows more closely the specification :
https://github.com/FoxIO-LLC/ja4/blob/main/technical_details/JA4.md#alpn-extension-value

Also fixes the case with a single-char alpn.

10 months agodefrag: fix off by one
Philippe Antoine [Mon, 15 Jul 2024 07:52:00 +0000 (09:52 +0200)] 
defrag: fix off by one

Ticket: 7067

This off by one could lead to an empty fragment being inserted
in the rb tree, which led to integer underflow

10 months agostream: improve 3whs completed by ACK with data 11829/head
Victor Julien [Fri, 20 Sep 2024 07:54:57 +0000 (09:54 +0200)] 
stream: improve 3whs completed by ACK with data

If the ACK packet completing the 3whs is received, the stream engine will
transition to "established". However, the packet itself will not be tagged
as "established". This will only happen for the next packet after the 3whs,
so that `flow:established` only matches after the 3whs.

It is possible that the ACK packet completing the 3whs was lost. Since the
ACK packets themselves are not acknowledged, there will be no retransmission
of them. Instead, the next packet can have the expected ACK flag as well as
data.

This case was mishandled in a subtle way. The stream engine state transition
was done correctly, as well as the data handling and app-layer updates.
However, the packet itself was not tagged as "established", which meant
that `flow:established` would not yet match.

This patch detects this case and tags the packet as established if ACK
with data is received that completes the 3whs.

Bug: #7264.

10 months agosip: use pure rust function
Philippe Antoine [Mon, 16 Sep 2024 18:50:48 +0000 (20:50 +0200)] 
sip: use pure rust function

For internal function that is not part of C FFI

10 months agodetect/dataset: abort only in debug mode 11823/head
Philippe Antoine [Tue, 13 Aug 2024 14:53:53 +0000 (16:53 +0200)] 
detect/dataset: abort only in debug mode

Ticket: 7195

10 months agodetect/datasets: implement unset command
Philippe Antoine [Mon, 12 Aug 2024 07:54:43 +0000 (09:54 +0200)] 
detect/datasets: implement unset command

Ticket: 7195

Otherwise, Suricata aborted on such a rule

10 months agodatasets: restrict scope of macro/enum
Philippe Antoine [Thu, 1 Aug 2024 18:50:28 +0000 (20:50 +0200)] 
datasets: restrict scope of macro/enum

10 months agossl/ja3: better check for ja3 being enabled
Philippe Antoine [Mon, 23 Sep 2024 12:03:04 +0000 (14:03 +0200)] 
ssl/ja3: better check for ja3 being enabled

Ticket: 6634

Completes commit 84735251b577a284af3795708786974fd30720b0

Avoids error log in Ja3BufferAddValue about NULL buffer

10 months agostream/reassembly: optimize GetBlock
Noah Liu [Mon, 23 Sep 2024 03:07:47 +0000 (11:07 +0800)] 
stream/reassembly: optimize GetBlock

Current GetBlock degrees the sbb search from rb tree to
line, which costs much cpu time, and could be replaced by
SBB_RB_FIND_INCLUSIVE. It reduces time complexity from
O(nlogn) to O(logn).

Ticket: 7208.

10 months agodocs: remove mentions to Suricata-6
Juliana Fajardini [Fri, 20 Sep 2024 18:43:51 +0000 (15:43 -0300)] 
docs: remove mentions to Suricata-6

Task #7262

10 months agodoc/conf/yaml: replace underscore with dashes
Juliana Fajardini [Tue, 17 Sep 2024 18:50:37 +0000 (15:50 -0300)] 
doc/conf/yaml: replace underscore with dashes

Use sed + regex to replace all occurrences of suricata.yaml terms that
used underscore for their up-to-date dash version.

Also search for such terms in the eve-log.yaml partials file, as that
is referenced in the configuration section.

commands used:

sed -i 's/\(^ *[a-z]*\)_\([a-z]*:\)/\1-\2/g'
sed -i 's/\(^ *[a-z]*\)_\([a-z]*\)_\([a-z]*:\)/\1-\2-\3/g'

Some other instances were found manually.

Task #7260

10 months agodetect/base64: minor cleanups
Shivani Bhardwaj [Tue, 23 Jul 2024 11:22:35 +0000 (16:52 +0530)] 
detect/base64: minor cleanups

1. decode_len can be u32 as it stores min of two u32s.
2. Add defensive check for payload_len calculation underflow.

10 months agotransform/base64: add explicit mode to test
Shivani Bhardwaj [Thu, 11 Jul 2024 07:58:21 +0000 (13:28 +0530)] 
transform/base64: add explicit mode to test

Without any mode setting, the test would take up the mode to be 0 which
used to be the relax mode for base64 decoder in C. However, there was no
code corresponding to that mode and it was never used so nothing
happened when this test was run.

Add an explicit strict mode as per the expectation of the test from its
comments.

10 months agorust/base64: add decoder
Shivani Bhardwaj [Wed, 10 Jul 2024 11:20:09 +0000 (16:50 +0530)] 
rust/base64: add decoder

Add a pure rust base64 decoder. This supports 3 modes of operation just
like the C decoder as follows.
1. RFC 2045
2. RFC 4648
3. Strict

One notable change is that "strict" mode is carried out by the rust
base64 crate instead of native Rust. This crate was already used for
encoding in a few places like datasets of string type. As a part of this
mode, now, only the strings that can be reliably converted back are
decoded.

The decoder fn is available to C via FFI.

Bug 6280
Ticket 7065
Ticket 7058

10 months agodoc/rfb: mention accidental fix for security_result log 11809/head
Philippe Antoine [Fri, 16 Aug 2024 14:53:54 +0000 (16:53 +0200)] 
doc/rfb: mention accidental fix for security_result log

Ticket: 7198

10 months agodoc: add new sip keywords
Giuseppe Longo [Thu, 18 Apr 2024 13:31:55 +0000 (15:31 +0200)] 
doc: add new sip keywords

10 months agosip: add sip.content_length sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 12:25:39 +0000 (14:25 +0200)] 
sip: add sip.content_length sticky buffer

This adds a sticky (multi) buffer to match the "Content-Length" header field in
both requests and responses.

Ticket #6374

10 months agosip: add sip.content_type sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 12:21:11 +0000 (14:21 +0200)] 
sip: add sip.content_type sticky buffer

This adds a sticky (multi) buffer to match the "Content-Type" header field in
both requests and responses.

Ticket #6374

10 months agosip: add sip.user_agent sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 12:17:06 +0000 (14:17 +0200)] 
sip: add sip.user_agent sticky buffer

This adds a sticky (multi) buffer to match the "User-Agent" header field in
both requests and responses.

Ticket #6374

10 months agosip: add sip.via sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 12:11:11 +0000 (14:11 +0200)] 
sip: add sip.via sticky buffer

This adds a sticky (multi) buffer to match the "Via" header field in
both requests and responses.

Ticket #6374

10 months agosip: add sip.to sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 12:06:00 +0000 (14:06 +0200)] 
sip: add sip.to sticky buffer

This adds a sticky (multi) buffer to match the 'To' header field in
both requests and responses.

Ticket #6374

10 months agosip: add sip.from sticky buffer
Giuseppe Longo [Sat, 10 Aug 2024 11:52:07 +0000 (13:52 +0200)] 
sip: add sip.from sticky buffer

This adds a sticky (multi) buffer to match the "From" header field
in both requests and responses.

Ticket #6374

10 months agorust/sip: store response headers
Giuseppe Longo [Fri, 15 Sep 2023 07:23:54 +0000 (09:23 +0200)] 
rust/sip: store response headers

To match on response SIP headers, those headers must be stored.

Ticket #6374

10 months agorust/sip: store multiple header values
Giuseppe Longo [Wed, 19 Jun 2024 12:26:50 +0000 (14:26 +0200)] 
rust/sip: store multiple header values

According to RFC 3261, a single header can be repeated one or more times,
and its name can also be specified using the 'compact form.'

This patch updates the hashmap used for storing headers to accommodate multiple
values instead of just one.

Additionally, if a header name is defined in the compact form, it is expanded
into its long form (i.e., the standard name).

This conversion simplifies the logic for matching a given header
and ensures 1:1 parity with keywords.

Ticket #6374

10 months agosip: rustify sticky buffers
Giuseppe Longo [Sat, 10 Aug 2024 10:26:55 +0000 (12:26 +0200)] 
sip: rustify sticky buffers

Ticket #7204

10 months agodetect: Clear errno before strtoul
Jeff Lucovsky [Tue, 9 Jul 2024 13:39:17 +0000 (09:39 -0400)] 
detect: Clear errno before strtoul

Per the notes for strtoul, since 0 or ULONG_MAX is a legitimate return
value, errno must be cleared before the call so an error can be checked
after the call by testing errno.

Issue: 7126

10 months agosmtp: Prevent error messages on packet path
Jeff Lucovsky [Sun, 7 Jul 2024 14:29:00 +0000 (10:29 -0400)] 
smtp: Prevent error messages on packet path

Issue: 7126

This commit abandons the use of StringParseUint32 which generates an
error message of there are non-numeric characters.

The SMTP parser had used this function on the packet path; this commit
uses strtoul instead.

An example of the content causing the error message to be emitted:

    3460 LAST

10 months agopgsql: trigger raw stream reassembly at tx completion 11804/head
Juliana Fajardini [Wed, 17 Jul 2024 20:22:04 +0000 (17:22 -0300)] 
pgsql: trigger raw stream reassembly at tx completion

Once we are tracking tx progress per-direction for PGSQL, we can trigger
the raw stream reassembly, for detection purposes, as soon as the
transactions are completed in the given direction.

Task #7000

10 months agopgsql: track transaction progress per direction
Juliana Fajardini [Thu, 29 Aug 2024 21:02:15 +0000 (18:02 -0300)] 
pgsql: track transaction progress per direction

PGSQL's current implementation tracks the transaction progress without
taking into consideration flow direction, and also has indirections
that make it harder to understand how the progress is tracked, as well
as when a request or response is actually complete.

This patch introduces tracking such progress per direction and adds
completion status per direction, too. This will help when triggering
raw stream reassembly or for unidirectional transactions, and may be
useful when we implement sub-protocols that can have multiple requests
per transaction, as well.

CancelRequests and TerminationRequests are examples of unidirectional
transactions. There won't be any responses to those requests, so we can
also mark the response side as done, and set their transactions as
completed.

Bug #7113

10 months agopgsql: use new API style for extern C functions
Juliana Fajardini [Wed, 18 Sep 2024 21:04:56 +0000 (18:04 -0300)] 
pgsql: use new API style for extern C functions

10 months agopgsql: order StateProgress enum per direction
Juliana Fajardini [Wed, 28 Aug 2024 20:15:01 +0000 (17:15 -0300)] 
pgsql: order StateProgress enum per direction

Related to
Bug #7113

10 months agopgsql: apply rust fmt changes
Juliana Fajardini [Wed, 11 Sep 2024 14:02:47 +0000 (11:02 -0300)] 
pgsql: apply rust fmt changes

10 months agodoc/configuration: improve emergency-recovery docs
Juliana Fajardini [Tue, 17 Sep 2024 18:50:37 +0000 (15:50 -0300)] 
doc/configuration: improve emergency-recovery docs

When removing mentions to `prune-flows` a few inconsistencies for how
we write and refer to `emergency-recovery` were left behind, still.

10 months agoeve/flow: turn error into debug assertion
Victor Julien [Wed, 18 Sep 2024 07:35:43 +0000 (09:35 +0200)] 
eve/flow: turn error into debug assertion

In case this hits logging an error is harmful, better to silently
continue.

Remove use of `default` to help the compiler flag new enum additions.

10 months agoeve/flow: log flow state directly
Victor Julien [Wed, 18 Sep 2024 07:34:10 +0000 (09:34 +0200)] 
eve/flow: log flow state directly

No need to first turn it into a flags field.

10 months agodetect: safety for app-layer logging of stream-only rules
Philippe Antoine [Fri, 31 May 2024 12:06:55 +0000 (14:06 +0200)] 
detect: safety for app-layer logging of stream-only rules

If a stream-only rule matches, and we find a tx where we
want to log the app-layer data, store into the tx data that
we already logged, so that we do not log again the app-layer metadata

Ticket: 7085

10 months agodoc: add note about big endian for icmp_seq match
jason taylor [Tue, 3 Sep 2024 18:13:08 +0000 (14:13 -0400)] 
doc: add note about big endian for icmp_seq match

10 months agodoc/configuration: remove mention to prune-flows 11792/head
Juliana Fajardini [Tue, 17 Sep 2024 18:50:37 +0000 (15:50 -0300)] 
doc/configuration: remove mention to prune-flows

Although the `prune-flows` option was removed with a5587fec2eb,
when documentation for the suricata.yaml config file was added with
b252b0d, this option was also included - as has remained until now.

10 months agoci: mov from cifuzz to clusterfuzzlite
Philippe Antoine [Tue, 10 Sep 2024 12:10:30 +0000 (14:10 +0200)] 
ci: mov from cifuzz to clusterfuzzlite

To better support main7 CI fuzzing

Ticket: 7253

10 months agooutput/json: Remove unneeded parameters
Jeff Lucovsky [Sat, 24 Aug 2024 13:02:53 +0000 (09:02 -0400)] 
output/json: Remove unneeded parameters

Issue: 4974

Remove unused parameters in output path for
- AlertJsonMetadata
- AlertJsonHeader

10 months agoconfig: Update reference keys
Jeff Lucovsky [Mon, 10 Jun 2024 20:04:38 +0000 (16:04 -0400)] 
config: Update reference keys

Issue: 4974

1. Use https instead of http everywhere
2. Organize and annotate references by
    - Referenced by ET/Open and ET/Pro
        - URL resolves and works as intended (to provide supplemental
          information regarding a reference value, e.g., bug id, cve
          value)
        - URL no longer resolves
        - URL resolves but doesn't work as intended (to provide
          supplemental information)
    - Not referenced by ET/Open nor ET/Pro
        - URL resolves and works as intended (to provide supplemental
          information regarding a reference value, e.g., bug id, cve
          value)
        - URL no longer resolves
        - URL resolves but doesn't work as intended (to provide
          supplemental information)

10 months agodoc: Document reference config setting
Jeff Lucovsky [Tue, 30 Apr 2024 17:11:50 +0000 (13:11 -0400)] 
doc: Document reference config setting

Issue: 4974

10 months agoalert/reference: Optionally add reference(s)
Jeff Lucovsky [Sat, 27 Apr 2024 13:55:38 +0000 (09:55 -0400)] 
alert/reference: Optionally add reference(s)

Issue: 4974

Optionally include rule references with the alert. Since there can be
multiple reference keywords, they are collected into an array.

10 months agorust: pin serde version 11768/head
Philippe Antoine [Tue, 10 Sep 2024 08:17:16 +0000 (10:17 +0200)] 
rust: pin serde version

because oss-fuzz does not support newer rust nightly
and newer serde does not support oss-fuzz old nightly

10 months agolua: use lua from crates.io rather than github
Jason Ish [Mon, 12 Aug 2024 22:00:23 +0000 (16:00 -0600)] 
lua: use lua from crates.io rather than github

This allows the source override in .cargo/config.toml to apply to the
suricata-lua-sys crate as well fixing offline builds.

Ticket: #7226

10 months agodcerpc: return error on invalid header
Shivani Bhardwaj [Fri, 21 Jul 2023 13:52:45 +0000 (19:22 +0530)] 
dcerpc: return error on invalid header

DCERPC/TCP tends to return the same values for invalid and incomplete
headers. As a result of this, invalid headers and any traffic following
it is buffered and processed later on assumed to be valid DCERPC traffic.
Fix this by clearly defining error and incomplete data and taking
appropriate actions.

Bug 7230

10 months agorunmode: fix coverity warning 11755/head
Philippe Antoine [Tue, 10 Sep 2024 07:24:59 +0000 (09:24 +0200)] 
runmode: fix coverity warning

CID 1619284:  Memory - illegal accesses  (OVERRUN)

In ParseAFXDPConfig, a pointer to bool is cast into a pointer
to int.

Also removing the cast pattern when useless

10 months agorust/detect: fix too_long_first_doc_paragraph clippy warning
Philippe Antoine [Mon, 9 Sep 2024 09:09:52 +0000 (11:09 +0200)] 
rust/detect: fix too_long_first_doc_paragraph clippy warning

warning: first doc comment paragraph is too long
  --> src/detect/iprep.rs:57:1
   |
57 | / /// value matching is done use `DetectUintData` logic.
58 | | /// isset matching is done using special `DetectUintData` value ">= 0"
59 | | /// isnotset matching bypasses `DetectUintData` and is handled directly
60 | | /// in the match function (in C).
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
   = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line

10 months agorust/dcerpc: fix single_match clippy warning
Philippe Antoine [Mon, 9 Sep 2024 09:09:18 +0000 (11:09 +0200)] 
rust/dcerpc: fix single_match clippy warning

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/dcerpc/log.rs:36:33
   |
36 |               DCERPC_TYPE_BIND => match &state.bind {
   |  _________________________________^
37 | |                 Some(bind) => {
38 | |                     jsb.open_array("interfaces")?;
39 | |                     for uuid in &bind.uuid_list {
...  |
51 | |                 None => {}
52 | |             },
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default

10 months agoframes: do not rely on FRAME_STREAM_ID
Philippe Antoine [Wed, 14 Aug 2024 14:17:36 +0000 (16:17 +0200)] 
frames: do not rely on FRAME_STREAM_ID

As it is not always the first frame to be created :
if it is not enabled, it does not get created, and other enabled
frames may be created first. see use of FrameConfigTypeIsEnabled

This resulted that this other frame got its length updated
on stream end, which led to false positives.

Resorting on FRAME_STREAM_TYPE is more consistent.

Ticket: 7213

10 months agohttp2: add frames support
Philippe Antoine [Wed, 14 Aug 2024 12:14:11 +0000 (14:14 +0200)] 
http2: add frames support

Ticket: 5743

Why ? To add detection capabilities

10 months agodcerpc: don't reuse completed tx
Victor Julien [Wed, 31 Jul 2024 11:58:29 +0000 (13:58 +0200)] 
dcerpc: don't reuse completed tx

In the DCERPC over TCP pcap, logging and rule matching is disrupted by adding a simple rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )

Works: alert + 3 dcerpc records.

But when adding a trivial rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )
        alert tcp any any -> any any (dsize:3; sid:2; rev:1; )

The alert for sid:1 disappears and also there is one dcerpc event less.

In the single rule case we can aggressively free the transactions, as there
is only an sgh in the toserver direction.

This means that when we encounter the 2nd REQUEST, the first 2 transactions
have already been processed and freed. So for the 2nd REQUEST we open a new
TX and run inspection and logging on it.

When the 2nd rule is added, it adds toclient sgh as well. This means that we
will now slightly delay the freeing of the transactions.

As a consequence we still have the TX for the first REQUEST when the 2nd REQUEST
is parsed. This leads to the 2nd REQUEST re-using the TX. Since the TX is
already marked as inspected, it means the toserver rule now no longer matches.
Also we're not logging this TX correctly now.

This commit fixes the issue by not "finding" a TX that as already been
marked complete in the search direction.

Bug #7187.

10 months agodetect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN 11732/head
Victor Julien [Fri, 6 Sep 2024 11:14:48 +0000 (13:14 +0200)] 
detect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN

The `app-layer-protocol` keyword inconsistently checks whether the
alproto is ALPROTO_UNKNOWN. In the regular match function it isn't
checked, in the prefilter function its checked for all but the "either"
mode.

This leads to false positives for negated matching, as an expression
like "!tls" will match if checked against ALPROTO_UNKNOWN.

This patch adds the checking everywhere. The keyword returns no match as
long as the alproto is ALPROTO_UNKNOWN.

Bug: #7241.

10 months agotls/ja3: do not append to ja3 str once ja3 hash is computed
Philippe Antoine [Tue, 3 Sep 2024 13:37:00 +0000 (15:37 +0200)] 
tls/ja3: do not append to ja3 str once ja3 hash is computed

Ticket: 6634

That means take only the first client hello into account.
This way, we do not end with ja3 string with 9 commas...

10 months agorust/base64: upgrade crate to latest
Shivani Bhardwaj [Thu, 29 Aug 2024 08:08:57 +0000 (13:38 +0530)] 
rust/base64: upgrade crate to latest

base64 crate is updated to the latest version 0.22.1. This came with
several API changes which are applied to the code. The old calls have
been replaced with the newer calls.

This was done following the availability of better fns to directly
decode into slices/vectors as needed and also that previous version was
too old.
Along with this change, update the Cargo.lock.in to reflect all changes
in the package versions.

Task 7219

10 months agorust: update Cargo.lock.in
Shivani Bhardwaj [Mon, 2 Sep 2024 05:35:38 +0000 (11:05 +0530)] 
rust: update Cargo.lock.in

to include the latest packages available.

10 months agogithub-actions: bump github/codeql-action from 3.25.15 to 3.26.6
dependabot[bot] [Sun, 1 Sep 2024 19:04:52 +0000 (19:04 +0000)] 
github-actions: bump github/codeql-action from 3.25.15 to 3.26.6

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.15 to 3.26.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.25.15...v3.26.6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
10 months agogithub-actions: bump actions/upload-artifact from 4.3.4 to 4.4.0
dependabot[bot] [Sun, 1 Sep 2024 19:04:34 +0000 (19:04 +0000)] 
github-actions: bump actions/upload-artifact from 4.3.4 to 4.4.0

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.4.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/0b2256b8c012f0828dc542b3febcab082c67f72b...50769540e7f4bd5e21e526ee35c689e35e0d6874)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
11 months agooutput-filedata: rename and document registration function 11689/head
Jason Ish [Fri, 30 Aug 2024 19:19:49 +0000 (13:19 -0600)] 
output-filedata: rename and document registration function

Prefix registration function and pointer function type with SC, as
well as document.

Ticket: #7227

11 months agooutput-file: rename and document registration function
Jason Ish [Fri, 30 Aug 2024 19:11:30 +0000 (13:11 -0600)] 
output-file: rename and document registration function

Rename OutputRegisterFileLogger to SCOutputRegisterFileLogger, add
function documentation and include in userguide.

Ticket: #7227

11 months agooutput-streaming: rename and document registration
Jason Ish [Fri, 30 Aug 2024 18:54:28 +0000 (12:54 -0600)] 
output-streaming: rename and document registration

Prefix the registration function and types with "SC", and add function
documentation.

Ticket: #7227

11 months agooutput-file: use void *initdata instead of OutputCtx
Jason Ish [Fri, 30 Aug 2024 15:00:59 +0000 (09:00 -0600)] 
output-file: use void *initdata instead of OutputCtx

Avoids leaking a higher level abstraction into a low level logger.

Ticket: #7227

11 months agooutput-filedata: use void *initdata instead of OutputCtx
Jason Ish [Fri, 30 Aug 2024 14:58:58 +0000 (08:58 -0600)] 
output-filedata: use void *initdata instead of OutputCtx

Avoids leaking a higher level abstraction into a low level logger.

Ticket: #7227

11 months agooutput-streaming: use void *initdata instead of OutputCtx
Jason Ish [Fri, 30 Aug 2024 14:56:39 +0000 (08:56 -0600)] 
output-streaming: use void *initdata instead of OutputCtx

Using OutputCtx leaks a higher level abstraction into the low level
logger.

Ticket: #7227

11 months agooutput: remove remaining ThreadExitPrintStats callbacks
Jason Ish [Fri, 30 Aug 2024 14:11:07 +0000 (08:11 -0600)] 
output: remove remaining ThreadExitPrintStats callbacks

Not used in output modules.

Ticket: #7227

11 months agooutput-stats: remove ThreadExitPrintStats callback
Jason Ish [Fri, 30 Aug 2024 13:52:36 +0000 (07:52 -0600)] 
output-stats: remove ThreadExitPrintStats callback

Not used.

Ticket: #7227

11 months agooutput-streaming: remove ThreadExitPrintStats callback
Jason Ish [Fri, 30 Aug 2024 13:50:59 +0000 (07:50 -0600)] 
output-streaming: remove ThreadExitPrintStats callback

Not used.

Ticket: #7227

11 months agooutput-filedata: remove ThreadExitPrintStats callback
Jason Ish [Fri, 30 Aug 2024 13:45:33 +0000 (07:45 -0600)] 
output-filedata: remove ThreadExitPrintStats callback

Not used.

Ticket: #7227

11 months agooutput-file: remove ThreadExitPrintStats callback
Jason Ish [Fri, 30 Aug 2024 13:39:51 +0000 (07:39 -0600)] 
output-file: remove ThreadExitPrintStats callback

Not used.

Ticket: #7227

11 months agooutput-tx: rename and document transaction logger registration
Jason Ish [Thu, 29 Aug 2024 22:55:57 +0000 (16:55 -0600)] 
output-tx: rename and document transaction logger registration

Rename OutputRegisterTxLogger to SCOutputRegisterTxLogger to make it
part of the public API as well as document.

Ticket: #7227

11 months agooutput-tx.h: include tm-threads.h
Jason Ish [Thu, 29 Aug 2024 22:44:33 +0000 (16:44 -0600)] 
output-tx.h: include tm-threads.h

Required to properly resolve the types in the header without depending
on includes coming before it in C files.

Ticket: #7227

11 months agoexamples: add tx logger to custom logger example
Jason Ish [Thu, 29 Aug 2024 22:33:03 +0000 (16:33 -0600)] 
examples: add tx logger to custom logger example

However, its disabled due to issue
https://redmine.openinfosecfoundation.org/issues/7236.

Ticket: #7227

11 months agooutput-tx: remove ThreadExitPrintStats callback
Jason Ish [Thu, 29 Aug 2024 20:49:53 +0000 (14:49 -0600)] 
output-tx: remove ThreadExitPrintStats callback

After removing the exit stats function from log-tlslog, this callback
is no longer used.

Ticket: #7227

11 months agolog-tlslog: remove unneeded includes
Jason Ish [Thu, 29 Aug 2024 20:39:54 +0000 (14:39 -0600)] 
log-tlslog: remove unneeded includes

Ticket: #7227

11 months agolog-tlslog: remove ThreadExitPrintStats callback
Jason Ish [Thu, 29 Aug 2024 20:35:50 +0000 (14:35 -0600)] 
log-tlslog: remove ThreadExitPrintStats callback

Remove the ThreadExitPrintStats callback, this is the only logger that
was actually using it, and this logger is marked for deprecation. This
allows us to remove the callback from the registration signature.

Ticket: #7227

11 months agotlsstore: remove ThreadExitPrintStats callback
Jason Ish [Thu, 29 Aug 2024 20:33:42 +0000 (14:33 -0600)] 
tlsstore: remove ThreadExitPrintStats callback

Remove the callback to print stats on thread exit.  The counter value
was never being used and this helps us get rid of this callback
altogether as their is only one other usage of it.

Ticket: #7227

11 months agooutput-tx: use void * instead of OutputCtx
Jason Ish [Wed, 28 Aug 2024 23:17:50 +0000 (17:17 -0600)] 
output-tx: use void * instead of OutputCtx

Using OutputCtx results in the low level output-tx packet logger being
aware of Suricata's higher level loggers that use OutputCtx, for the
low level logger this is purely opaque data that may not be an
OutputCtx for custom loggers.

Ticket: #7227

11 months agodevguide: more on low level logging
Jason Ish [Tue, 27 Aug 2024 23:02:41 +0000 (17:02 -0600)] 
devguide: more on low level logging

Use the extending/output section to introduce the low level logging
API.

Ticket: #7227

11 months agooutput-flow: rename register function and document
Jason Ish [Tue, 27 Aug 2024 22:41:34 +0000 (16:41 -0600)] 
output-flow: rename register function and document

Rename OutputRegisterFlowLogger to SCOutputRegisterFlowLogger and
document in the header file.

Mark other functions in the header file as part of the internal API.

Ticket: #7227

11 months agooutput-packet: rename register function and document
Jason Ish [Tue, 27 Aug 2024 22:33:58 +0000 (16:33 -0600)] 
output-packet: rename register function and document

Rename OutputRegisterPacketLogger to SCOutputRegisterPacketLogger as
its part of the public API and document its parameters.

Comment on the other functions in the header that they are part of the
internal API.

Ticket: #7227

11 months agopacket-logger: remove ThreadExitPrintStats
Jason Ish [Tue, 27 Aug 2024 22:18:55 +0000 (16:18 -0600)] 
packet-logger: remove ThreadExitPrintStats

The ThreadExitPrintStats callback was never being used, remove.

Ticket: #7227