Commit Graph

1666 Commits (master)

Author SHA1 Message Date
Jason Ish 2e52e9501f mqtt: naming and visibility cleanups
- remove rs_prefix, replace with SC if needed
- remove pub and no_mangle where not needed
- remove some unused functions and fields

Related to ticket: #7498
15 hours ago
Jason Ish 0fe11cdfe5 enip: remove rs_ prefix
Related to ticket: #7498
15 hours ago
Jason Ish c726d67bb0 dcerpc: visibility and naming cleanups
- replace rs_ prefixed names with SC
- remove no_mangle and pub where not needed
- remove some unused functions

Related to ticket: #7498
15 hours ago
Jason Ish f0116c3a6b bittorrent: no_mangle, pub and naming cleanups
- Remove rs_prefix
- Remove no_mangle and pub when not needed

Related to ticket: #7498
15 hours ago
Jason Ish 05dd607f34 rust: use CBINDGEN variable and not "cbindgen"
This uses the cbindgen found during ./configure, and not the one
found on the path during "make", which while often the same, aren't
always the same.

Ticket: #6384
15 hours ago
Jeff Lucovsky 9b088ed018 applayer/ftp: Misc cleanup
Issue: 4082

Small fixups.
1 day ago
Jeff Lucovsky b7d240fb14 applayer/ftp: Move MPM declaration
This commit moves the MPM fn declaration into core.rs making it
available for other Rust modules.

Issue: 4082
1 day ago
Jeff Lucovsky 4d0cf8a8fa app-layer/ftp: Fixup state values
Issue: 4082

Fixup the incorrect state values -- they should be the default enum
values to match the pre-Rust implementation.
1 day ago
Jason Ish 8fa347410e suricatactl: rust version of suricatactl 2 days ago
Jason Ish 8115669602 suricatasc: a Rust implementation of suricatasc
This is a re-implementation of suricatasc program in Rust that
attempts to be a 100% drop-in replacement.
2 days ago
Jason Ish c33bebd630 rust: remove allow of static mutables
As references to static mutables are highly discouraged, remove the
global suppressing of the compiler warning. Each use case can be
suppressed as needed.

Ticket: #7417
2 days ago
Jason Ish 4a2f10d235 smb: wrap read access to static mutables in function
Simply wrapping in a function removes static_mut_refs compiler
warning.

Ticket: #7417
2 days ago
Jason Ish d8c080b268 smtp: suppress static_mut_refs where needed
Allows us to get rid of the global supression.

Ticket: #7417
2 days ago
Jason Ish 9ed5b4c002 smtp: remove SCMimeSmtpConfigExtractUrlsSchemeReset
It doesn't appear to be needed. The vec being cleared is only set once
per run, so never needs to be cleared.

Removes one point where we have to supress the static_mut_refs compiler
warning.

Ticket: #7417
2 days ago
Jeff Lucovsky dd344bd07c ftp: Move config file handling to Rust
Issue: 4082

Move the configuration file handling to Rust.

These changes will no longer terminate Suricata when there's an invalid
value for ftp.memcap. Like earlier Suricata releases, an error message
is logged "Invalid value <value> for ftp.memcap" but Suricata will no
longer terminate execution. It will use a default value of "0" instead.
3 days ago
Jeff Lucovsky f0410c93d0 ftp: convert enumerations to Rust
As part of the effort to convert the FTP/FTPDATA parser to rust, move
the enums from C to rust.

Issue: 4082
3 days ago
Philippe Antoine 8c3bd3e8a0 dcerpc: consume bytes after gap resync
Ticket: 7567

After a gap, we search a new record that may start later than
the beginning of current stream slice.
If so, consume the first bytes before the start of the record,
so that AppLayerResult::incomplete can be consistent and not
trigger assertion !((res.needed + res.consumed < input_len))
3 days ago
Philippe Antoine 3bc2a14fbf rust: fix clippy 1.85 precedence warnings
warning: operator precedence can trip the unwary
   --> src/jsonbuilder.rs:781:36
    |
781 |                 buf[offset] = HEX[(x >> 4 & 0xf) as usize];
    |                                    ^^^^^^^^^^^^ help: consider parenthesizing your expression: `(x >> 4) & 0xf`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `#[warn(clippy::precedence)]` on by default
1 week ago
Philippe Antoine 726de5520f quic: discard late retry packets
Ticket: 7556

See RFC 9000 section 17.2.5.2 :
After the client has received and processed an Initial
or Retry packet from the server,
it MUST discard any subsequent Retry packets that it receives.
1 week ago
Shivani Bhardwaj a551674eae dcerpc: add iface to dcerpc request event
so as to avoid extra steps for correlation among events to find
this information.

Feature 7565
1 week ago
Jason Ish 4cdb879538 rust/bindgen: use temp file to generating bindings
Prefixing a file with sed doesn't appear to be portable. Instead, make
use of a temporary file.

Fixes generating the bindings on FreeBSD and Mac.
1 week ago
Alice Akaki 73ae6e997f detect: add ldap.responses.dn
ldap.responses.dn matches on LDAPDN from responses operations
This keyword maps the following eve fields:
ldap.responses[].search_result_entry.base_object
ldap.responses[].bind_response.matched_dn
ldap.responses[].search_result_done.matched_dn
ldap.responses[].modify_response.matched_dn
ldap.responses[].add_response.matched_dn
ldap.responses[].del_response.matched_dn
ldap.responses[].mod_dn_response.matched_dn
ldap.responses[].compare_response.matched_dn
ldap.responses[].extended_response.matched_dn
It is a sticky buffer
Supports prefiltering

Ticket: #7471
1 week ago
Alice Akaki 16dcee46fc detect: add ldap.request.dn
ldap.request.dn matches on LDAPDN from request operations
This keyword maps the following eve fields:
ldap.request.bind_request.name
ldap.request.add_request.entry
ldap.request.search_request.base_object
ldap.request.modify_request.object
ldap.request.del_request.dn
ldap.request.mod_dn_request.entry
ldap.request.compare_request.entry
It is a sticky buffer
Supports prefiltering

Ticket: #7471
1 week ago
Alice Akaki 7b350e9933 misc: fix name prefix in detect register functions 1 week ago
Philippe Antoine d61f36c66f quic: decrypt only initial packets
Ticket: 7556

Avoids failed_decrypt events when the first packet seen is not
a Quic Initial packet
1 week ago
Philippe Antoine 6d8910d245 quic: handle retry packets
Ticket: 7556
1 week ago
Philippe Antoine f295cc059d quic: handle fragmented hello over multiple packets
Ticket: 7556

To do so, we need to add 2 buffers (one for each direction)
to the QuicState structure, so that on parsing the second packet
with hello/crypto fragment, we still have the data of the first
hello/crypto fragment.

Use a hardcoded limit so that these buffers cannot grow indefinitely
and set an event when reaching the limit
1 week ago
Philippe Antoine 68adc87bd2 quic: parse ack frame number 3
cf rfc9000 section 19.3. ACK Frames

Ticket: 7556
1 week ago
Philippe Antoine ee04d667b5 quic: move all_consuming check to callee
Will alow to have decode_frames accept one additional parameter
with past fragment data
1 week ago
Philippe Antoine 294a33a890 quic: rustfmt 1 week ago
Juliana Fajardini ae00181736 pgsql/parser: fix type complexity clippy warning
Cf https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
1 week ago
Juliana Fajardini a4ce9cfe15 pgsql/logger: don't log empty transactions
This may happen in some situations if the app-layer parser only sees
unknown messages and sets an event: there will be an empty transaction,
but nothing to log.

Related to
Task #5566
1 week ago
Juliana Fajardini d676d711ee pgsql: add case for Unknown response message state
No state change, but since we added Unknown responses, we should handle
that case -- should we have a specific state for such cases?

Related to
Bug #5524
Task #5566
1 week ago
Juliana Fajardini 1b6f4da23b pgsql: add events
Events for:
- parsing error when parsing pgsql packet length
- parsing error for pgsql requests (post length parsing)
- parsing error for pgsql responses (post length parsing)
- too many transactions

Include `pgsql-events.rules` file, and PGSQL events SID range definition

Task #5566
1 week ago
Juliana Fajardini 6eadb752ec pgsql/parser: add more debug statements 1 week ago
Juliana Fajardini 38f8508bf5 pgsql: apply rustfmt changes 1 week ago
Juliana Fajardini ff8d4e972c pgsql: don't always return error for parsing errors
This allows the app-proto to continue onto parsing next PDUs, if
possible.

Bug #5524
1 week ago
Juliana Fajardini 4fed424d74 pgsql: don't fail if proto parses unknown message
Even if unknown, if the message is properly parsed, allow the parser to
proceed.

Related to
Bug #5524
1 week ago
Juliana Fajardini cc841e66db pgsql/parser: always use fn for parsing PDU length
Some inner parsers were using it, some weren't. Better to standardize
this. Also take the time to avoid magic numbers for representing the
expected lengths for pgsql PDUs.
Also throwing PgsqlParseError and allowing for incomplete results.

Related to
Task #5566
Bug #5524
1 week ago
Juliana Fajardini 29d3aa7a6a pgsql: add PgsqlParserError
Building on top of work done by Jason Ish.

Related to
Bug #5524
1 week ago
Juliana Fajardini 737fea751f pgsql/parser: simplify response parsing
The initial parsing for message type checking was more complex than
needed be.

Related to
Bug #5524
1 week ago
Juliana Fajardini 24375a1fef pgsql/parser: fix response message length
Some backend messages can be the shortest pgsql length possible,
4 bytes, but the parser expectd all messages to be longer than that.

Related to
Bug #5524
1 week ago
Philippe Antoine b514b25165 detect/flow: move keyword parsing code to rust
for flow.pkts and flow.bytes keywords

Ticket: 7562

Avoid null deref when parsing flow.bytes:toserver;
1 week ago
Philippe Antoine 8ae5665767 detect/krb5: avoid integer underflow with krb5.ticket_encryption
Ticket: 7560

When passing INT32_MIN aka 0x80000000, we cannot compute -vali
as it does not fit into a i32
1 week ago
Jason Ish 10ede91536 rust: add bindings to SCPlugin.* to sys crate
Also disable bindgen's generated layout tests.  They are valid for the
platform generating the tests, but may not be valid for other
platforms. For example, if the tests are generated on a 64 bit
platform the tests will not be valid when run on a 32 bit platform as
pointers are a different size.

However, the generating bindings are valid for both platform.

Ticket: #7341
2 weeks ago
Jason Ish 9b73de6f6d rust: add auto-generated header to sys.rs
We don't keep bindgen's autogenerated do not edit line as it contains
the bindgen version which could break the CI check for out of date
bindings. So add our own do not edit line.

Ticket: #7341
2 weeks ago
Jason Ish 4554c4778d rust: use AppProto from generated bindings instead of duplicating
Have bindgen generate bindings for app-layer-protos.h, then use the
generated definitions of AppProto/AppProtoEnum instead if defining
them ourselves.

This header was chosen as its used by Rust, and its a simple header
with no circular dependencies.

Ticket: #7341
2 weeks ago
Jason Ish 21ccc4f307 rust: integrate bindgen to generate Rust bindings to C
Bindgen works by processing a header file which includes all other
header files it should generate bindings for. For this I've created
bindgen.h which just includes app-layer-protos.h for now as an
example.

These bindings are then generated and saved in the "suricata-sys"
crate and become availale as "suricata_sys::sys".

Ticket: #7341
2 weeks ago
Jason Ish 8f22e55678 rust/sys: stub in suricata-sys crate for Rust bindings to C
Follow Rust convention of using a "sys" crate for bindings to C
functions. The bindings don't exist yet, but will be generated by
bindgen and put into this crate.

Ticket: #7341
2 weeks ago
Shivani Bhardwaj bc79300dfa datasets: move initial file reading to rust
In a recent warning reported by scan-build, datasets were found to be
using a blocking call in a critical section.

datasets.c:187:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
  187 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
datasets.c:292:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
  292 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
datasets.c:368:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
  368 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
datasets.c:442:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
  442 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
datasets.c:512:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
  512 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.

These calls are blocking in the multi tenant mode where several tenants
may be trying to load the same dataset in parallel.
In a single tenant mode, this operation is performed as a part of a
single thread before the engine startup.

In order to evade the warning and simplify the code, the initial file
reading is moved to Rust with this commit with a much simpler handling
of dataset and datarep.

Bug 7398
2 weeks ago