]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
2 years agopcap: improve pcap_breakloop support 8706/head
Victor Julien [Tue, 11 Apr 2023 09:40:35 +0000 (11:40 +0200)] 
pcap: improve pcap_breakloop support

When pcap_breakloop has been issued on a handle, the current pcap_dispatch
call may return -2 (PCAP_ERROR_BREAK), but it can also return the number
of processed packets if lower than the desired number. So add this condition
as a check.

2 years agodetect: only breakloop threads that are lagging
Victor Julien [Thu, 6 Apr 2023 14:06:34 +0000 (16:06 +0200)] 
detect: only breakloop threads that are lagging

Sleep after all threads have been checked.

Bug: #5969.

2 years agoflow/worker: refresh detect thread during housekeeping
Victor Julien [Thu, 6 Apr 2023 13:43:41 +0000 (15:43 +0200)] 
flow/worker: refresh detect thread during housekeeping

During housekeeping multiple flows are processed. If a rule reload happens
at that time, we need to use the new detect thread as soon as possible.

Bug: #5969.

2 years agoflow/worker: remove unused detect thread arg
Victor Julien [Thu, 6 Apr 2023 13:31:12 +0000 (15:31 +0200)] 
flow/worker: remove unused detect thread arg

2 years agohttp2: faster when reducing dynamic headers size 8688/head
Philippe Antoine [Thu, 16 Mar 2023 08:20:40 +0000 (09:20 +0100)] 
http2: faster when reducing dynamic headers size

avoid quadratic complexity from removing the first element
and copying all the contents a big number fo times.

Ticket: #5909

2 years agohttp: fix multipart completion 8682/head
Philippe Antoine [Fri, 31 Mar 2023 18:06:13 +0000 (20:06 +0200)] 
http: fix multipart completion

As brought by commit 578f328e06b3e03f3bdbbf852b5d121e20849b8b

Ticket: #5952

2 years agonetmap: Forward port packet stall fix 8677/head
Jeff Lucovsky [Sat, 1 Apr 2023 13:47:56 +0000 (09:47 -0400)] 
netmap: Forward port packet stall fix

Issue: 5862

This commit forward ports fixes from master-6.0.x that address packet
stalling that may occur under IPS configurations.

2 years agoapp-layer-dnp3: Fix build for big endian
Cole Dishington [Fri, 31 Mar 2023 00:40:51 +0000 (13:40 +1300)] 
app-layer-dnp3: Fix build for big endian

Add missing include of util-byte.h for big endian targets that need
SCByteSwap(16|32|64) for DNP3_SWAP(16|32|64).

2 years agouserguide/muti-tenant: fix typo
Juliana Fajardini [Mon, 3 Apr 2023 14:48:21 +0000 (11:48 -0300)] 
userguide/muti-tenant: fix typo

2 years agodoc: add tenant id value requirement
jason taylor [Thu, 30 Mar 2023 13:53:23 +0000 (13:53 +0000)] 
doc: add tenant id value requirement

Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years agooutput: fix logic error
Maxim Korotkov [Thu, 16 Feb 2023 17:16:19 +0000 (20:16 +0300)] 
output: fix logic error

The logical error may have been made here. Comparison with the upper
bound of the variable type does not make sense. It may be worth adding
the cast of one of the multiplication operands to the 64-bit type for
avoiding overflow.

Found by Security Code with Svace static analyzer
Bug: #5789

Signed-off-by: Maxim Korotkov <m.korotkov@securitycode.ru>
2 years agostream: improve FIN checking 8675/head
Victor Julien [Mon, 3 Apr 2023 09:50:09 +0000 (11:50 +0200)] 
stream: improve FIN checking

After recent next_seq changes, the FIN checks could be too strict
leading to stalling sessions in IPS mode.

This patch requires a FIN to be >= last ack and <= next_win to be
accepted.

2 years agoutil/base64: don't reset decoded bytes in RFC4648 8660/head
Shivani Bhardwaj [Thu, 9 Mar 2023 07:13:41 +0000 (12:43 +0530)] 
util/base64: don't reset decoded bytes in RFC4648

Old behavior:
With RFC4648, the decoded bytes were reset to 0 in case an unusual
character was encountered in the encoded string. This worked out fine
for small test cases where there weren't many bytes to be decoded.

Problem:
If a big encoded string had a character outside of the base alphabet,
the processing would stop and the number of decoded bytes were set to 0.
However, even though the processing should stop at the invalid
character, the number of decoded bytes should correctly store the bytes
decoded up until the point an invalid characted was encountered.

New behavor:
For any base64 encoded string given to the base64 decoder in RFC4648
mode, we make sure that the number of decoded bytes correctly reflect
the number of bytes processed up until the string was valid. This makes
sure any further calculations/use of the decoded data is done correctly.

Redmine ticket: 5885

2 years agoapp-layer: add direction to transaction creation where needed
Jason Ish [Wed, 15 Mar 2023 22:23:49 +0000 (16:23 -0600)] 
app-layer: add direction to transaction creation where needed

Build on Eric's but set the direction on transaction creation when
needed. I think this makes it a little more clear, and easier to
document when creating single direction transactions.

This also somewhat abstracts the inner-workings of a directional
transaction from the implementation.

Ticket: #4759

2 years agosip: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 21:01:18 +0000 (22:01 +0100)] 
sip: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agoenip: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:08:57 +0000 (20:08 +0100)] 
enip: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agodnp3: activate unidirectional TX flag
Eric Leblond [Mon, 23 Jan 2023 19:08:07 +0000 (20:08 +0100)] 
dnp3: activate unidirectional TX flag

By implementing the no inspection flag we can now set
the unidirectional TX flag. Which means that the alstate
progress function can now be simplified to always return
1 f the transaction is complete.

Ticket: #5799

2 years agonfs: TX are not unidirectional
Eric Leblond [Mon, 23 Jan 2023 19:07:07 +0000 (20:07 +0100)] 
nfs: TX are not unidirectional

NFS transactions are not unidirectional so we should not declare
them as such.

2 years agoquic: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:05:39 +0000 (20:05 +0100)] 
quic: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agontp: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:05:08 +0000 (20:05 +0100)] 
ntp: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agokrb: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:04:26 +0000 (20:04 +0100)] 
krb: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agomqtt: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:04:00 +0000 (20:04 +0100)] 
mqtt: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agoike: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:03:35 +0000 (20:03 +0100)] 
ike: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agodns: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:03:12 +0000 (20:03 +0100)] 
dns: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agobittorrent_dht: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:02:31 +0000 (20:02 +0100)] 
bittorrent_dht: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agosnmp: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:02:00 +0000 (20:02 +0100)] 
snmp: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agoapp-layer: add flag to skip detection on TX
Eric Leblond [Mon, 23 Jan 2023 19:01:05 +0000 (20:01 +0100)] 
app-layer: add flag to skip detection on TX

Stamus team did discover a problem were a signature can shadow
other signatures.

For example, on a PCAP only containing Kerberos protocol and where the
following signature is matching:

alert krb5 $HOME_NET any -> any any (msg:"krb match"; krb5_cname; content:"marlo"; sid:3; rev:1;)

If we add the following signature to the list of signature

alert ssh $HOME_NET any -> any any (msg:"rr"; content:"rr"; flow:established,to_server; sid:4; rev:2;)

Then the Kerberos signature is not matching anymore.

To understand this case, we need some information:

- The krb5_cname is a to_client keyword
- The signal on ssh is to_server
- Kerberos has unidirectional transaction
- kerberos application state progress is a function always returning 1

As the two signatures are in opposite side, they end up in separate
sig group head.

Another fact is that, in the PCAP, the to_server side of the session
is sent first to the detection. It thus hit the sig group head of
the SSH signature. When Suricata runs detection in this direction
the Kerberos application layer send the transaction as it is existing
and because the alstate progress function just return 1 if the transaction
exists. So Suricata runs DetectRunTx() and stops when it sees that
sgh->tx_engines is NULL.

But the transaction is consumed by the engine as it has been evaluated
in one direction and the kerberos transaction are unidirectional so
there is no need to continue looking at it.

This results in no matching of the kerberos signature as the match
should occur in the evaluation of the other side but the transaction
with the data is already seen has been handled.

This problem was discovered on this Kerberos signature but all
the application layer with unidirectional transaction are impacted.

This patch introduces a flag that can be used by application layer
to signal that the TX should not be inspected. By using this flag
on the directional detect_flags_[ts|tc] the application layer can
prevent the TX to be consumed in the wrong direction.

Application layers with unidirectional TX will be updated
in separate commits to set the flag on the direction opposite
to the one they are.

Ticket: #5799

2 years agodetect: remove STREAM_FLUSH
Eric Leblond [Fri, 20 Jan 2023 10:08:11 +0000 (11:08 +0100)] 
detect: remove STREAM_FLUSH

It is unused in the code so can be removed.

Ticket: #5799

2 years agoapp-layer-parser: give direction to progress func
Eric Leblond [Fri, 20 Jan 2023 09:35:59 +0000 (10:35 +0100)] 
app-layer-parser: give direction to progress func

The tx progress functions are expecting a direction and were given
a flow flags. As a result, they were not reporting correctly the
status if a DetectRunScratchPad flow_flags was containing some other
bits in the flag.

One case was when a signature was alterating the stream analysis
and triggering the addition of the STREAM_FLUSH flags.

The consequences are quite severe as the transactions are pilling
up waiting to be inspected causing sometimes a 10x performance hit
on pcap parsing. Also as the inspection was not done, Suricata is
missing a part of the alerts.

This was discovered when working on the following set of signatures:

alert ssh $HOME_NET any -> any any (msg:"pcre without content"; pcre:"/rabbit/"; sid:1; rev:1;)
alert smb $HOME_NET any -> any any (msg:"smb share content"; smb.share; content:"C"; sid:2; rev:1;)

When the first one is present the second is not triggering even
though the pcap file had no ssh inside. This is due to the fact
that the ssh signature was triggering the STREAM_FLUSH flag to
be set on the flowflags of the packet. But the application
layer will ask the smb state progress via

r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
        StateGetProgress(alstate, flags);

passing it the flow flags but the smb function is expecting
a direction so we end up in a unplanned case

pub unsafe extern "C" fn rs_smb_tx_get_alstate_progress(tx: *mut ffi::c_void,
                                                  direction: u8)
...
if direction == Direction::ToServer as u8 && tx.request_done {

This leads the signature to not be evaluated correctly.

Ticket: #5799

2 years agohttp: complete multipart until request.body-limit 8648/head
Philippe Antoine [Thu, 26 Jan 2023 08:28:46 +0000 (09:28 +0100)] 
http: complete multipart until request.body-limit

In the case we are truncating a multipart file because of reaching
request.body-limit, we used to not consume the whole buffer, but
keep expected_boundary_len bytes in case a new boundary begins
in these bytes.
Even if we cannot check the complete boundary, we can still check
the first bytes, as will be done in the rust version.

Ticket: #5952

2 years agostream: handle zero window probe acks 8638/head
Victor Julien [Mon, 6 Mar 2023 15:06:25 +0000 (16:06 +0100)] 
stream: handle zero window probe acks

These can be skipped for the most part.

2 years agoeve/stream: add output warning about experimental state
Victor Julien [Mon, 6 Mar 2023 15:05:56 +0000 (16:05 +0100)] 
eve/stream: add output warning about experimental state

2 years agostream: accept and flag ack of ZWP data
Victor Julien [Fri, 3 Mar 2023 07:02:35 +0000 (08:02 +0100)] 
stream: accept and flag ack of ZWP data

Tcp Zero Window Probes try to send a single byte payload to "probe" if
the window has reopened. This single byte is, if accepted, not retransmitted.

2 years agostream: harden tcp reuse check against RST/FIN
Victor Julien [Fri, 3 Mar 2023 12:30:55 +0000 (13:30 +0100)] 
stream: harden tcp reuse check against RST/FIN

2 years agostream: improve SYN and SYN/ACK handling with ECN/CWR flags
Victor Julien [Fri, 3 Mar 2023 12:30:14 +0000 (13:30 +0100)] 
stream: improve SYN and SYN/ACK handling with ECN/CWR flags

2 years agostream: fix TFO overlap detection with ECN/CWR flags
Victor Julien [Fri, 3 Mar 2023 12:02:48 +0000 (13:02 +0100)] 
stream: fix TFO overlap detection with ECN/CWR flags

2 years agostream: flag zero window probe packets
Victor Julien [Thu, 2 Mar 2023 10:51:37 +0000 (11:51 +0100)] 
stream: flag zero window probe packets

2 years agoconf: deprecate multiple "include" statements at same level
Jason Ish [Fri, 24 Mar 2023 05:51:11 +0000 (23:51 -0600)] 
conf: deprecate multiple "include" statements at same level

The YAML spec considers duplicate keys to be an error, as do some YAML
implementations, most notably Rust's serde_yaml which would be nice to
use in the future.

Multiple include lines at the same level will still work, but a warning
will be emitted.

These can be fixed by moving to an "include" array:

include:
  - file1.yaml
  - file2.yaml

Ticket: #5939

2 years agoconf: fatal error if "include" is a mapping
Jason Ish [Fri, 24 Mar 2023 05:49:55 +0000 (23:49 -0600)] 
conf: fatal error if "include" is a mapping

If a field named "include" is mapping it is not processed correctly.
Instead return a fatal error.

In our YAML, "include" has always been a reserved word, so this should
not break any known configuration.

Ticket: #5939

2 years agoconf: allow "include" to be a list of files
Jason Ish [Fri, 24 Mar 2023 05:49:00 +0000 (23:49 -0600)] 
conf: allow "include" to be a list of files

In preparation for deprecating multiple "include" fields at the same
level, allow "include" to be a list of filenames.

Ticket: #5939

2 years agodocs: clarify exception policy's supported values
Juliana Fajardini [Wed, 22 Mar 2023 19:05:40 +0000 (16:05 -0300)] 
docs: clarify exception policy's supported values

As flow.memcap-policy and defrag.memcap-policy do not support flow
actions, clarify that in the documentation. Also fix some typos, and
add missing values in some places where the exception policies were
explained.

Related to
Bug #5940

2 years agoexception/policy: use pkt action if no flow support
Juliana Fajardini [Fri, 24 Mar 2023 14:15:14 +0000 (11:15 -0300)] 
exception/policy: use pkt action if no flow support

Defrag memcap and flow memcap do not support flow action for the
exception policies, as there is no flow when the exception condition is
hit. In such cases, the exception policy must be considered for the
packet only, when that makes sense, or should be ignored, in case of
`bypass`.

Bug #5940

2 years agodetect: bump detect engine version for tenant reload 8635/head
Philippe Antoine [Fri, 10 Mar 2023 10:28:26 +0000 (11:28 +0100)] 
detect: bump detect engine version for tenant reload

Because the engine version is used to free the old
variables and not the new ones.
As is done in DetectEngineReload.

Ticket: #5866

2 years agodetect: bytemath do not left shift more than 64
Philippe Antoine [Tue, 14 Mar 2023 11:17:05 +0000 (12:17 +0100)] 
detect: bytemath do not left shift more than 64

As it is undefined behavior by C standard.
In this case, zeroes the value.

Ticket: #5900

2 years agorust: don't suppress vendor output
Jason Ish [Wed, 22 Mar 2023 16:03:30 +0000 (10:03 -0600)] 
rust: don't suppress vendor output

There appears to be some errors happening in CI and this may be hiding
the source of the error.

2 years agorust: bundle Cargo.lock
Jason Ish [Sat, 18 Mar 2023 18:20:12 +0000 (12:20 -0600)] 
rust: bundle Cargo.lock

Cargo.lock has to be provided as template, Cargo.lock.in so it can
live beside Cargo.lock in out of tree automake builds, like distcheck.

This will pin Rust dependencies even for git builds, updating
Cargo.lock will now be a manual process that we'll have to take care
of periodically.

2 years agoflow/manager: fix coverity divide_by_zero warning
Juliana Fajardini [Fri, 24 Mar 2023 20:04:57 +0000 (17:04 -0300)] 
flow/manager: fix coverity divide_by_zero warning

Updated all cases where flow_config.prealloc was used in a division.

*** CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
/src/flow-manager.c: 858 in FlowManager()
852                                "flow_spare_q status: %" PRIu32 "%% flows at the queue",
853                             spare_pool_len, flow_config.prealloc,
854                             spare_pool_len * 100 / flow_config.prealloc);
855
856                     /* only if we have pruned this "emergency_recovery" percentage
857                      * of flows, we will unset the emergency bit */
>>>     CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
>>>     In expression "spare_pool_len * 100U / flow_config.prealloc", division by expression "flow_config.prealloc" which may be zero has undefined behavior.
858                     if (spare_pool_len * 100 / flow_config.prealloc > flow_config.emergency_recovery) {
859                         emerg_over_cnt++;
860                     } else {
861                         emerg_over_cnt = 0;
862                     }

Related to
Bug #5919

2 years agocontent: Constrain distance/within values
Jeff Lucovsky [Wed, 7 Dec 2022 15:20:06 +0000 (10:20 -0500)] 
content: Constrain distance/within values

Ticket: 5740

This commit constrains the values for distance and limit to 1MB. The
constraint is enforced while parsing the keyword values.

2 years agodoc/content: Add limits for distance/within
Jeff Lucovsky [Wed, 7 Dec 2022 15:10:18 +0000 (10:10 -0500)] 
doc/content: Add limits for distance/within

Ticket: 5740

2 years agoprofiling: updated switch block to fix gcc warning 8625/head
jason taylor [Tue, 21 Mar 2023 14:51:13 +0000 (14:51 +0000)] 
profiling: updated switch block to fix gcc warning

This fixes a warning emitted by Fedora 37 when compiling
with gcc 12.2.1

Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years agoprofiling: minor reformatting
Victor Julien [Fri, 24 Mar 2023 08:25:44 +0000 (09:25 +0100)] 
profiling: minor reformatting

2 years agoflow/manager: fix prealloc unhandled division by 0 8624/head
Juliana Fajardini [Mon, 20 Mar 2023 14:56:58 +0000 (11:56 -0300)] 
flow/manager: fix prealloc unhandled division by 0

If flow.prealloc was set to zero in our yaml config, this led to
a floating point exception in the flow manager.

Bug: #5919.

2 years agoenip: optimized tx iterator
Philippe Antoine [Thu, 23 Mar 2023 08:00:42 +0000 (09:00 +0100)] 
enip: optimized tx iterator

As for SMTP, having a linked list.

Ticket: #5927

2 years agodnp3: optimized tx iterator
Philippe Antoine [Thu, 23 Mar 2023 07:57:53 +0000 (08:57 +0100)] 
dnp3: optimized tx iterator

As for SMTP, having a linked list.

Ticket: #5927

2 years agosmtp: optimized tx iterator
Philippe Antoine [Wed, 22 Mar 2023 16:24:40 +0000 (17:24 +0100)] 
smtp: optimized tx iterator

To be more efficient with larger number of transactions.
As was done for FTP.

Ticket: #5927

2 years agosource-xf-xdp: update for deprecated function in libbpf
Jason Ish [Wed, 22 Mar 2023 21:13:46 +0000 (15:13 -0600)] 
source-xf-xdp: update for deprecated function in libbpf

libbpf 0.8 deprecates bpf_get_link_xpd_id, and 1.0 removes it. Add
./configure check to see if this method is available and use it if so,
otherwise use the deprecated method which is not available on older
but still supported Linux distributions.

Ticket: #5924

2 years agorust: update aes and aes-gcm crates
Jason Ish [Wed, 22 Mar 2023 17:58:33 +0000 (11:58 -0600)] 
rust: update aes and aes-gcm crates

Addresses RUSTSEC-2021-0059, RUSTSEC-2021-0060.

2 years agodetect/urilen: fix applying urilen as depth
Victor Julien [Thu, 23 Mar 2023 14:42:18 +0000 (15:42 +0100)] 
detect/urilen: fix applying urilen as depth

If urilen induced depth was set, later DetectContentPropagateLimits()
would apply a wrong depth setting, leading to a false negative in
some cases.

Bug: #5929.

2 years agodetect/urilen: support HTTP/2
Victor Julien [Thu, 23 Mar 2023 10:31:49 +0000 (11:31 +0100)] 
detect/urilen: support HTTP/2

Ticket: #5931.

2 years agoeve/drop: don't log drops unless packet is dropped
Victor Julien [Tue, 21 Mar 2023 19:20:48 +0000 (20:20 +0100)] 
eve/drop: don't log drops unless packet is dropped

In pass/drop combinations where the pass rule took precendence over
the drop, a "drop" false positive could still be logged due to the
storing of the drop record in the packet drop alert store.

Bug: #5867.

2 years agodetect/mpm: minor code cleanups
Victor Julien [Mon, 20 Mar 2023 13:25:41 +0000 (14:25 +0100)] 
detect/mpm: minor code cleanups

2 years agodetect: apply within as depth where possible
Victor Julien [Sun, 19 Mar 2023 16:46:02 +0000 (17:46 +0100)] 
detect: apply within as depth where possible

The rule lang allows for within and distance to act as depth/offset,
but internally this was not handle the same way. This patch converts
within/distance w/o a prior pattern to depth/within.

2 years agodetect/offset: minor code cleanups
Victor Julien [Sun, 19 Mar 2023 18:25:09 +0000 (19:25 +0100)] 
detect/offset: minor code cleanups

2 years agodetect/content: refactor limit propagation
Victor Julien [Sun, 19 Mar 2023 15:39:32 +0000 (16:39 +0100)] 
detect/content: refactor limit propagation

2 years agodetect/distance: minor code cleanups
Victor Julien [Sun, 19 Mar 2023 15:30:00 +0000 (16:30 +0100)] 
detect/distance: minor code cleanups

2 years agodetect/within: minor code cleanups
Victor Julien [Sun, 19 Mar 2023 15:24:40 +0000 (16:24 +0100)] 
detect/within: minor code cleanups

2 years agodetect/analyzer: fix lists names
Victor Julien [Thu, 16 Mar 2023 05:38:48 +0000 (06:38 +0100)] 
detect/analyzer: fix lists names

Simpler names that lead to cleaner json.

2 years agodetect/analyzer: add byte_test/byte_jump detail
Victor Julien [Wed, 15 Mar 2023 21:16:40 +0000 (22:16 +0100)] 
detect/analyzer: add byte_test/byte_jump detail

2 years agodetect/analyzer: add content relative_next flag
Victor Julien [Mon, 13 Mar 2023 13:48:19 +0000 (14:48 +0100)] 
detect/analyzer: add content relative_next flag

2 years agodetect/analyzer: add more pcre detail
Victor Julien [Mon, 13 Mar 2023 12:53:32 +0000 (13:53 +0100)] 
detect/analyzer: add more pcre detail

2 years agodetect: split mpm per alproto for file.data & others
Victor Julien [Sat, 18 Mar 2023 18:05:07 +0000 (19:05 +0100)] 
detect: split mpm per alproto for file.data & others

Instead of a shared mpm context for just "file.data" or "file.magic"
use per alproto mpms. This way http file.data rules won't affect smb
file.data performance.

Ticket: #4378.

2 years agompm factory: include alproto
Victor Julien [Sat, 18 Mar 2023 18:56:07 +0000 (19:56 +0100)] 
mpm factory: include alproto

In preparation of spliting out mpm's for keywords shared by
multiple protocols, like file.data.

2 years agojsonschema: do not enforce keys for alert metadata 8605/head
Philippe Antoine [Mon, 26 Dec 2022 10:54:54 +0000 (11:54 +0100)] 
jsonschema: do not enforce keys for alert metadata

As this is a free field and can have any key based on a rule

2 years agodoc: security.limit-noproc upgrade note
Philippe Antoine [Mon, 13 Mar 2023 10:28:40 +0000 (11:28 +0100)] 
doc: security.limit-noproc upgrade note

Ticket: #5621

2 years agogithub-ci: Add Netmap build to GH actions
Lukas Sismis [Fri, 10 Mar 2023 17:25:44 +0000 (18:25 +0100)] 
github-ci: Add Netmap build to GH actions

Issue: #5803

2 years agosmtp: apply suricata.yaml defaults to in-code defaults
Jason Ish [Tue, 14 Mar 2023 22:11:25 +0000 (16:11 -0600)] 
smtp: apply suricata.yaml defaults to in-code defaults

Currently the default suricata.yaml sets some values that do not
reflect the default values in the code. As most users are probably
using a default suricata.yaml, make the code have the same defaults as
in suricata.yaml:

- mime.decode-mime: false -> true
- mime.decode-base64: false -> true
- mime.decode-quoted-printable: false -> true
- mime.extract-urls: false -> true

Issue: #5823

2 years agoschema: add "message_id" to email
Jason Ish [Tue, 14 Mar 2023 22:11:07 +0000 (16:11 -0600)] 
schema: add "message_id" to email

2 years agoconf: document ConfGetChildValueBool
Jason Ish [Mon, 13 Mar 2023 23:27:04 +0000 (17:27 -0600)] 
conf: document ConfGetChildValueBool

2 years agodetect-lua: Convert unittests to FAIL/PASS API
Gabriel Lima Luz [Fri, 3 Feb 2023 15:02:56 +0000 (12:02 -0300)] 
detect-lua: Convert unittests to FAIL/PASS API

Ticket: 4051

2 years agosource-xdp: only allow busy poll if headers support it
Jason Ish [Thu, 9 Feb 2023 17:16:18 +0000 (11:16 -0600)] 
source-xdp: only allow busy poll if headers support it

Wrap the enabling of busy poll in a compile time conditional checking
for the required defines to be set. While we have runtime support for
kernels less than 5.11, we also need a compile time check as the headers
may be old as well.

Issue: 5855

2 years agogithub-ci: add Debian 11 builder with XDP
Jason Ish [Thu, 9 Feb 2023 15:39:37 +0000 (09:39 -0600)] 
github-ci: add Debian 11 builder with XDP

2 years agoschema: fix optional 8587/head
Jason Ish [Mon, 6 Mar 2023 17:51:03 +0000 (11:51 -0600)] 
schema: fix optional

"optional" is not part of jsonschema. Instead an array named "required"
is used to list all field names that are required.

2 years agoschema: fix engines section
Jason Ish [Mon, 6 Mar 2023 17:48:45 +0000 (11:48 -0600)] 
schema: fix engines section

The definition of items is an object, not an array.

2 years agonflog/time: Fixup timestamp handling
Jeff Lucovsky [Tue, 7 Mar 2023 13:59:12 +0000 (08:59 -0500)] 
nflog/time: Fixup timestamp handling

Issue: 5818

This commit corrects the timestamp handling for the packet to work with
the SCTime_t struct.

2 years agorust/clippy: allow derivable impls
Jason Ish [Thu, 9 Mar 2023 17:48:53 +0000 (11:48 -0600)] 
rust/clippy: allow derivable impls

The latest Rust will automatically "fix" derivable default
implementation, which is nice, but makes changes that don't meet our
current MSRV, so allow derivable impls for now.

2 years agodetect/app-layer-event: simplify parsing code
Victor Julien [Wed, 8 Mar 2023 09:09:26 +0000 (10:09 +0100)] 
detect/app-layer-event: simplify parsing code

Simpler and fully local parsing code.

Remove unittests that relied on previous implementation. Code
is tested by SV tests.

2 years agodetect/analyzer: add transform names
Victor Julien [Mon, 6 Mar 2023 16:31:54 +0000 (17:31 +0100)] 
detect/analyzer: add transform names

2 years agoutil/mime: use uint32_t for consumed bytes 8581/head
Shivani Bhardwaj [Wed, 8 Mar 2023 15:46:03 +0000 (21:16 +0530)] 
util/mime: use uint32_t for consumed bytes

In a case of the line buffer being over 255 bytes, the consumed bytes
would reset to 0 as it was uint8_t. Fix this integer overflow by setting
the type to uint32_t.

Redmine ticket: 5883

2 years agodoc: add dataset examples 8572/head
Shivani Bhardwaj [Mon, 27 Feb 2023 13:17:16 +0000 (18:47 +0530)] 
doc: add dataset examples

2 years agodetect: add comments for DETECT_SM_LIST_* types
Shivani Bhardwaj [Thu, 2 Mar 2023 07:28:17 +0000 (12:58 +0530)] 
detect: add comments for DETECT_SM_LIST_* types

2 years agoconfig: put version in configuration as a proper value
Jason Ish [Mon, 30 Jan 2023 23:13:04 +0000 (17:13 -0600)] 
config: put version in configuration as a proper value

Adds a new field, "suricata-version" to the configuration file with
the major and minor version of the Suricata that generated the
configuration file.

This may be useful in the future for presenting warnings about
important changes, or even providing different defaults based on what
the user might expect.

Ticket: 5822

2 years agopfring: Packet structure for ts fix
Jeff Lucovsky [Fri, 17 Feb 2023 14:18:24 +0000 (09:18 -0500)] 
pfring: Packet structure for ts fix

Issue: 5818

This commit addresses the issue with using the address of a packed
member of a structure. The pfring timeval is within a packed structure.

2 years agopfring/time: Track stat output with SCTime_t
Jeff Lucovsky [Sun, 29 Jan 2023 14:28:38 +0000 (09:28 -0500)] 
pfring/time: Track stat output with SCTime_t

Issue: 5818

This commit changes the datatype of the tracking value for the last time
stats were dumped.

Changing the type also eliminates a comparison between values with
different signs.

2 years agotime: SCTime additions -- neq, initializer
Jeff Lucovsky [Sun, 29 Jan 2023 13:36:42 +0000 (08:36 -0500)] 
time: SCTime additions -- neq, initializer

Issue: 5818

This commit adds an initializer for the SCTime_t type and a comparison
macro for "not equal".

Use them as follows:
    SCTime_t my_var = SCTIME_INITIALIZER;
    if (SCTIME_CMP_NEQ(sctime1_val, sctime2_val)) {
    }

2 years agoeve: add version and warning in ntlmssp
Lancer Cheng [Tue, 14 Feb 2023 11:33:35 +0000 (11:33 +0000)] 
eve: add version and warning in ntlmssp

Bug OISF#5783

2 years agodoc: add version filed in NTLMSSP documentation
Lancer Cheng [Tue, 14 Feb 2023 11:27:29 +0000 (11:27 +0000)] 
doc: add version filed in NTLMSSP documentation

Bug OISF#5783

2 years agosmb: fix parser of ntlmssp negotiateflags
Lancer Cheng [Tue, 14 Feb 2023 11:26:57 +0000 (11:26 +0000)] 
smb: fix parser of ntlmssp negotiateflags

Fix endian-conversion bug in function parse_ntlm_auth_nego_flags

Bug OISF#5783

2 years agolog/thread: Consolidate threaded file tracking
Jeff Lucovsky [Sat, 11 Feb 2023 16:42:55 +0000 (11:42 -0500)] 
log/thread: Consolidate threaded file tracking

Issue: 5836

This commit removes the duplicate threaded file tracking from the log
file mechanisms.

Tracking is now consolidated with the threaded hash table.

2 years agolog: Stop if log initialization fails at startup
Jeff Lucovsky [Sat, 4 Feb 2023 15:08:37 +0000 (10:08 -0500)] 
log: Stop if log initialization fails at startup

Issue: 5836

This commit modifies Suricata to fail if log initialization errors occur
during startup.

2 years agostream: add seq min and max; use in segment compare 8563/head
Victor Julien [Tue, 28 Feb 2023 14:00:09 +0000 (15:00 +0100)] 
stream: add seq min and max; use in segment compare