Commit Graph

1423 Commits (98b12d1c30e6f8db1e38f3c34abf965a4d03b062)

Author SHA1 Message Date
Shivani Bhardwaj 98b12d1c30 release: 7.0.11; update changelog 3 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)
3 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)
3 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)
3 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
4 months ago
Philippe Antoine 8d45e8c95a rust: allow collapsible_else_if for debug logs
see https://github.com/rust-lang/rust-clippy/issues/15158
4 months ago
Philippe Antoine 30be40a483 rust: make cargo clippy clean
Fixing single_match and manual_find intertwined with SCLogDebug

(cherry picked from commit 38db51b878)
4 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() {
4 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)
4 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)
4 months ago
Philippe Antoine 0e9d05b8e5 snmp: probing parser returns unknown if not enough data
Ticket: 7019
(cherry picked from commit 54a3a18a9e)
5 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)
6 months ago
Jason Ish 2826d670d6 rust: fix rustdoc indentation in lists
Ticket: #7652
6 months ago
Jason Ish 1504dcea4a rust: fix clippy warnings for unspecified extern ABI
Fix done by clippy --fix.

Ticket: #7652
6 months ago
Jason Ish f19e28f121 version: start development towards 7.0.11 6 months 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)
8 months 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)
8 months 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)
8 months ago
Philippe Antoine ac6dcd6fbf quic: handle retry packets
Ticket: 7556
(cherry picked from commit 6d8910d245)
8 months 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)
8 months ago
Philippe Antoine ce90ff187e quic: parse ack frame number 3
cf rfc9000 section 19.3. ACK Frames

Ticket: 7556
(cherry picked from commit 68adc87bd2)
8 months 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)
8 months ago
Jason Ish 13a76e0710 rust: fixes for new clippy warnings
Fixes provided by cargo clippy --fix.
8 months 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)
8 months 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.
8 months 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.
8 months 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)
8 months 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)
8 months 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)
8 months ago
Philippe Antoine a40b37ba44 rust: fix assertions_on_constants for assert!(false)
using panic! instead with a string message

(cherry picked from commit a8199bf2ca)
8 months ago
Jason Ish c7ff76cac5 rust: allow vec_init_then_push in tests
To supress the clippy lint in tests.
8 months ago
Jason Ish 2b6e5f822c mqtt: always use 0x notation for hex in tests
Fixes clippy lint for zero_prefixed_literal.
8 months 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
8 months ago
Giuseppe Longo aabaa95913 sip/parser: accept valid chars
Accepts valid characters as defined in RFC3261.

cherry-picked from commit 7e993d5081
8 months ago
Giuseppe Longo bfcbe48e72 rust/sip: rustfmt sip module
cherry-picked from commit 8ff80cb84d
8 months 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)
10 months 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)
10 months ago
Jason Ish 58c41a7fa9 dns: truncate names larger than 1025 characters
Once a name has gone over 1025 chars it will be truncated to 1025
chars and no more labels will be added to it, however the name will
continue to be parsed up to the label limit in attempt to find the end
so parsing can continue.

This introduces a new struct, DNSName which contains the name and any
flags which indicate any name parsing errors which should not error
out parsing the complete message, for example, infinite recursion
after some labels are parsed can continue, or truncation of name where
compression was used so we know the start of the next data to be
parsed.

This limits the logged DNS messages from being over our maximum size
of 10Mb in the case of really long names.

Ticket: #7280

(cherry picked from commit 3a5671739f)
10 months ago
Jason Ish ccc61f6294 requires: add option to ignore unknown requirements
The new behavior in 8, and backported is to treat unknown requirements
as unsatisfied requirements.

For 7.0.8, add a configuration option, "ignore-unknown-requirements"
to completely ignore unknown requirements, effectively treating them
as available.

Ticket: #7434
10 months ago
Jason Ish eac4854636 requires: treat unknown requires keywords as unmet requirements
For example, "requires: foo bar" is an unknown requirement, however
its not tracked, nor an error as it follows the syntax. Instead,
record these unknown keywords, and fail the requirements check if any
are present.

A future version of Suricata may have new requires keywords, for
example a check for keywords.

Ticket: #7418
(cherry picked from commit 820a3e51b7)
10 months ago
Jason Ish 825eadf1c5 rust: remove unnecessary lifetimes
Fix provided by cargo clipy --fix.

Backport of 7bdbe7ed32.
10 months ago
Jason Ish 60dd1d566c rust/smb: fix rustdoc line
'///' style rust comments/documentation come before the item being
documented.

Spotted by clippy.

(cherry picked from commit aa6e94fc73)
10 months ago
Jason Ish a502c188c5 rust: allow static_mut_refs for now
But we should fix all these soon.

(cherry picked from commit 4c12165816)
10 months ago
Jason Ish 9edac554eb rust: update num-derive to 0.4.2
Includes Cargo.lock.in generated for just this single crate update
(minimal atomic update to keep Cargo.lock in sync with Cargo.toml).

This prevents the clippy warning:

    508 | #[derive(FromPrimitive, Debug)]
        |          ^------------
        |          |
        |          `FromPrimitive` is not local
        |          move the `impl` block outside of this constant `_IMPL_NUM_FromPrimitive_FOR_IsakmpPayloadType`
    509 | pub enum IsakmpPayloadType {
        |          ----------------- `IsakmpPayloadType` is not local
        |
        = note: the derive macro `FromPrimitive` defines the non-local `impl`, and may need to be changed
        = note: the derive macro `FromPrimitive` may come from an old version of the `num_derive` crate, try updating your dependency with `cargo update -p num_derive`
        = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
        = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
        = note: this warning originates in the derive macro `FromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info)

Backport of 8e408d3730.
10 months ago
Jason Ish 4632510308 rust: sync Cargo.lock with Cargo.toml
This just updates some internal dependencies to our own crates in the
work-space.
10 months ago
Philippe Antoine 1bae761818 mqtt: look for a reason code in all messages
instead of stopping on the first message if it does not
have a reason code, like conn and conn_ack

Was fixed in master by big refactor 0a1062fad2
11 months ago
Sascha Steinbiss 378b9bb55d mqtt: add reason code support for SUBACK
Ticket: #7323
(cherry picked from commit 377d4705e1)
11 months ago
Jason Ish c3aa3ae102 http2: rename event variant to match rule
Rename InvalidHTTP1Settings to InvalidHttp1Settings so it gets the
expected name transformation of "invalid_http1_settings".

Ticket: #7361
(cherry picked from commit b1c26dccf3)
11 months ago
Jason Ish bcd3523cc7 rust/applayer: return -1 if event info was not found
The returned event_id was being set to -1, but the function wasn't
returning -1 to indicate error.

Ticket: #7361
11 months ago
Jason Ish 3000e963d5 rust/applayer: use c_int as return type for get_info_by_id
Rust was using i8 as the return type, while C uses int. As of Rust
1.82, the return value is turned to garbage over the FFI boundary.

Ticket: #7338
(cherry picked from commit 45384ef969)
12 months ago