Commit Graph

1436 Commits (32609e6896f9079c175665a94005417cec7637eb)

Author SHA1 Message Date
Jason Ish 767ea29a21 rust: update flate2 to 1.0.35
flate2 depends on adler which is no longer maintained and triggers this
cargo audit warning:

Crate:     adler
Version:   1.0.2
Warning:   unmaintained
Title:     adler crate is unmaintained, use adler2 instead
Date:      2025-09-05
ID:        RUSTSEC-2025-0056
URL:       https://rustsec.org/advisories/RUSTSEC-2025-0056
Dependency tree:
adler 1.0.2
└── miniz_oxide 0.7.1
    └── flate2 1.0.28
        └── suricata 7.0.14-dev

Updating flate2 uses a new maintained fork of adler.

Ticket: #5994
4 months ago
Jason Ish c0e46c2714 rust: fix clippy warning for unused import
While debug_validate_bug_on is still used, it does not need to be
imported directly, as that macro is marked with `macro_export`, making
it globally available to the crate.

(cherry picked from commit 50224f2ee5)
4 months ago
Jeff Lucovsky 3e1f76ade3 nfs: Support EXCLUSIVE4_1 flag
Issue: 8006

Support the EXCLUSIVE4_1 create mode added to NFS 4.1

(cherry picked from commit e1bf5cb1f3)
5 months ago
Shivani Bhardwaj 090542709c release: 7.0.13; update changelog 6 months ago
Philippe Antoine 5abf9b81e7 output/jsonbuilder: helper function SCJbSetPrintAsciiString
To replace C PrintStringsToBuffer and avoid a stack alloc
+ copy

Ticket: 8004
(cherry picked from commit 7447651fa0)
6 months ago
Jason Ish f85944511a ike: don't log duplicate attributes
Track what attributes have been logged and skip over duplicate
attributes to avoid having duplicate fields in the JSON object, which
is invalid JSON.

This is lossy, subsequent attributes are lost.

Ticket: #7923
(cherry picked from commit 35464150de)
6 months ago
Jason Ish fa15ebf7ff ike/detect: info log message should be debug
(cherry picked from commit b543e28402)
6 months ago
Philippe Antoine 6bebd73d71 http2: add INTERNAL_ERROR for http2.error_code keyword 6 months ago
Philippe Antoine 4e0ca599c4 http2: fix parsing of goaway frames
There was a last stream id before the error code
As per section 6.8 of RFC 7540

Ticket: 7991
(cherry picked from commit 9a4a29e218)
6 months ago
Jason Ish f305213aa2 release: 7.0.12; update changelog 7 months ago
Jason Ish 7f49479e9f rust: respect RUSTC and CARGO env vars like CC
To support alternative cargo and rustc programs (such as cargo-1.82),
respect CARGO and RUSTC environment variables during ./configure much
like CC.

RUSTFMT is also respected as that is required for the tests, and Cargo
can't figure this out like it can for rustc (perhaps a bug in the
packaging).

For cbindgen, we have also have to make sure the cargo environment
variable is set for each invocation.

To build with Ubuntu's Rust 1.82 packaging:

  CARGO=cargo-1.82 RUSTC=rustc-1.82 RUSTDOC=rustdoc-1.82 \
      ./configure

Note that setting RUSTDOC is only required for commands like "make
check" to pass.

Ticket: #7877
(cherry picked from commit 6d74656bef)
7 months ago
Philippe Antoine 73501c5671 dns: do not fail parsing on response with data length 0
Ticket: 7574
8 months ago
Jason Ish a84c418323 rust: fix mismatched_lifetime_syntaxes warning
Fix new warning present in Rust 1.89, for example:

warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/ike/parser.rs:295:30
295 | pub fn parse_key_exchange(i: &[u8], length: u16) -> IResult<&[u8], KeyExchangePayload> {
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
9 months ago
Shivani Bhardwaj 98b12d1c30 release: 7.0.11; update changelog 10 months ago
Philippe Antoine 7fa88ea9e7 http2: do not set file flags for global txs
Global txs means here txs with stream id 0, used for connection control
messages.

(cherry picked from commit fa8d3a4ccb)
10 months ago
Philippe Antoine de2bdfec99 http2: mark old txs as updated
As is done in the other case a few lines below

(cherry picked from commit 349c21af2c)
10 months ago
Philippe Antoine 97eee2cada http2: forbid data on stream 0
Ticket: 7658

Suricata will not handle well if we open a file for this tx,
do not close it, but set the transaction state to completed.

RFC 9113 section 6.1 states:

If a DATA frame is received whose Stream Identifier field is 0x00,
the recipient MUST respond with a connection error (Section 5.4.1)
 of type PROTOCOL_ERROR.

(cherry picked from commit 1d6d331752)
10 months ago
Philippe Antoine 805ac10fad rust/smb: fix manual_unwrap_or_default
warning: match can be simplified with `.unwrap_or_default()`
   --> src/smb/smb2.rs:682:41
    |
682 |                           let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
    |  _________________________________________^
683 | |                             Some(p) => p,
684 | |                             None => {
685 | |                                 SCLogDebug!("SMBv2 response: GUID NOT FOUND");
686 | |                                 Vec::new()
687 | |                             },
688 | |                         };
    | |_________________________^ help: replace it with: `state.ssn2vec_map.remove(&guid_key).unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
    = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default
10 months ago
Philippe Antoine 8d45e8c95a rust: allow collapsible_else_if for debug logs
see https://github.com/rust-lang/rust-clippy/issues/15158
10 months ago
Philippe Antoine 30be40a483 rust: make cargo clippy clean
Fixing single_match and manual_find intertwined with SCLogDebug

(cherry picked from commit 38db51b878)
10 months ago
Philippe Antoine 9a0edd0ce5 rust/dns: fix clippy char_indices_as_byte_indices
error: indexing into a string with a character position where a byte index is expected
  --> src/dns/detect.rs:45:39
   |
45 |                 let code: u8 = opcode[i..].parse().map_err(|_| ())?;
   |                                       ^
   |
   = note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
  --> src/dns/detect.rs:36:10
   |
36 |     for (i, c) in opcode.chars().enumerate() {
   |          ^                       ^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices
   = note: `#[deny(clippy::char_indices_as_byte_indices)]` on by default
help: consider using `.char_indices()` instead
   |
36 -     for (i, c) in opcode.chars().enumerate() {
36 +     for (i, c) in opcode.char_indices() {
10 months ago
Philippe Antoine b027350efc rust: update brotli crate to latest version
Ticket: 7735

New version has a fix for an integer underflow

(cherry picked from commit 97591230a9)
10 months ago
Philippe Antoine dd4687486b dcerpc: use wrapping to prevent u16 overflow
Otherwise, rust with debug assertion may trigger a panic

Ticket: 7730

(cherry picked from commit 261d2ad63b)
11 months ago
Philippe Antoine 0e9d05b8e5 snmp: probing parser returns unknown if not enough data
Ticket: 7019
(cherry picked from commit 54a3a18a9e)
11 months ago
Philippe Antoine 858739519d rust: fix clippy warning manual_contains
warning: using `contains()` instead of `iter().any()` is more efficient
   --> src/http2/http2.rs:267:20
    |
267 |                 if block.value.iter().any(|&x| x == b'@') {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `block.value.contains(&b'@')`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
    = note: `#[warn(clippy::manual_contains)]` on by default

(cherry picked from commit 0f3932afb7)
1 year ago
Jason Ish 2826d670d6 rust: fix rustdoc indentation in lists
Ticket: #7652
1 year ago
Jason Ish 1504dcea4a rust: fix clippy warnings for unspecified extern ABI
Fix done by clippy --fix.

Ticket: #7652
1 year ago
Jason Ish f19e28f121 version: start development towards 7.0.11 1 year ago
Philippe Antoine 782f35c5cf app-layer: track modified/processed txs
To optimize detection, and logging, to avoid going through
all the live transactions when only a few were modified.

Two boolean fields are added to the tx data: updated_tc and ts
The app-layer parsers are now responsible to set these when
needed, and the logging and detection uses them to skip
transactions that were not updated.

There may some more optimization remaining by when we set
both updated_tc and updated_ts in functions returning
a mutable transaction, by checking if all the callers
are called in one direction only (request or response)

Ticket: 7087
(cherry picked from commit b02557ac7d)
1 year ago
Philippe Antoine 05bf4a8dec 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.

(cherry picked from commit 726de5520f)
1 year ago
Philippe Antoine 530f1a40e4 quic: decrypt only initial packets
Ticket: 7556

Avoids failed_decrypt events when the first packet seen is not
a Quic Initial packet

(cherry picked from commit d61f36c66f)
1 year ago
Philippe Antoine ac6dcd6fbf quic: handle retry packets
Ticket: 7556
(cherry picked from commit 6d8910d245)
1 year ago
Philippe Antoine 31d57ef7fc 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

(cherry picked from commit f295cc059d)
1 year ago
Philippe Antoine ce90ff187e quic: parse ack frame number 3
cf rfc9000 section 19.3. ACK Frames

Ticket: 7556
(cherry picked from commit 68adc87bd2)
1 year ago
Philippe Antoine 26a1d02722 quic: move all_consuming check to callee
Will alow to have decode_frames accept one additional parameter
with past fragment data

(cherry picked from commit ee04d667b5)
1 year ago
Jason Ish 13a76e0710 rust: fixes for new clippy warnings
Fixes provided by cargo clippy --fix.
1 year ago
Philippe Antoine 7fce4ef077 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

(cherry picked from commit 8ae5665767)
1 year ago
Jason Ish ac62d1bc46 dns: refactor tests to avoid assert!(false)
Mostly just unwrap instead of match as unwrap provides good
context. And replace a few assert!(false) with a descriptive panic.
1 year ago
Jason Ish 6666555a09 rust: allow clippy::unused_unit for tests that use the test macro
The cause of the issue comes from the macro, which is provided by a
crate. Bust just to allow this for now.
1 year ago
Shivani Bhardwaj 17b8f1f7d7 dns: fix clippy lint warnings
Fix vector lint issues:
- same_item_push
- vec_init_then_push

(cherry picked from commit 2c0d3b83c4)
1 year ago
Philippe Antoine 57111f35c3 rust: fix assertions_on_constants for assert!(true)
Which will be optimized away by the compiler

(cherry picked from commit c49463c86f)
1 year ago
Philippe Antoine ab089b0859 rust: fix single_binding
error: this match could be written as a `let` statement
   --> src/nfs/nfs3_records.rs:747:9
    |
747 | /         match result {
748 | |             (r, request) => {
749 | |                 assert_eq!(r.len(), 0);
750 | |                 assert_eq!(request.handle, expected_handle);
751 | |                 assert_eq!(request.name_vec, br#"bln"#);
752 | |             }
753 | |         }
    | |_________^

(cherry picked from commit 259cdf169e)
1 year ago
Philippe Antoine a40b37ba44 rust: fix assertions_on_constants for assert!(false)
using panic! instead with a string message

(cherry picked from commit a8199bf2ca)
1 year ago
Jason Ish c7ff76cac5 rust: allow vec_init_then_push in tests
To supress the clippy lint in tests.
1 year ago
Jason Ish 2b6e5f822c mqtt: always use 0x notation for hex in tests
Fixes clippy lint for zero_prefixed_literal.
1 year ago
Giuseppe Longo b3e6a8f15d sip/parser: enforce valid chars for sip version
The `is_version_char` function incorrectly allowed characters that are not
part of the valid SIP version "SIP/2.0".

For instance, 'HTTP/1.1' was mistakenly accepted as a valid SIP version,
although it's not.

This commit fixes the issue by updating the condition to strictly
check for the correct version string.

cherry-picked from commit 69f841c998
1 year ago
Giuseppe Longo aabaa95913 sip/parser: accept valid chars
Accepts valid characters as defined in RFC3261.

cherry-picked from commit 7e993d5081
1 year ago
Giuseppe Longo bfcbe48e72 rust/sip: rustfmt sip module
cherry-picked from commit 8ff80cb84d
1 year ago
Jason Ish 71212b78bd dns: provide events for recoverable parse errors
Add events for the following resource name parsing issues:

- name truncated as its too long
- maximum number of labels reached
- infinite loop

Currently these events are only registered when encountered, but
recoverable. That is where we are able to return some of the name,
usually in a truncated state.

As name parsing has many code paths, we pass in a pointer to a flag
field that can be updated by the name parser, this is done in
addition to the flags being set on a specific name as when logging we
want to designate which fields are truncated, etc. But for alerts, we
just care that something happened during the parse. It also reduces
errors as it won't be forgotten to check for the flags and set the
event if some new parser is written that also parses names.

Ticket: #7280

(cherry picked from commit 19cf0f8133)
1 year ago
Jason Ish 5edb84fe23 eve/dns: add truncation flags for fields that are truncated
If rrname, rdata or mname are truncated, set a flag field like
'rrname_truncated: true' to indicate that the name is truncated.

Ticket: #7280

(cherry picked from commit 37f4c52b22)
1 year ago