]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
19 months agoschema: apply clang formatting changes 10061/head
Juliana Fajardini [Mon, 11 Dec 2023 20:10:54 +0000 (17:10 -0300)] 
schema: apply clang formatting changes

19 months agouserguide/eve: explain pgsql requests & responses
Juliana Fajardini [Mon, 11 Dec 2023 20:55:37 +0000 (17:55 -0300)] 
userguide/eve: explain pgsql requests & responses

Add a more visible explanation of that requests, responses, frontend and
and backend are, in Pgsql context, to avoid having to repeat that over
different portions of the docs.

19 months agopgsql: add cancel request message
Juliana Fajardini [Mon, 11 Dec 2023 20:10:13 +0000 (17:10 -0300)] 
pgsql: add cancel request message

A CanceldRequest can occur after any query request, and is sent over a
new connection, leading to a new flow. It won't take any reply, but, if
processed by the backend, will lead to an ErrorResponse.

Task #6577

19 months agodoc/eve-format: break pgsql section to char limit
Juliana Fajardini [Mon, 11 Dec 2023 20:26:31 +0000 (17:26 -0300)] 
doc/eve-format: break pgsql section to char limit

19 months agopgsql: extract length validation into function
Juliana Fajardini [Thu, 30 Nov 2023 21:55:13 +0000 (18:55 -0300)] 
pgsql: extract length validation into function

This is called so many times that it seems to make sense that we use a
function for this.

19 months agodetect/byte: remove unneeded SIG_FLAG_APPLAYER sets 10052/head
Victor Julien [Wed, 13 Dec 2023 07:45:06 +0000 (08:45 +0100)] 
detect/byte: remove unneeded SIG_FLAG_APPLAYER sets

Flag will be set during list(s) setup if needed.

19 months agodetect/byte_extract: modernize tests
Victor Julien [Tue, 12 Dec 2023 13:54:41 +0000 (14:54 +0100)] 
detect/byte_extract: modernize tests

19 months agodetect/bytemath: bump length to uint32_t
Victor Julien [Thu, 7 Dec 2023 16:07:04 +0000 (17:07 +0100)] 
detect/bytemath: bump length to uint32_t

This puts the logic in line with the other payload inspection
functions.

19 months agodetect/bytejump: test cleanup
Victor Julien [Fri, 8 Dec 2023 11:45:06 +0000 (12:45 +0100)] 
detect/bytejump: test cleanup

Just one used during debugging.

19 months agodetect/bytejump: don't reuse content flag
Victor Julien [Fri, 8 Dec 2023 08:38:38 +0000 (09:38 +0100)] 
detect/bytejump: don't reuse content flag

To avoid future problems with overlapping flag values, give bytejump
its own DETECT_BYTEJUMP_OFFSET_VAR flag.

The values are currently not overlapping, so this patch should have
no side effects.

19 months agodetect/analyzer: print int keyword values correctly
Victor Julien [Fri, 8 Dec 2023 09:31:21 +0000 (10:31 +0100)] 
detect/analyzer: print int keyword values correctly

To avoid negative values to be misrepresented.

Bug: #6615.

19 months agojsonbuilder: add set_int for signed ints
Victor Julien [Fri, 8 Dec 2023 09:30:25 +0000 (10:30 +0100)] 
jsonbuilder: add set_int for signed ints

Bug: #6615

19 months agoeve/stream: add sb main region size; segment count
Victor Julien [Thu, 28 Sep 2023 12:41:20 +0000 (14:41 +0200)] 
eve/stream: add sb main region size; segment count

Gives more detail about memory use.

19 months agooutput-json-dns: remove un-needed includes 10047/head
Jason Ish [Sun, 12 Nov 2023 13:46:07 +0000 (08:46 -0500)] 
output-json-dns: remove un-needed includes

19 months agooutput-json-alert: remove un-needed includes
Jason Ish [Sun, 12 Nov 2023 13:03:25 +0000 (14:03 +0100)] 
output-json-alert: remove un-needed includes

19 months agodoc/userguide: document dns.query.name, dns.answer.name
Jason Ish [Wed, 15 Nov 2023 18:11:51 +0000 (12:11 -0600)] 
doc/userguide: document dns.query.name, dns.answer.name

With some other minor cleanups in the DNS keyword section.

19 months agodns: replace usage of rs_dns_tx_get_query_name with SCDnsTxGetQueryName
Jason Ish [Wed, 15 Nov 2023 18:31:12 +0000 (12:31 -0600)] 
dns: replace usage of rs_dns_tx_get_query_name with SCDnsTxGetQueryName

SCDnsTxGetQueryName was introduced to allow for getting the query name
in responses as well as requests, so covers the functionality of
rs_dns_tx_get_query_name.

19 months agodns: add dns.query.name sticky buffer
Jason Ish [Tue, 14 Nov 2023 23:01:49 +0000 (17:01 -0600)] 
dns: add dns.query.name sticky buffer

This buffer is much like dns.query_name but allows for detection in both
directions.

Feature: #6497

19 months agodns: add dns.answer.name keyword
Jason Ish [Mon, 23 Oct 2023 21:28:40 +0000 (15:28 -0600)] 
dns: add dns.answer.name keyword

This sticky buffer will allow content matching on the answer names.
While ansers typically only occur in DNS responses, we allow the buffer
to be used in request context as well as the request message format
allows it.

Feature: #6496

19 months agodns: consolidate DNSRequest and DNSResponse to DNSMessage
Jason Ish [Wed, 15 Nov 2023 21:58:36 +0000 (15:58 -0600)] 
dns: consolidate DNSRequest and DNSResponse to DNSMessage

DNS request and response messages follow the same format so there is
no reason not to use the same data structure for each. While its
unlikely to see fields like answers in a request, the message format
does not disallow them, so it might be interesting data to have the
ability to log.

19 months agodns: rustfmt with latest stable
Jason Ish [Thu, 16 Nov 2023 15:44:07 +0000 (09:44 -0600)] 
dns: rustfmt with latest stable

19 months agorustfmt: replace deprecated fn_args_layout with fn_params_layout
Jason Ish [Thu, 16 Nov 2023 15:43:33 +0000 (09:43 -0600)] 
rustfmt: replace deprecated fn_args_layout with fn_params_layout

19 months agodetect: rename InspectEngineFuncPtr2 to InspectEngineFuncPtr
Jason Ish [Sun, 12 Nov 2023 13:15:11 +0000 (14:15 +0100)] 
detect: rename InspectEngineFuncPtr2 to InspectEngineFuncPtr

Version 1 of the API no longer exists.

19 months agodetect: rename DetectAppLayerInspectEngineRegister2
Jason Ish [Mon, 23 Oct 2023 22:24:23 +0000 (16:24 -0600)] 
detect: rename DetectAppLayerInspectEngineRegister2

Rename DetectAppLayerInspectEngineRegister2 to
DetectAppLayerInspectEngineRegister as there is no other variant of
this function, and the versioning with lack of supporting
documentation can lead to confusion.

19 months agodetect: rename DetectAppLayerMpmRegister2 to DetectAppLayerMpmRegister
Jason Ish [Mon, 23 Oct 2023 21:05:43 +0000 (15:05 -0600)] 
detect: rename DetectAppLayerMpmRegister2 to DetectAppLayerMpmRegister

The old DetectAppLayerMpmRegister has not been around since 4.1.x.
Rename the v2 of this function to a versionless function as there is no
documentation referring to what the 2 means.

19 months agodetect/analyzer: add details to flowbits keyword
Hadiqa Alamdar Bukhari [Wed, 13 Dec 2023 11:15:50 +0000 (16:15 +0500)] 
detect/analyzer: add details to flowbits keyword

Task #6309

19 months agoendace: Fix source-dag timestamps
Stephen Donnelly [Mon, 11 Dec 2023 02:32:06 +0000 (15:32 +1300)] 
endace: Fix source-dag timestamps

Bug: #6618.

Fix Endace ERF to SCTime_t timestamp conversion

Fix typo preventing compilation with --enable-dag

19 months agodoc/userguide: update guidance on 5 to 6 upgrading 10043/head
Victor Julien [Thu, 7 Dec 2023 09:27:41 +0000 (10:27 +0100)] 
doc/userguide: update guidance on 5 to 6 upgrading

TCP memory use can be higher than expected in certain configs.

Ticket: #6552.

19 months agogithub-ci/formatting: update to Ubuntu 22.04
Jason Ish [Wed, 6 Dec 2023 16:09:47 +0000 (10:09 -0600)] 
github-ci/formatting: update to Ubuntu 22.04

Update the formatting CI job to Ubuntu 22.04 to get a newer version of
clang-format, in this case clang-format-14.

19 months agoclang-format.sh: prefer clang-format-14
Jason Ish [Wed, 6 Dec 2023 16:09:03 +0000 (10:09 -0600)] 
clang-format.sh: prefer clang-format-14

Add clang-format-14 as the preferred version, this is the default on
Ubuntu 22.04.

19 months agocppcheck: Address cpcheck report of an FP
Jeff Lucovsky [Sat, 25 Nov 2023 14:22:19 +0000 (09:22 -0500)] 
cppcheck: Address cpcheck report of an FP

Issue: 6527

Address the FP raised by cppcheck -- note that although the code
corectly checks to ensure that `to_shift != &sb->reqion`, the logic was
detected as a FP. Rework the code to eliminate the FP.

19 months agocppcheck/detect: Address cppcheck memory leak
Jeff Lucovsky [Sat, 25 Nov 2023 14:20:43 +0000 (09:20 -0500)] 
cppcheck/detect: Address cppcheck memory leak

Issue: 6527

Ensure that the `map->string` memory isn't leaked following an error
return from `HashListTableAdd`

19 months agohttp2: do not have leading space for response line
Philippe Antoine [Sun, 19 Nov 2023 19:28:28 +0000 (20:28 +0100)] 
http2: do not have leading space for response line

Ticket: 6547

19 months agodetect/flowbits: remove DETECT_FLOWBITS_CMD_NOALERT 10028/head
Shivani Bhardwaj [Sat, 9 Dec 2023 07:19:31 +0000 (12:49 +0530)] 
detect/flowbits: remove DETECT_FLOWBITS_CMD_NOALERT

DETECT_FLOWBITS_CMD_NOALERT is misleading as it gives an impression that
noalert is a flowbit specific command that'll be used and dealt with at
some point but as soon as noalert is found in the rule lang, signature
flag for noalert is set and control is returned. It never gets added to
cmd of the flowbits object.

19 months agodetect-engine: use flag SIG_FLAG_MPM_NEG
Shivani Bhardwaj [Thu, 7 Dec 2023 08:57:01 +0000 (14:27 +0530)] 
detect-engine: use flag SIG_FLAG_MPM_NEG

The flag SIG_FLAG_MPM_NEG is set before whitelisting the rules. Make it
better by checking for the flag in the beginning and return immediately.

19 months agodetect-engine: use bool return type
Shivani Bhardwaj [Thu, 7 Dec 2023 08:52:41 +0000 (14:22 +0530)] 
detect-engine: use bool return type

19 months agodetect: rename SigAddressPrepare fns to SigPrepare
Shivani Bhardwaj [Thu, 7 Dec 2023 07:23:51 +0000 (12:53 +0530)] 
detect: rename SigAddressPrepare fns to SigPrepare

There is nothing Address specific going on in the preparations.
Stage 1: Preprocessing happens. Sigs classified as IP Only, Masks
applied, content specific limits applied, etc and sig array built.
Stage 2: Sigs grouped by IPOnly, ports and protocols.
Stage 3: Decoder Events SGH built.
Stage 4: File flags set, sig grouping done per prefilter, etc.

19 months agodoc: clarify IP-only with iprep
Shivani Bhardwaj [Thu, 7 Dec 2023 11:48:24 +0000 (17:18 +0530)] 
doc: clarify IP-only with iprep

19 months agogithub/action: fix Debian 12 intermittent failures 10011/head
Victor Julien [Thu, 7 Dec 2023 09:07:24 +0000 (10:07 +0100)] 
github/action: fix Debian 12 intermittent failures

Parallel builds caused issues during `cargo vendor`. So do just a single
thread build.

 make[4]: Entering directory '/__w/suricata/suricata/rust'
cbindgen --config /__w/suricata/suricata/rust/cbindgen.toml \
--quiet --output /__w/suricata/suricata/rust/dist/rust-bindings.h
CARGO_HOME="/github/home/.cargo"  /usr/bin/cargo vendor
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
ERROR: Couldn't execute `cargo metadata` with manifest "/__w/suricata/suricata/rust/Cargo.toml": Metadata(Output { status: ExitStatus(unix_wait_status(25856)), stdout: "", stderr: "    Blocking waiting for file lock on package cache\n    Blocking waiting for file lock on package cache\nerror: failed to download `adler v1.0.2`\n\nCaused by:\n  unable to get packages from source\n\nCaused by:\n  failed to parse manifest at `/github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/adler-1.0.2/Cargo.toml`\n\nCaused by:\n  no targets specified in the manifest\n  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n" })
ERROR: Couldn't generate bindings for /__w/suricata/suricata/rust.
make[4]: *** [Makefile:597: dist/rust-bindings.h] Error 1
make[4]: *** Waiting for unfinished jobs....

19 months agodetect/content-inspect: improve header docs 9999/head
Victor Julien [Wed, 6 Dec 2023 16:32:15 +0000 (17:32 +0100)] 
detect/content-inspect: improve header docs

19 months agodetect/content-inspect: optimize struct layout
Victor Julien [Tue, 26 Sep 2023 08:10:52 +0000 (10:10 +0200)] 
detect/content-inspect: optimize struct layout

Move members used by DetectEngineContentInspection() to the same cache line.

19 months agodetect: optimize struct layout
Victor Julien [Tue, 26 Sep 2023 08:10:14 +0000 (10:10 +0200)] 
detect: optimize struct layout

Move reference count to top of DetectEngineThreadCtx, to move it to the
same cache line as the other members that are checked first in Detect().

19 months agodetect/bytemath: pass match ctx directly
Victor Julien [Tue, 26 Sep 2023 07:34:09 +0000 (09:34 +0200)] 
detect/bytemath: pass match ctx directly

Adjust includes to enable this.

19 months agodetect/payload: remove unneeded pointer reset
Victor Julien [Mon, 25 Sep 2023 08:53:22 +0000 (10:53 +0200)] 
detect/payload: remove unneeded pointer reset

DetectEngineThreadCtx::replist is managed elsewhere.

19 months agodetect/isdataat: optimize recursion mismatches
Victor Julien [Mon, 25 Sep 2023 08:16:27 +0000 (10:16 +0200)] 
detect/isdataat: optimize recursion mismatches

Since recursive content matching goes through the buffer from left to
right, it is possible to bail early when isdataat is part of the
recursive checking. If `isdataat:50,relative` fails for offset 10, it
will surely also fail for offset 20. So break inspection in such cases.

The exception is for dynamic isdataat, where the value is determined
by a prior byte_extract that may be updated during the recursion.

19 months agodetect/content-inspect: flatten branches
Victor Julien [Sun, 24 Sep 2023 05:42:37 +0000 (07:42 +0200)] 
detect/content-inspect: flatten branches

Flatten else branches after terminating ifs.

19 months agodetect/content-inspect: localize recursion counting
Victor Julien [Sun, 24 Sep 2023 04:51:33 +0000 (06:51 +0200)] 
detect/content-inspect: localize recursion counting

Use stack local var instead of DetectEngineThreadCtx member. Instead
setup a stack local struct that both counts and holds the limit. Make sure
the limit is a const so we can avoid rereading it.

This is part of an effort to reduce the size of the DetectEngineThreadCtx
structure and reduce the number of memory writes to it. Additionally, it
is part of an effect to reduce the number of places where detection
tracks various forms of state.

19 months agodetect/content-inspect: reduce scope of internal func
Victor Julien [Sun, 24 Sep 2023 04:56:57 +0000 (06:56 +0200)] 
detect/content-inspect: reduce scope of internal func

19 months agodetect/base64: move content inspection logic
Victor Julien [Sat, 23 Sep 2023 11:01:05 +0000 (13:01 +0200)] 
detect/base64: move content inspection logic

Integrate with rest of content inspect code.

19 months agodetect/krb5.sname: use new content inspect entry
Victor Julien [Sat, 2 Dec 2023 08:45:15 +0000 (09:45 +0100)] 
detect/krb5.sname: use new content inspect entry

19 months agodetect/dns.query: use new content inspect entry
Victor Julien [Sat, 2 Dec 2023 08:44:58 +0000 (09:44 +0100)] 
detect/dns.query: use new content inspect entry

19 months agodetect/content-inspect: add entry for InspectionBuffer
Victor Julien [Sat, 2 Dec 2023 08:44:06 +0000 (09:44 +0100)] 
detect/content-inspect: add entry for InspectionBuffer

This is a convinience addition to abstract away the internals of
the InspectionBuffer in keyword specific detection code.

19 months agodetect/content-inspect: switch type of enum
Victor Julien [Sat, 2 Dec 2023 08:41:02 +0000 (09:41 +0100)] 
detect/content-inspect: switch type of enum

19 months agodetect/content-inspect: assist branch prediction
Victor Julien [Sat, 23 Sep 2023 07:32:14 +0000 (09:32 +0200)] 
detect/content-inspect: assist branch prediction

Hitting the recursion limit should be rare.

19 months agodetect/content-inspect: remove const casting
Victor Julien [Sat, 23 Sep 2023 07:26:12 +0000 (09:26 +0200)] 
detect/content-inspect: remove const casting

19 months agodetect/content-inspect: pass const to inspect func
Victor Julien [Mon, 25 Sep 2023 07:09:33 +0000 (09:09 +0200)] 
detect/content-inspect: pass const to inspect func

19 months agodetect/content-inspect: reduce scope of variables
Victor Julien [Mon, 25 Sep 2023 07:09:07 +0000 (09:09 +0200)] 
detect/content-inspect: reduce scope of variables

19 months agoutil/time: Improve usecs handling in time macros
Stephen Donnelly [Tue, 28 Nov 2023 21:23:45 +0000 (10:23 +1300)] 
util/time: Improve usecs handling in time macros

Fix SCTIME_ADD_SECS zeroing subsecond part

When adding s seconds to SCtime_t ts, don't zero out the ts.usecs field.

Issue: 6584

Fix SCTIME_FROM_TIMESPEC garbage microseconds part

When converting nanosecond to microseconds divide by 1000 instead
of multiplying by 1000.

Issue: 6585

19 months agonapatech: Fix packet timestamps
Ilya Bakhtin [Fri, 29 Sep 2023 14:56:48 +0000 (16:56 +0200)] 
napatech: Fix packet timestamps

Initialize both seconds and useconds of packet timestamp from napatech
timestamp format.

This commit uses updated macro definitions from util-utime.h to avoid
zero seconds value.

Issue: 6372

19 months agoutil/time: Prevent usecs overflow
Ilya Bakhtin [Fri, 29 Sep 2023 14:23:04 +0000 (16:23 +0200)] 
util/time: Prevent usecs overflow

This commit takes care of original seconds value and prevents the
useconds field from overflowing pas its maximum value.

Issue: 6372

19 months agopgsql: don't log password msg if password disabled 9985/head
Juliana Fajardini [Tue, 5 Dec 2023 13:56:28 +0000 (10:56 -0300)] 
pgsql: don't log password msg if password disabled

If the logging of the password is disabled, there isn't much point in
logging the password message itself.

19 months agodoc: add file.name information to smtp keyword doc
jason taylor [Wed, 20 Sep 2023 21:46:04 +0000 (21:46 +0000)] 
doc: add file.name information to smtp keyword doc

Signed-off-by: jason taylor <jtfas90@gmail.com>
19 months agodoc: add file.name information to nfs keyword doc
jason taylor [Wed, 20 Sep 2023 21:42:10 +0000 (21:42 +0000)] 
doc: add file.name information to nfs keyword doc

Signed-off-by: jason taylor <jtfas90@gmail.com>
19 months agodoc: add file.name information to smb keyword doc
jason taylor [Wed, 20 Sep 2023 20:58:21 +0000 (20:58 +0000)] 
doc: add file.name information to smb keyword doc

Signed-off-by: jason taylor <jtfas90@gmail.com>
19 months agodoc: update ftp keyword doc example rule format
jason taylor [Wed, 20 Sep 2023 20:51:52 +0000 (20:51 +0000)] 
doc: update ftp keyword doc example rule format

Signed-off-by: jason taylor <jtfas90@gmail.com>
19 months agodoc: add file.name information to ftp keyword doc
jason taylor [Wed, 20 Sep 2023 20:44:36 +0000 (20:44 +0000)] 
doc: add file.name information to ftp keyword doc

Signed-off-by: jason taylor <jtfas90@gmail.com>
19 months agodoc: add file.name information to http keyword doc
jason taylor [Wed, 20 Sep 2023 20:26:29 +0000 (20:26 +0000)] 
doc: add file.name information to http keyword doc

Signed-off-by: jason taylor <jtfas90@gmail.com>
20 months agoebpf: Update eBPF map to BTF defined map 9978/head
Vincent Li [Wed, 2 Aug 2023 20:31:54 +0000 (20:31 +0000)] 
ebpf: Update eBPF map to BTF defined map

legacy map definition is removed from libbpf1.0+.
update the legacy map definition to BTF defined map.

Distros with < libbpf1.0 (0.5, 0.6, 0.7, 0.8) bpf_helpers.h
support BTF map definition, this change does not break
old libbpf and support new libpbf1.0+.

Bug: #6250

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
Co-authored-by: Victor Julien <vjulien@oisf.net>
20 months agopgsql: remove probe_ts function
Juliana Fajardini [Mon, 27 Nov 2023 20:01:33 +0000 (17:01 -0300)] 
pgsql: remove probe_ts function

With the changes in the probing_ts function, this other one could become
obsolete. Remove it, and directly call `parser::parse_request` when
checking for gaps, instead.

20 months agopgsql: remove unused error handling call
Juliana Fajardini [Mon, 27 Nov 2023 20:17:11 +0000 (17:17 -0300)] 
pgsql: remove unused error handling call

20 months agopgsql: don't log unknown message type
Juliana Fajardini [Mon, 27 Nov 2023 20:16:52 +0000 (17:16 -0300)] 
pgsql: don't log unknown message type

20 months agopgsql: fix probing functions
Juliana Fajardini [Thu, 23 Nov 2023 11:14:24 +0000 (08:14 -0300)] 
pgsql: fix probing functions

Some non-pgsql traffic seen by Suricata is mistankenly identified as
pgsql, as the probing function is too generic. Now, if the parser sees
an unknown message type, even if it looks like pgsql, it will fail.

Bug #6080

20 months agopgsql: add unknonwn frontend message type
Juliana Fajardini [Mon, 27 Nov 2023 20:22:19 +0000 (17:22 -0300)] 
pgsql: add unknonwn frontend message type

We had unkonwn message type for the backend, but not the frontend
messages. It's important to better identify those to improve pgsql
probing functions.

Related to
Bug #6080

20 months agodetect-engine: use ports only after edge case handling 9964/head
Shivani Bhardwaj [Mon, 4 Dec 2023 14:36:57 +0000 (20:06 +0530)] 
detect-engine: use ports only after edge case handling

Also, add comments to clarify what's happening in the code.

20 months agodetect: remove misleading comment
Shivani Bhardwaj [Tue, 21 Nov 2023 08:50:49 +0000 (14:20 +0530)] 
detect: remove misleading comment

The comment seems to have come from the enum for addresses where IPv4
and IPv6 matters.

20 months agodetect/port: remove BUG_ON in favor of PORT_ER
Shivani Bhardwaj [Tue, 21 Nov 2023 08:23:09 +0000 (13:53 +0530)] 
detect/port: remove BUG_ON in favor of PORT_ER

Either the BUG_ON condition would hit or PORT_ER. Prefer to return error
in case of an error as the fn expects that.

20 months agodetect/engine: defensive check and comment update
Shivani Bhardwaj [Mon, 20 Nov 2023 12:30:37 +0000 (18:00 +0530)] 
detect/engine: defensive check and comment update

20 months agodetect: remove redundant null setting
Shivani Bhardwaj [Mon, 20 Nov 2023 11:44:13 +0000 (17:14 +0530)] 
detect: remove redundant null setting

de_ctx->dport_hash_table is already set to NULL in the fn
DetectPortHashFree which is called right before this setting.
Remove the redundant setting.

20 months agodetect: use proper names for whitelist score criteria
Shivani Bhardwaj [Mon, 20 Nov 2023 11:42:54 +0000 (17:12 +0530)] 
detect: use proper names for whitelist score criteria

20 months agodetect/engine: fix whitelisted port range check
Shivani Bhardwaj [Thu, 16 Nov 2023 08:18:06 +0000 (13:48 +0530)] 
detect/engine: fix whitelisted port range check

So far, the condition for checking if the whitelisted port was in the
port range of "a" said

a->port >= w->port && a->port2 <= w->port

But, if a->port <= a->port2, this condition could only be true when
a->port == w->port == a->port2. However, the motivation for this fn was
to be able to find if the whitelisted port for a carrier proto already
was in the range of the given protocol and calculate a score for the
port accordingly.
Fix the range check such that a->port <= w->port <= a->port2.

20 months agodetect: rename whitelist to score
Shivani Bhardwaj [Thu, 16 Nov 2023 08:11:39 +0000 (13:41 +0530)] 
detect: rename whitelist to score

The term "whitelist" is actually used to store a list of DetectPort type
items for tcp and udp in detect.h. Using the same term for also keeping
the score that affects the grouping of rules is confusing. So, rename
the variable to "score".

20 months agodetect-engine: use only the exact match fn
Shivani Bhardwaj [Wed, 1 Nov 2023 10:31:35 +0000 (16:01 +0530)] 
detect-engine: use only the exact match fn

DetectFlagsSignatureNeedsSynPackets checks if TCP SYN flag is set among
other flags.
DetectFlagsSignatureNeedsSynOnlyPackets checks if only TCP SYN flag is
set and no other flag.

Since DetectFlagsSignatureNeedsSynOnlyPackets also already checks for
TCP SYN flag, it does not need to be used in combination with
DetectFlagsSignatureNeedsSynPackets as this fn seems to be the superset
of the former.

20 months agodetect/asn1: handle in PMATCH
Victor Julien [Mon, 25 Sep 2023 18:14:29 +0000 (20:14 +0200)] 
detect/asn1: handle in PMATCH

Since the asn1 keyword is processing payload data, move the handling of
the keyword into the PMATCH with content inspection.

Use u32 as buffer length in the Rust FFI

20 months agoflow/timeout: clean up flow finish code 9939/head
Victor Julien [Fri, 1 Dec 2023 08:47:57 +0000 (09:47 +0100)] 
flow/timeout: clean up flow finish code

20 months agoflow/timeout: use single packet for timeout handling
Victor Julien [Mon, 25 Sep 2023 09:58:03 +0000 (11:58 +0200)] 
flow/timeout: use single packet for timeout handling

In the FlowFinish logic, one or two pseudo packets are used to finish flow
handling. In the case of 2 (one per direction), the logic first set up the
2 packets, then it would process them one by one. This lead to poor cache
locality.

This patch processes the first packet entirely first, followed by the second
packet.

20 months agoflow/timeout: use const TcpSession; cleanup prototypes
Victor Julien [Fri, 1 Dec 2023 08:47:13 +0000 (09:47 +0100)] 
flow/timeout: use const TcpSession; cleanup prototypes

20 months agodetect/content-inspect: minor code cleanups
Victor Julien [Sun, 24 Sep 2023 05:26:24 +0000 (07:26 +0200)] 
detect/content-inspect: minor code cleanups

20 months agodetect/replace: minor code cleanup
Victor Julien [Fri, 22 Sep 2023 08:14:23 +0000 (10:14 +0200)] 
detect/replace: minor code cleanup

20 months agodetect/content: minor code/comment cleanups
Victor Julien [Fri, 22 Sep 2023 07:48:56 +0000 (09:48 +0200)] 
detect/content: minor code/comment cleanups

20 months agodetect/content: use const pointer where possible
Victor Julien [Fri, 22 Sep 2023 08:14:11 +0000 (10:14 +0200)] 
detect/content: use const pointer where possible

20 months agodetect/app-layer-events: constify arguments; minor cleanups
Victor Julien [Wed, 27 Sep 2023 10:23:23 +0000 (12:23 +0200)] 
detect/app-layer-events: constify arguments; minor cleanups

20 months agodetect: improve explanation of offset tracking
Victor Julien [Thu, 12 Oct 2023 13:31:35 +0000 (15:31 +0200)] 
detect: improve explanation of offset tracking

20 months agodetect/content: test cleanup
Victor Julien [Thu, 5 Oct 2023 14:15:28 +0000 (16:15 +0200)] 
detect/content: test cleanup

20 months agodetect/bytejump: fix debug messages
Victor Julien [Thu, 5 Oct 2023 13:46:18 +0000 (15:46 +0200)] 
detect/bytejump: fix debug messages

Remove newlines.

20 months agodetect/file.data: modernize test
Victor Julien [Thu, 5 Oct 2023 14:24:15 +0000 (16:24 +0200)] 
detect/file.data: modernize test

20 months agodetect: modernize unittest
Victor Julien [Thu, 5 Oct 2023 13:33:05 +0000 (15:33 +0200)] 
detect: modernize unittest

20 months agodetect/content-inspect: keyword context as const
Victor Julien [Tue, 26 Sep 2023 13:55:09 +0000 (15:55 +0200)] 
detect/content-inspect: keyword context as const

20 months agodetect/pcre: match data is const at match time
Victor Julien [Thu, 5 Oct 2023 08:25:16 +0000 (10:25 +0200)] 
detect/pcre: match data is const at match time

20 months agodetect/http.uri: modernize unittest
Victor Julien [Mon, 25 Sep 2023 18:40:42 +0000 (20:40 +0200)] 
detect/http.uri: modernize unittest

20 months agoutil/print: minor code cleanups
Victor Julien [Sat, 7 Oct 2023 05:01:20 +0000 (07:01 +0200)] 
util/print: minor code cleanups