Commit Graph

15223 Commits (47c9a14543dff9c57a2797752691617f7ddaadb2)
 

Author SHA1 Message Date
Shivani Bhardwaj 47c9a14543 detect-engine: use bool return type 2 years ago
Shivani Bhardwaj bd41b31005 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.
2 years ago
Shivani Bhardwaj b9540df5ad doc: clarify IP-only with iprep 2 years ago
Victor Julien c82d93490c 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....
2 years ago
Victor Julien 332c2ea470 detect/content-inspect: improve header docs 2 years ago
Victor Julien 06c809573b detect/content-inspect: optimize struct layout
Move members used by DetectEngineContentInspection() to the same cache line.
2 years ago
Victor Julien 0014077a36 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().
2 years ago
Victor Julien 53591702aa detect/bytemath: pass match ctx directly
Adjust includes to enable this.
2 years ago
Victor Julien e2fbcf9654 detect/payload: remove unneeded pointer reset
DetectEngineThreadCtx::replist is managed elsewhere.
2 years ago
Victor Julien 6db02563f1 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.
2 years ago
Victor Julien c19d11ff0d detect/content-inspect: flatten branches
Flatten else branches after terminating ifs.
2 years ago
Victor Julien 4cce7ba48b 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.
2 years ago
Victor Julien 97f78e1b49 detect/content-inspect: reduce scope of internal func 2 years ago
Victor Julien e9b33c48f0 detect/base64: move content inspection logic
Integrate with rest of content inspect code.
2 years ago
Victor Julien 6a01f40d40 detect/krb5.sname: use new content inspect entry 2 years ago
Victor Julien c9ab95cbe2 detect/dns.query: use new content inspect entry 2 years ago
Victor Julien d73cce478c 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.
2 years ago
Victor Julien b357532e7e detect/content-inspect: switch type of enum 2 years ago
Victor Julien 1f265d9d79 detect/content-inspect: assist branch prediction
Hitting the recursion limit should be rare.
2 years ago
Victor Julien b1fa975503 detect/content-inspect: remove const casting 2 years ago
Victor Julien 0ba4b297df detect/content-inspect: pass const to inspect func 2 years ago
Victor Julien a7c9028f01 detect/content-inspect: reduce scope of variables 2 years ago
Stephen Donnelly 0850e3d137 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
2 years ago
Ilya Bakhtin 417806ca35 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
2 years ago
Ilya Bakhtin d3095ac058 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
2 years ago
Juliana Fajardini bdec2d8ea8 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.
2 years ago
jason taylor fc81c99b58 doc: add file.name information to smtp keyword doc
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor 9d1ad0187e doc: add file.name information to nfs keyword doc
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor 327ba7397a doc: add file.name information to smb keyword doc
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor e4077b8803 doc: update ftp keyword doc example rule format
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor bb1f7575d3 doc: add file.name information to ftp keyword doc
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor bbc17b1c7d doc: add file.name information to http keyword doc
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
Vincent Li 64d12aacc8 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>
2 years ago
Juliana Fajardini 9aeeac532e 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.
2 years ago
Juliana Fajardini 53d29f652a pgsql: remove unused error handling call 2 years ago
Juliana Fajardini afd6e4dc41 pgsql: don't log unknown message type 2 years ago
Juliana Fajardini 4f85d06192 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
2 years ago
Juliana Fajardini 1ac5d97259 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
2 years ago
Shivani Bhardwaj c1bf955326 detect-engine: use ports only after edge case handling
Also, add comments to clarify what's happening in the code.
2 years ago
Shivani Bhardwaj 77eb85e224 detect: remove misleading comment
The comment seems to have come from the enum for addresses where IPv4
and IPv6 matters.
2 years ago
Shivani Bhardwaj 8960a86f4f 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.
2 years ago
Shivani Bhardwaj d8a887e518 detect/engine: defensive check and comment update 2 years ago
Shivani Bhardwaj 945ec4bc0a 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.
2 years ago
Shivani Bhardwaj 6076b9e2f0 detect: use proper names for whitelist score criteria 2 years ago
Shivani Bhardwaj 4a00ae6076 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.
2 years ago
Shivani Bhardwaj 2b73a17bb0 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".
2 years ago
Shivani Bhardwaj 1f78a4fcd8 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.
2 years ago
Victor Julien d3ccff5822 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
2 years ago
Victor Julien 13cc493885 flow/timeout: clean up flow finish code 2 years ago
Victor Julien ea4503c3e3 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.
2 years ago