Commit Graph

16755 Commits (ff8d4e972c2ec640055cdad072ab1bd81d794c77)
 

Author SHA1 Message Date
Victor Julien 7fd707a876 flow/manager: add chunk debug output 2 years ago
Victor Julien ae072d5c07 flow/manager: fix multi instance row tracking
In multi instance flow manager setups, each flow manager gets a slice
of the hash table to manage. Due to a logic error in the chunked
scanning of the hash slice, instances beyond the first would always
rescan the same (first) subslice of their slice.

The `pos` variable that is used to keep the state of what the starting
position for the next scan was supposed to be, was treated as if it held
a relative value. Relative to the bounds of the slice. It was however,
holding an absolute position. This meant that when doing it's bounds
check it was always considered out of bounds. This would reset the sub-
slice to be scanned to the first part of the instances slice.

This patch addresses the issue by correctly handling the fact that the
value is absolute.

Bug: #7365.

Fixes: e9d2417e0f ("flow/manager: adaptive hash eviction timing")
2 years ago
Juliana Fajardini a9b36d88b8 detect/engine/flowint: apply clang format changes
Related to
Task #7426
2 years ago
Juliana Fajardini 6e4a501e7c flowint: add isnotset support
Similar keywords use `isnotset`, while `flowint` only accepted `notset`
Opted to change the code, not only the regex, to keep the underlying
code also following the same patterns.

Task #7426
2 years ago
Victor Julien 2fe2cf8553 eve/alert: enrich decoder event
Default decoder event alert was very sparse, not even logging packet
type and pcap_cnt. Expand support for this record type. It will be more
useful with the ethernet headers and packet field, but these are still
disabled by default.

Ticket: #7433.
2 years ago
Victor Julien b23fa51e33 detect: fix decoder only events
Add missing setup part of the decoder event sgh.

Bug: #7414.
2 years ago
Philippe Antoine 09ba69cfb0 output/http: log invalid status as a string
Ticket: 7311

If response_status_number is not a valid poisitive integer,
we should not try to parse it again, and fail again,
but just log the raw string.
2 years ago
Victor Julien 923ad6af77 af-packet: speed up thread sync during startup
Threads are initialized sequentially to allow for a predictable mapping
of threads and queues. Not all parts of the start up need to be done
sequentially. The setting up of the rings can be very expensive, taking
of a couple of hundred milliseconds. The ring setup doesn't need to be
done sequentially though.

This patch releases the thread early, after bind but before the ring
setups.

Ticket: #7272.
2 years ago
Philippe Antoine b58b886db7 detect/transforms: in place modifications of buffers
As is the case when chaining multiple transforms.
Avoids using memcpy in these cases.

Add tests for these cases.

Ticket: 7409
2 years ago
dependabot[bot] e9173f3b06 github-actions: bump github/codeql-action from 3.27.0 to 3.27.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.27.0...v3.27.5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] c73e90e305 github-actions: bump codecov/codecov-action from 4.6.0 to 5.0.7
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.6.0 to 5.0.7.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](b9fd7d16f6...015f24e681)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jason Ish 289ff25f5b requires: support requires check for keyword
For example:

    requires: keyword foo;

Will require that Suricata supports the "foo" keyword.

Ticket: #7403
2 years ago
Jason Ish 8bcc844b6f sigtable: add function to test for a keyword
To be used by the requires keyword to check for keyword support.

Ticket: #7403
2 years ago
Jason Ish 820a3e51b7 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
2 years ago
Victor Julien ae10fc3de4 codecov: expect 5 flags to be submitted
Flags are:
- unittests
- suricata-verify
- pcap
- livemode
- fuzzcorpus

This should make sure codecov only adds its report after receiving
the results for each of the flags.
2 years ago
Victor Julien 663fa0c518 github-actions: add basic commandline tests
Run various commandlines, checking that they don't error/crash.

Also counts towards coverage.
2 years ago
Victor Julien d7e1a8f7da github-actions: fix codecov for unittests
Don't overwrite ut coverage with later tests.
2 years ago
Jason Ish 4c12165816 rust: allow static_mut_refs for now
But we should fix all these soon.
2 years ago
Jason Ish aa6e94fc73 rust/smb: fix rustdoc line
'///' style rust comments/documentation come before the item being
documented.

Spotted by clippy.
2 years ago
Jason Ish 7bdbe7ed32 rust: remove unnecessary lifetimes
Fix provided by cargo clippy --fix.
2 years ago
Jason Ish 8e408d3730 rust: update num-derive to 0.4.2
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)
2 years ago
Jason Ish 287d8360e7 util-buffer: expand by multiples of 4k 2 years ago
Jason Ish 2e2eaac0b2 output-json: cleanup, have OutputJsonBuilderBuffer return void
The return value was never used.
2 years ago
Jason Ish d39e42728a output-json: drop eve records that are too long
In the situation where the mem buffer cannot be expanded to the
requested size, drop the log message.

For each JSON log context, a warning will be emitted once with a partial
bit of the log record being dropped to identify what event types may be
leading to large log records.

This also fixes the call to MemBufferExpand which is supposed be
passed the amount to expand by, not the new size required.

Ticket: #7300
2 years ago
Nancy Enos 2d13df6872 configure: Remove obsolete rust support line
Ticket: #6705
2 years ago
Philippe Antoine 4ec90bd227 detect: absent keyword to test absence of sticky buffer
Ticket: 2224

It takes an argument to match only if the buffer is absent,
or it can still match if the buffer is present, but we test
the absence of some content.

For multi buffers, absent matches if there are 0 buffers.

For file keywords, absent matches if there is no file.
2 years ago
Philippe Antoine 7682816ef9 http1/detect: code simplification
- DetectEngineInspectBufferHttpHeader is only used with ALPROTO_HTTP1
- engine->progress should be HTP_REQUEST_HEADERS or HTP_RESPONSE_HEADERS based on the direction
2 years ago
Victor Julien 13f420c793 detect/ip-only: code cleanups
Move repeated pattern into helper function.
2 years ago
Victor Julien a8c63992fb detect/sigorder: remove data structs from global namespace
Rename types enum to reflect it is not using a radix tree anymore.
2 years ago
Victor Julien 4aeb606a97 detect/ip-only: remove dead code 2 years ago
Victor Julien 3eb2f6a584 radix: remove old radix tree implementation
No longer used.
2 years ago
Victor Julien 0ea6fe668e detect/iponly: reimplement with radix4 for ipv6
Use a more compact ipv6 specific structure.
2 years ago
Victor Julien 4b6296c848 detect/iponly: reimplement with radix4 for ipv4
Use a more compact ipv4 specific structure.
2 years ago
Victor Julien 8536dd51b5 host-os-policy: switch to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
2 years ago
Victor Julien 82cd053fc8 htp: switch config tree to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
2 years ago
Victor Julien 46fb7bb162 defrag/config: switch to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
2 years ago
Victor Julien c75b29c74f reputation: switch cidr handling to radix4/6
Splits the unified tree into a ipv4 specific and ipv6 specific tree.
2 years ago
Victor Julien 8f03a2eb9b radix: implement more compact trees
Implement a more compact set of trees specifically for IPv4
and IPv6 addresses. This allows for more compact data structures
and fewer memory allocations.

Based on the existing radix tree implementation.
2 years ago
Victor Julien e9a2352b99 host-os-info: test cleanup 2 years ago
Pierre Chifflier bd7d38e91e ldap: add support for STARTTLS to make certificate information available
Ticket: #7394.
2 years ago
Pierre Chifflier 3341907125 ldap: add port 3268 (used by Active Directory) 2 years ago
Philippe Antoine c26cb9abd3 detect/transform: fix leak in xor transform parse
Fixes: 8984bc6801 ("transforms: move xor to rust")
2 years ago
Jason Ish 13841c0b9e rust: put all rust/cargo env vars in CARGO_ENV
To ensure that all calls to cargo use the same environment variables,
put the environment variables in CARGO_ENV so every call to cargo can
easily use the same vars.

The Cargo build system is smarter than make, it can detect a change in
an environment variable that affects the build, and the setting of
SURICATA_LUA_SYS_HEADER_DST changing could cause a rebuild.

Also update suricata-lua-sys, which is smarter about copying headers. It
will only copy if the destination does not exist, or the source header
is newer than the target, which can also prevent unnecessary rebuilds.

This is mainly to fix an issue where subsequent builds may fail,
especially when running an editor with a LSP enabled:

    Update lua crate to 0.1.0-alpha.5. This update will force a rewrite of
    the headers if the env var SURICATA_LUA_SYS_HEADER_DST changes. This
    fixes the issue where the headers may not be written.

    The cause is that Rust dependencies are cached, and if your editor is
    using rust-analyzer, it might cache the build without this var being
    set, so these headers are not available to Suricata. This crate update
    forces the re-run of the Lua build.rs if this env var changes, fixing
    this issue.
2 years ago
Eric Leblond 138898f5c2 github-actions: add list keywords and app layers
Add the 2 command line options to coverage build.
2 years ago
Eric Leblond be7cea4d32 suricata: fix list-keywords option
The list keywords option was crashing due to improper init.

Ticket: 7397
2 years ago
Shivani Bhardwaj d0427a2833 detect/smb: fix the sigmatch table for url
sigmatch_table for url entry was incorrectly set to DETECT_FLOW_AGE.
2 years ago
Jason Ish 5d766df12b make: install-headers: rust-bindings.h
rust-bindings.h was not being installed with "make install-headers",
and its now pulled in by a header used for plugin support, so make
sure its installed.

We first attempt to install the "dist" version if exists, otherwise
install the "gen" one. Also install the "gen" even if the "dist" one
exists, as its going to be newer.
2 years ago
Jason Ish 2ac16ee1a6 detect: break apart sigtable setup and initialization
Allows initialization to be done early, so the table is ready for
dynamic registration by plugins which are loaded before signature
setup.
2 years ago
Jason Ish 83b1e40028 examples/plugin: update to find generated rust header
Needed for changes to output-eve.h.
2 years ago
Jason Ish b660ff8aff eve: user callbacks for adding additional data
Provide a way for library/plugin users to register a callback that
will be called prior to an EVE record being closed. The callback will
be passed ThreadVars, Packet, and Flow pointers if available, as well
as private user data.
2 years ago