]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
3 months agogithub-ci: update to Fedora 42 13080/head
Victor Julien [Wed, 23 Apr 2025 08:23:43 +0000 (10:23 +0200)] 
github-ci: update to Fedora 42

3 months agoapp-layer: remove obsolete NULL check 13079/head
Philippe Antoine [Tue, 22 Apr 2025 19:15:53 +0000 (21:15 +0200)] 
app-layer: remove obsolete NULL check

Completes commit 833a738dd1429f63c79d95edf25bb86fcc15b51a

Fixes coverity 1646610

3 months agodoc/userguide: document that lua dns rules need hooks
Jason Ish [Tue, 22 Apr 2025 16:43:12 +0000 (10:43 -0600)] 
doc/userguide: document that lua dns rules need hooks

And remove the old "keywords" that a lua Rule can register with for
DNS.

3 months agolua: fix fast.lua example
Jason Ish [Thu, 10 Apr 2025 22:52:40 +0000 (16:52 -0600)] 
lua: fix fast.lua example

This one is a little different as it logs to a file, and is the same
fast.lua used in the new Suricata-Verify test.

Ticket: #7656

3 months agolua: add suricata.rule library
Jason Ish [Wed, 9 Apr 2025 21:19:29 +0000 (15:19 -0600)] 
lua: add suricata.rule library

Add a "suricata.rule" library for accessing rule information from a
Lua rule, or a Lua output script.

This lib replaces the following global Lua functions:
- SCRuleIds
- SCRuleAction
- SCRuleMsg
- SCRuleClass

Ticket: #7490

3 months agodoc/lua/dns: fix typo
Jason Ish [Thu, 10 Apr 2025 22:08:08 +0000 (16:08 -0600)] 
doc/lua/dns: fix typo

3 months agorust: use pure rust helper for registering sticky buffers
Philippe Antoine [Mon, 21 Apr 2025 19:54:48 +0000 (21:54 +0200)] 
rust: use pure rust helper for registering sticky buffers

Mark sdp and sip keywords with flags SIGMATCH_INFO_STICKY_BUFFER
as a side effect.

3 months agoplugin: applayer: do not use suricata JsonError
Philippe Antoine [Sat, 19 Apr 2025 18:57:18 +0000 (20:57 +0200)] 
plugin: applayer: do not use suricata JsonError

We do not need a specific error type

3 months agohttp: fail tx creation if we cannot allocate user data 13073/head
Philippe Antoine [Fri, 18 Apr 2025 19:16:29 +0000 (21:16 +0200)] 
http: fail tx creation if we cannot allocate user data

So, we always have a libhtp.rs htp_tx_t and a Suricata tx
with its AppLayerTxData

Thus AppLayerParserGetTxData cannot return NULL

Ticket: 5739

3 months agorust/htp: remove unused code
Philippe Antoine [Mon, 21 Apr 2025 19:21:06 +0000 (21:21 +0200)] 
rust/htp: remove unused code

3 months agowebsocket: fixes substraction 13064/head
Philippe Antoine [Mon, 21 Apr 2025 19:16:38 +0000 (21:16 +0200)] 
websocket: fixes substraction

Fixes: 16f74c68aaa9 ("websocket: use max window bits of 15")
3 months agogithub-ci: codecov llvm updates 13057/head
Victor Julien [Sun, 20 Apr 2025 13:58:51 +0000 (15:58 +0200)] 
github-ci: codecov llvm updates

Use LLVM 15 with Rust 1.67.1

3 months agogithub-ci: update codecov unittest job
Victor Julien [Sun, 20 Apr 2025 13:57:22 +0000 (15:57 +0200)] 
github-ci: update codecov unittest job

LLVM 19, rust 1.85.1 and Ubuntu 24.04.

3 months agodnp3: mark tx as updated when creating it 13054/head
Philippe Antoine [Sat, 19 Apr 2025 19:28:16 +0000 (21:28 +0200)] 
dnp3: mark tx as updated when creating it

Ticket: 7668

We should set updated_tx when allocating a dnp3 tx

3 months agoftp: mark tx as updated when creating it
Philippe Antoine [Sat, 19 Apr 2025 19:27:01 +0000 (21:27 +0200)] 
ftp: mark tx as updated when creating it

Ticket: 7668

We should set updated_tx when allocating a ftp tx

Was already done right for updated_tc

3 months agohttp1: always mark tx as updated on request/response start
Philippe Antoine [Sat, 19 Apr 2025 19:21:31 +0000 (21:21 +0200)] 
http1: always mark tx as updated on request/response start

Ticket: 7668

We should set updated_tx when allocating HtpTxUserData

3 months agodetect: rust helper to register sticky buffer 13053/head
Philippe Antoine [Mon, 17 Feb 2025 20:13:54 +0000 (21:13 +0100)] 
detect: rust helper to register sticky buffer

3 months agodetect: rename SCSigTableElmt to SCSigTableAppLiteElmt
Philippe Antoine [Mon, 17 Feb 2025 20:41:56 +0000 (21:41 +0100)] 
detect: rename SCSigTableElmt to SCSigTableAppLiteElmt

3 months agodetect: remove never set SIGMATCH_NOT_BUILT
Philippe Antoine [Wed, 5 Mar 2025 16:26:49 +0000 (17:26 +0100)] 
detect: remove never set SIGMATCH_NOT_BUILT

3 months agounittests: more realistic packet from UTHBuildPacketReal
Philippe Antoine [Thu, 6 Feb 2025 12:35:42 +0000 (13:35 +0100)] 
unittests: more realistic packet from UTHBuildPacketReal

So that its contents can be reused when translating unit tests
to SV tests

3 months agodetect/dns: support string for dns.rrtype
Philippe Antoine [Sun, 26 Jan 2025 14:46:34 +0000 (15:46 +0100)] 
detect/dns: support string for dns.rrtype

Ticket: 6723

3 months agodetect/dns: support string for dns.rcode
Philippe Antoine [Sun, 26 Jan 2025 14:35:24 +0000 (15:35 +0100)] 
detect/dns: support string for dns.rcode

Ticket: 6723

3 months agodetect/dns: move keywords to rust
Philippe Antoine [Sun, 26 Jan 2025 14:16:03 +0000 (15:16 +0100)] 
detect/dns: move keywords to rust

Ticket: 7529
Ticket: 3725

Adds url for dns.opcode on the way

3 months agodetect: new helper to register multi-buffer with progress
Philippe Antoine [Tue, 15 Apr 2025 19:08:01 +0000 (21:08 +0200)] 
detect: new helper to register multi-buffer with progress

This allows to use these engines for hook rules needing exact
progress (checked in SigValidate)

3 months agoci: rustc wrapper to disable coverage for external crates
Philippe Antoine [Tue, 15 Apr 2025 14:40:44 +0000 (16:40 +0200)] 
ci: rustc wrapper to disable coverage for external crates

To keep the disk usage good even when we use new crates

3 months agohttp1: brotli decompression
Philippe Antoine [Fri, 11 Apr 2025 19:56:19 +0000 (21:56 +0200)] 
http1: brotli decompression

Ticket: 5692

http2 already used brotli crate for decompression

3 months agooutput: fix leak in case of alloc error 13049/head
Philippe Antoine [Fri, 18 Apr 2025 13:17:58 +0000 (15:17 +0200)] 
output: fix leak in case of alloc error

CID: 1638290

3 months agodefrag: remove unnecessary NULL check
Philippe Antoine [Fri, 18 Apr 2025 12:52:30 +0000 (14:52 +0200)] 
defrag: remove unnecessary NULL check

CID: 727861

3 months agoutil/mpm: prevents double free
Philippe Antoine [Fri, 18 Apr 2025 12:38:48 +0000 (14:38 +0200)] 
util/mpm: prevents double free

CID: 1645545

PatternDatabaseGetCached frees cd on success
So, we should NULL it, so that in case PatternDatabaseGetSize fails
and we goto error, we do not free cd again.

3 months agodetect: explicitly skip check on SCConfGet
Philippe Antoine [Fri, 18 Apr 2025 12:32:27 +0000 (14:32 +0200)] 
detect: explicitly skip check on SCConfGet

CID: 1644571

3 months agodox/userguide: add tx_cnt documentation 13044/head
Eric Leblond [Sun, 30 Mar 2025 15:24:35 +0000 (17:24 +0200)] 
dox/userguide: add tx_cnt documentation

3 months agoeve/schema: remove duplicate fields
Eric Leblond [Sun, 30 Mar 2025 15:24:06 +0000 (17:24 +0200)] 
eve/schema: remove duplicate fields

3 months agoeve/flow: log tx_cnt
Eric Leblond [Mon, 20 Jan 2025 10:17:21 +0000 (11:17 +0100)] 
eve/flow: log tx_cnt

This patch adds a `tx_cnt` field to `netflow` events to give some
context about the underlying protocol activity.

Ticket: #7635

3 months agoeve/netflow: add tx_cnt
Eric Leblond [Fri, 24 Jan 2025 13:44:34 +0000 (14:44 +0100)] 
eve/netflow: add tx_cnt

This patch adds a `tx_cnt` field to `netflow` events to give some
context about the underlying protocol activity.

Ticket: #7635

3 months agoeve/smb: add tx_id to event
Eric Leblond [Wed, 19 Jan 2022 13:56:06 +0000 (14:56 +0100)] 
eve/smb: add tx_id to event

As SMB protocol is using heavily transactions, getting the transaction
ID in SMB events can be really useful for automated analysis.

3 months agowebsocket: use max window bits of 15
Philippe Antoine [Thu, 3 Apr 2025 08:49:38 +0000 (10:49 +0200)] 
websocket: use max window bits of 15

Ticket: 7285

As this is the default for websocket, which is bigger than the
defaut for zlib usage

Also limit the decompressed content to the max-payload-size
configuration parameter also used for non-compressed content.

And also use a stateful decoder to store/remember the compression
state to be able to decompress later messages.

3 months agorust: use flate2 with C zlib
Philippe Antoine [Thu, 3 Apr 2025 08:47:48 +0000 (10:47 +0200)] 
rust: use flate2 with C zlib

move flate2.rs to a backend supporting the setting
of window_bits, which is not the case for miniz-oxide.

This will allow WebSocket to use Sec-WebSocket-Extensions
which can set a non-default window_bits

3 months agowebsocket: decompress single pdu message
Philippe Antoine [Thu, 27 Mar 2025 21:33:30 +0000 (22:33 +0100)] 
websocket: decompress single pdu message

Ticket: 7285

Previously, only messages over multiple PDUs could get decompressed

3 months agooutput/rotate: Remove extra rotation flag register 13035/head
Jeff Lucovsky [Mon, 14 Apr 2025 20:07:24 +0000 (16:07 -0400)] 
output/rotate: Remove extra rotation flag register

Issue: 3436

Remove duplicate register of the rotation flag. Eventually, this will
cause corruption when the file context has been freed and the rotation
flag is deregistered.

3 months agooutput/rotate: Serialize rotation flag handling
Jeff Lucovsky [Mon, 14 Apr 2025 20:06:08 +0000 (16:06 -0400)] 
output/rotate: Serialize rotation flag handling

Issue: 3436

Serialize rotation flag handling to avoid corruption.

3 months agodetect: add email.received keyword
Alice Akaki [Wed, 9 Apr 2025 21:43:42 +0000 (17:43 -0400)] 
detect: add email.received keyword

email.received matches on MIME EMAIL Received
This keyword maps to the EVE field email.received[]
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7599

3 months agodoc: Update bypass docs to use new keyword format
James [Sun, 7 Jul 2024 17:43:02 +0000 (18:43 +0100)] 
doc: Update bypass docs to use new keyword format

Ticket: #7143

Update documentation to reflect new sticky buffer keyword format

3 months agodetect/app-layer-protocol: allow matching on 'unknown'
Victor Julien [Fri, 11 Apr 2025 14:59:05 +0000 (16:59 +0200)] 
detect/app-layer-protocol: allow matching on 'unknown'

3 months agofirewall: detect: set firewall support flag on select keywords
Victor Julien [Fri, 11 Apr 2025 08:22:20 +0000 (10:22 +0200)] 
firewall: detect: set firewall support flag on select keywords

3 months agofirewall: detect: add feature flag for keywords supporting firewall
Victor Julien [Fri, 11 Apr 2025 08:21:54 +0000 (10:21 +0200)] 
firewall: detect: add feature flag for keywords supporting firewall

3 months agofirewall: detect: set per rule table
Victor Julien [Fri, 11 Apr 2025 04:43:48 +0000 (06:43 +0200)] 
firewall: detect: set per rule table

For firewall mode, set the pseudo table in the rule and use this
in alert queue ordering, so that rule actions are applied in the
expected order:

        packet:filter -> packet:td -> app:filter -> app:td

This makes sure that a packet:td drop is applied before a app:filter
accept.

3 months agodetect: don't set conflicting packet/flow actions
Victor Julien [Fri, 11 Apr 2025 04:45:40 +0000 (06:45 +0200)] 
detect: don't set conflicting packet/flow actions

If for the same a packet a drop rule and a pass rule would match,
the applying of actions could be contradictionary:

- the drop would be applied to the packet
- the pass rule would also be considered, not overriding the drop,
  but still setting the flow pass flag.

This would lead to the packet being dropped, but the rest of the
flow getting passed, including retransmissions of the dropped
packet.

This patch only sets drop/pass actions if no conflicting action
has been set on the packet before. It respects the action-order.

Bug: #7653.

3 months agofirewall: detect: add explanation
Victor Julien [Fri, 11 Apr 2025 04:44:58 +0000 (06:44 +0200)] 
firewall: detect: add explanation

3 months agodetect/alert: minor cleanup
Victor Julien [Thu, 10 Apr 2025 08:16:51 +0000 (10:16 +0200)] 
detect/alert: minor cleanup

3 months agodetect: add email.url keyword 13016/head
Alice Akaki [Wed, 9 Apr 2025 19:10:43 +0000 (15:10 -0400)] 
detect: add email.url keyword

email.url matches on URLs extracted from an email
This keyword maps to the EVE field email.url[]
Supports multiple buffer matching
Supports prefiltering

Ticket: #7597

3 months agorust/htp: remove authors; fix homepage
Jason Ish [Wed, 9 Apr 2025 20:33:17 +0000 (14:33 -0600)] 
rust/htp: remove authors; fix homepage

Remove the authors field as it is deprecated.

Update the repository page to the Suricata repository.

Remove the homepage, it can be found via the reposistory page.

3 months agohtp: rename to suricata-htp; allow publishing to crates.io
Jason Ish [Wed, 9 Apr 2025 15:57:48 +0000 (09:57 -0600)] 
htp: rename to suricata-htp; allow publishing to crates.io

As the "suricata" crate depends on htp, we need to publish htp to
crates.io first, however "htp" name is already taken. So rename "htp" to
"suricata-htp".

3 months agosuricatactl: add description to Cargo.toml
Jason Ish [Wed, 9 Apr 2025 15:55:30 +0000 (09:55 -0600)] 
suricatactl: add description to Cargo.toml

For publishing to crates.io.

3 months agorust: always update Cargo.lock.in
Jason Ish [Thu, 10 Apr 2025 15:12:35 +0000 (09:12 -0600)] 
rust: always update Cargo.lock.in

On a normal project where the Cargo.lock is checked in, it would be
normal to see an updated Cargo.lock in git status and the like. As we
use autoconf to generate this file, we should just copy it back to the
input file so we get the same convenience of seeing when it is
updated, which usually means it needs to be checked in.

However, to satisfy "make distcheck", only copy it if the input
template exists, if the input template does not exist we are in an out
of tree build.

3 months agoworkflows: use aggressive-cleanup option w s-v
Shivani Bhardwaj [Thu, 10 Apr 2025 13:29:36 +0000 (18:59 +0530)] 
workflows: use aggressive-cleanup option w s-v

on the Fedora 41 + codecov job to avoid running out of disk space.

3 months agoconfigure: pickup pre-release versions from changelog
Jason Ish [Wed, 9 Apr 2025 15:15:38 +0000 (09:15 -0600)] 
configure: pickup pre-release versions from changelog

Pickup release versions like 8.0.0-beta1 and 8.0.0-rc1 from the
ChangeLog. This version is used in the generated documentation.

3 months agogithub-actions: f41 codecov improvements 12993/head 13003/head
Victor Julien [Tue, 8 Apr 2025 04:34:22 +0000 (06:34 +0200)] 
github-actions: f41 codecov improvements

Add missing gpg package.

Reduce disk space usage.

3 months agodetect/domain: move transform fully to rust
Victor Julien [Tue, 8 Apr 2025 18:19:36 +0000 (20:19 +0200)] 
detect/domain: move transform fully to rust

3 months agodetect/prefilter: fix coverity issue
Victor Julien [Tue, 8 Apr 2025 18:05:22 +0000 (20:05 +0200)] 
detect/prefilter: fix coverity issue

** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()

________________________________________________________________________________________________________
*** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()
938                 const DetectBufferType *buf = DetectEngineBufferTypeGetById(de_ctx, list_id);
939                 /* for now, exclude app-layer-events, as they are not tied to a specific
940                  * progress value like other keywords. */
941                 SCLogDebug("list_id %d buf %p", list_id, buf);
942                 if (list_id == app_events_list_id)
943                     continue;
>>>     CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing "buf", which is known to be "NULL".
944                 if (buf->packet) {
945                     SCLogDebug("packet buf");
946                     /* packet is handled below */
947                     pkt_non_pf = true;
948                 } else if (buf->frame) {
949                     for (DetectEngineFrameInspectionEngine *f = de_ctx->frame_inspect_engines;

3 months agolog-pcap: error out if malloc fails for bpf filter
Jason Ish [Tue, 8 Apr 2025 21:29:03 +0000 (15:29 -0600)] 
log-pcap: error out if malloc fails for bpf filter

3 months agodoc/userguide: type in pfring upgrade notes
Jason Ish [Tue, 8 Apr 2025 14:33:52 +0000 (08:33 -0600)] 
doc/userguide: type in pfring upgrade notes

3 months agoversion: start development towards 8.0.0-rc1
Jason Ish [Tue, 8 Apr 2025 21:21:13 +0000 (15:21 -0600)] 
version: start development towards 8.0.0-rc1

3 months agorelease: 8.0.0-beta1; update changelog suricata-8.0.0-beta1
Shivani Bhardwaj [Tue, 8 Apr 2025 12:36:59 +0000 (18:06 +0530)] 
release: 8.0.0-beta1; update changelog

3 months agolua: enable lua rules by default 12985/head 12986/head
Victor Julien [Tue, 8 Apr 2025 08:15:07 +0000 (10:15 +0200)] 
lua: enable lua rules by default

Now that sandboxing is in place, lua rule support is enabled by default.

3 months agodetect: add ldap.responses.attribute_type 12980/head
Alice Akaki [Sun, 2 Mar 2025 23:41:26 +0000 (19:41 -0400)] 
detect: add ldap.responses.attribute_type

ldap.responses.attribute_type matches on LDAP attribute type/description
This keyword maps the eve field ldap.responses[].search_result_entry.attributes[].type
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533

3 months agodetect: add ldap.request.attribute_type
Alice Akaki [Thu, 13 Feb 2025 05:18:37 +0000 (01:18 -0400)] 
detect: add ldap.request.attribute_type

ldap.request.attribute_type matches on LDAP attribute type/description
This keyword maps the following eve fields:
ldap.request.search_request.attributes[]
ldap.request.modify_request.changes[].modification.attribute_type
ldap.request.add_request.attributes[].name
ldap.request.compare_request.attribute_value_assertion.description
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533

3 months agorustfmt: rust/src/ldap/detect.rs
Alice Akaki [Fri, 4 Apr 2025 01:24:14 +0000 (21:24 -0400)] 
rustfmt: rust/src/ldap/detect.rs

3 months agoapp/ftp: Eliminate scan-build warning
Jeff Lucovsky [Fri, 28 Mar 2025 14:12:59 +0000 (10:12 -0400)] 
app/ftp: Eliminate scan-build warning

Scan-build reports that FTPRealloc could be called with size=0. Modify
the logic so it's never passed 0.

3 months agodoc/ftp: Document the ftp.reply keyword
Jeff Lucovsky [Fri, 28 Mar 2025 12:55:28 +0000 (08:55 -0400)] 
doc/ftp: Document the ftp.reply keyword

Issue: 7508

3 months agodetect/ftp: Add ftp.reply rule keyword
Jeff Lucovsky [Thu, 27 Mar 2025 14:30:47 +0000 (10:30 -0400)] 
detect/ftp: Add ftp.reply rule keyword

Issue: 7508

Add the rule detection keyword "ftp.reply". This is a multi-buffer
command.

3 months agoapp/ftp: Use Rust FTP response line handling
Jeff Lucovsky [Fri, 21 Mar 2025 14:01:27 +0000 (10:01 -0400)] 
app/ftp: Use Rust FTP response line handling

Use the Rust logic to parse FTP response lines with the goal to support
multi-buffer matches better.

A side effect is that the completion codes are no longer strings; the
schema update reflects this.

Issue: 4082

3 months agoapp/ftp: Move FTP response handling to rust
Jeff Lucovsky [Fri, 21 Mar 2025 13:57:38 +0000 (09:57 -0400)] 
app/ftp: Move FTP response handling to rust

Move handling of FTP responses to Rust to improve support for FTP
keyword matching. Parsing the response line when encountered
simplifies multi-buffer matching and metadata output.

Issue: 4082

3 months agouserguide/pop3: minor typo and formatting fixing
Juliana Fajardini [Mon, 7 Apr 2025 16:25:08 +0000 (09:25 -0700)] 
userguide/pop3: minor typo and formatting fixing

3 months agopop3: app-layer parser using sawp-pop3
Alex Savage [Mon, 24 Mar 2025 23:41:18 +0000 (23:41 +0000)] 
pop3: app-layer parser using sawp-pop3

This module uses the sawp-pop3 crate to parse POP3 requests and responses
Features:
- eve logging
- events for parsable but non-RFC-compliant messages

Ticket: 3243

3 months agodoc/userguide: doc domain and tld transforms
Eric Leblond [Mon, 31 Mar 2025 14:55:19 +0000 (16:55 +0200)] 
doc/userguide: doc domain and tld transforms

3 months agotld: add new transform
Eric Leblond [Wed, 24 Aug 2022 11:57:56 +0000 (13:57 +0200)] 
tld: add new transform

Extract the TLD from a buffer.

Ticket: #5639

3 months agodomain: add new transformation
Eric Leblond [Tue, 23 Aug 2022 14:44:23 +0000 (16:44 +0200)] 
domain: add new transformation

Ticket: #5639

3 months agoplugin: document app-layer plugins
Philippe Antoine [Fri, 17 Jan 2025 11:18:15 +0000 (12:18 +0100)] 
plugin: document app-layer plugins

Ticket: 7149
Ticket: 7150
Ticket: 7153

3 months agoplugin: add in-tree app-layer template plugin for testing
Philippe Antoine [Wed, 13 Nov 2024 10:07:03 +0000 (11:07 +0100)] 
plugin: add in-tree app-layer template plugin for testing

Ticket: 7151
Ticket: 7152
Ticket: 7154

3 months agorust: export jsonbuilder API in sys crate
Philippe Antoine [Wed, 2 Apr 2025 21:07:13 +0000 (23:07 +0200)] 
rust: export jsonbuilder API in sys crate

using cbindgen + bindgen

3 months agodoc/firewall: start of documentation
Victor Julien [Fri, 28 Mar 2025 14:14:28 +0000 (15:14 +0100)] 
doc/firewall: start of documentation

3 months agofirewall: beginning of ruleset analyzer
Victor Julien [Sat, 29 Mar 2025 07:21:46 +0000 (08:21 +0100)] 
firewall: beginning of ruleset analyzer

Output a `firewall.json` with a per table list of rules.

Also output a sorted list of the threat detection rules.

3 months agofirewall: start of firewall rules support
Victor Julien [Wed, 26 Feb 2025 10:38:35 +0000 (11:38 +0100)] 
firewall: start of firewall rules support

Config:

Firewall rules are like normal rule, with some key differences.

They are loaded separate, and first, from:

```yaml
firewall-rule-path: /etc/suricata/firewall/
firewall-rule-files:
  - fw.rules
```

Can also be loaded with --firewall-rules-exclusive: Mostly for QA purposes.

Allow -S with --firewall-rules-exclusive, so that firewall and threat detection
rules can be tested together.

Rules:

Differences with regular "threat detection" rules:

1. these rules are evaluated before threat detection rules

2. these rules are evaluated in the order as they appear in the rule file

3. currently only rules specifying an explicit hook at supported

   a. as a consequence, no rules will be treated as (like) IP-only, PD-only or
      DE-only

Require explicit action scope for firewall rules. Default policy is
drop for the firewall tables.

Actions:

New action "accept" is added to allow traffic in the filter tables.

New scope "accept:tx" is added to allow accepting a transaction.

Tables:

Rulesets are per table.

Table processing order: `packet:filter` -> `packet:td` -> `app:*:*` -> `app:td`.

Each of the tables has some unique properties:

`packet:filter`:
- default policy is `drop:packet`
- rules are process in order
- action scopes are explicit
- `drop` or `accept` is immediate
- `accept:hook` continues to `packet:td`

`packet:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `app:*:*` or `alert/action finalize`

`app:*:*`:
- default policy is `drop:flow`
- rules are process in order
- action scopes are explicit
- `drop` is immediate
- `accept` is conditional on possible `drop` from `packet:td`
- `accept:hook` continues to `app:td`, `accept:packet` or `accept:flow`
  continues to `alert/action finalize`

`app:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `alert/action finalize`

Implementation:

During sigorder, split into packet:filter, app:*:* and general td.

Allow fw rules to work when in pass:flow mode. When firewall mode is enabled,
`pass:flow` will not skip the detection engine anymore, but instead
process the firewall rules and then apply the pass before inspecting threat
detect rules.

3 months agodetect/xbits: implement tx bits
Victor Julien [Fri, 21 Mar 2025 08:42:09 +0000 (09:42 +0100)] 
detect/xbits: implement tx bits

Implement `xbits:set,mybit,track tx;` and `xbits:isset,mybit,track tx;`.

Store these in the AppLayerTxData.

Ticket: #6455.

3 months agoeve/alert: log ts_progress/tc_progress
Victor Julien [Mon, 17 Mar 2025 08:13:08 +0000 (09:13 +0100)] 
eve/alert: log ts_progress/tc_progress

This is mostly to help with debugging firewall rules, but
can be useful in other places.

3 months agodetect/app-layer-state: keyword for protocol state
Victor Julien [Fri, 14 Mar 2025 15:20:15 +0000 (16:20 +0100)] 
detect/app-layer-state: keyword for protocol state

Allow matching on the app-layer protocol state.

3 months agodetect/prefilter: allow special engine for each app update
Victor Julien [Fri, 14 Mar 2025 14:35:58 +0000 (15:35 +0100)] 
detect/prefilter: allow special engine for each app update

Allow registering the progress as -1, which means it will be invoked
each time the app prefilters are called.

3 months agodetect: start of pkt hooks
Victor Julien [Thu, 23 Jan 2025 15:11:30 +0000 (16:11 +0100)] 
detect: start of pkt hooks

New facility to allow a user to specify where to hook a rule
into the engine. This patch adds this for packets, adding two
hooks:

- `all`: to let a rule be evaluated by all rules
- `flow_start`: to have a rule be evaluated only for the first
  packet in both directions

Implemented by adding a hook flags field in the packet.

3 months agodetect/tls.version: allow using rule hook
Victor Julien [Mon, 31 Mar 2025 10:07:05 +0000 (12:07 +0200)] 
detect/tls.version: allow using rule hook

tls.version isn't hooked to a specific state by default. Allow it
to register at the rule hook.

3 months agodetect: explicit action scopes
Victor Julien [Thu, 3 Apr 2025 14:03:13 +0000 (16:03 +0200)] 
detect: explicit action scopes

For drop and pass allow setting the scope explicitly:

        drop:flow
        drop:packet

        pass:flow
        pass:packet

Ticket: #7481.

3 months agodetect/tls: more precise state registration for keywords
Victor Julien [Fri, 28 Feb 2025 08:28:10 +0000 (09:28 +0100)] 
detect/tls: more precise state registration for keywords

3 months agodetect: reuse hook based generic lists
Victor Julien [Mon, 20 Jan 2025 12:05:32 +0000 (13:05 +0100)] 
detect: reuse hook based generic lists

3 months agodetect/lua: use rule hook instead of init() 'needs' table
Victor Julien [Sun, 19 Jan 2025 09:54:41 +0000 (10:54 +0100)] 
detect/lua: use rule hook instead of init() 'needs' table

For registration of app-layer inspection, no longer use the 'needs'
table from the script, but instead use the rule hook setting.

Ticket: #4783.

3 months agodetect: introduce explicit hooks
Victor Julien [Tue, 14 Jan 2025 08:41:11 +0000 (09:41 +0100)] 
detect: introduce explicit hooks

Generic:
        <app_proto>:request_started and <app_proto>:response_started
        <app_proto>:request_complete and <app_proto>:response_complete

Per protocol, it uses the registered progress (state) values. E.g.

        tls:client_hello_done

A rule ruleset could be:

        pass tls:client_hello_done any any -> any any (tls.sni; content:"www.google.com"; sid:21; alert;)
        drop tls:client_hello_done any any -> any any (sid:22;)

The pass rule is evaluated when the client hello is parsed, and if it
doesn't match the drop rule will be evaluated.

Registers each generic lists as "<alproto>:<progress state>:generic"
(e.g. "tls:client_hello_done:generic").

Ticket: #7485.

3 months agohttp1: register progress state names
Victor Julien [Thu, 23 Jan 2025 10:05:48 +0000 (11:05 +0100)] 
http1: register progress state names

Use `request_started` for HTP_REQUEST_NOT_STARTED as when data is
received, the request parsing has started. The request line isn't
complete yet.

Similar for `response_started`.

3 months agotls: expose progress by name
Victor Julien [Fri, 17 Jan 2025 11:10:29 +0000 (12:10 +0100)] 
tls: expose progress by name

3 months agoapp-layer: API for mapping progress name vs id
Victor Julien [Fri, 17 Jan 2025 11:10:01 +0000 (12:10 +0100)] 
app-layer: API for mapping progress name vs id

3 months agotls: introduce per direction progress tracking
Victor Julien [Thu, 16 Jan 2025 11:32:40 +0000 (12:32 +0100)] 
tls: introduce per direction progress tracking

Per direction track progress to be able to have more fine grained
control over where the detection engines and logging hooks in.

3 months agodetect: allow longer buffer names
Victor Julien [Mon, 20 Jan 2025 08:05:04 +0000 (09:05 +0100)] 
detect: allow longer buffer names

To support hook based buffer names.

3 months agodetect: move non-pf rules into special prefilter engines
Victor Julien [Thu, 28 Dec 2023 21:11:56 +0000 (22:11 +0100)] 
detect: move non-pf rules into special prefilter engines

Instead of having a per detection engine list of rule that couldn't be
prefiltered, put those into special "prefilter" engines.

For packet and frame rules this doesn't change much, it just removes
some hard coded logic from the detect engine.

For the packet non-prefilter rules in the "non-prefilter" special prefilter
engine, add additional filtering for the packet variant. It can prefilter on
alproto, dsize and dest port.

The frame non-prefilter rules are added to a single engine, that per
rule checks the alproto and the type.

For app-layer, there is an engine per progress value, per app-layer
protocol and per direction. This hooks app-layer non-prefilter rules
into the app inspect logic at the correct "progress" hook.

e.g. a rule like
        dns.query; bsize:1;

Negated MPM rules will also fall into this category:
        dns.query; content:!"abc";

Are part of a special "generic list" app engine for dns, at the
same progress hook as `dns.query`.

This all results in a lot fewer checks:

previous:

  --------------------------------------------------------------------------
  Date: 1/29/2025 -- 10:22:25. Sorted by: number of checks.
  --------------------------------------------------------------------------
   Num      Rule         Gid      Rev      Ticks        %      Checks   Matches  Max Ticks   Avg Ticks   Avg Match   Avg No Match
  -------- ------------ -------- -------- ------------ ------ -------- -------- ----------- ----------- ----------- --------------
  1        20           1        0        181919672    11.85  588808   221      60454       308.96      2691.46     308.07
  2        50           1        0        223455914    14.56  453104   418      61634       493.17      3902.59     490.02
  3        60           1        0        185990683    12.12  453104   418      60950       410.48      1795.40     409.20
  4        51           1        0        192436011    12.54  427028   6084     61223       450.64      2749.12     417.42
  5        61           1        0        180401533    11.75  427028   6084     61093       422.46      2177.04     397.10
  6        70           1        0        153899099    10.03  369836   0        61282       416.13      0.00        416.13
  7        71           1        0        123389405    8.04   369836   12833    44921       333.63      2430.23     258.27
  8        41           1        0        63889876     4.16   155824   12568    39138       410.01      1981.97     272.10
  9        40           1        0        64149724     4.18   155818   210      39792       411.70      4349.57     406.38
  10       10           1        0        70848850     4.62   65558    0        39544       1080.70     0.00        1080.70
  11       11           1        0        94743878     6.17   65558    32214    60547       1445.19     2616.14     313.92

this commit:

  --------------------------------------------------------------------------
  Date: 1/29/2025 -- 10:15:46. Sorted by: number of checks.
  --------------------------------------------------------------------------
   Num      Rule         Gid      Rev      Ticks        %      Checks   Matches  Max Ticks   Avg Ticks   Avg Match   Avg No Match
  -------- ------------ -------- -------- ------------ ------ -------- -------- ----------- ----------- ----------- --------------
  1        50           1        0        138776766    19.23  95920    418      167584      1446.80     3953.11     1435.83
  2        60           1        0        97988084     13.58  95920    418      182817      1021.56     1953.63     1017.48
  3        51           1        0        105318318    14.60  69838    6084     65649       1508.04     2873.38     1377.74
  4        61           1        0        89571260     12.41  69838    6084     164632      1282.56     2208.41     1194.20
  5        11           1        0        91132809     12.63  32779    32214    373569      2780.22     2785.58     2474.45
  6        10           1        0        66095303     9.16   32779    0        56704       2016.39     0.00        2016.39
  7        70           1        0        48107573     6.67   12928    0        42832       3721.19     0.00        3721.19
  8        71           1        0        32308792     4.48   12928    12833    39565       2499.13     2510.05     1025.09
  9        41           1        0        25546837     3.54   12886    12470    41479       1982.53     1980.84     2033.05
  10       40           1        0        26069992     3.61   12886    210      38495       2023.13     4330.05     1984.91
  11       20           1        0        639025       0.09   221      221      14750       2891.52     2891.52     0.00