Commit Graph

17729 Commits (master)
 

Author SHA1 Message Date
Jason Ish 1f30746e07 rust/dns: rs_ prefix name cleanup 3 months ago
Victor Julien 3fe9bd7cbb detect/flow: don't overwrite hook direction 3 months ago
Victor Julien 6ee32cba3b firewall: apply action again for stateful matches
For "stateful rules", don't drop packets after the initial match as long
as the tx state doesn't change.

An example of how this could happen was:

        accept:hook ssh:request_started any any -> any any (alert; sid:2000;)
        accept:hook ssh:request_banner_wait_eol any any -> any any (alert; sid:2001;)
        accept:hook ssh:request_banner_done any any -> any any (        \
                ssh.software; content:"OpenSSH_8.2p1"; alert; sid:2002;)

As the ssh session reached the request_banner_done state, it would
remain in this state. So additional packets would again review the rules
for this state. The rule 2002 is stored in the tx state as fully
matched, and would be skipped for the additional packets. This meant
that the `accept:hook` action was not applied and the default drop
policy was triggered.

This is addressed by updating the stateful logic:

If an accept rule has the DE_STATE_FLAG_FULL_INSPECT flag set, and the
tx progress is not progressed beyond the rule, apply the rule accept
acction.
3 months ago
Victor Julien b1f955ef5a firewall: move app action setting into helper func
In preparation of adding another callsite.
3 months ago
dependabot[bot] 4b89dafb44 github-actions: bump actions/download-artifact from 4.2.1 to 4.3.0
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.2.1 to 4.3.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](95815c38cf...d3f86a106a)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
3 months ago
dependabot[bot] af2b56e9fb github-actions: bump github/codeql-action from 3.28.13 to 3.28.16
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.16.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.13...v3.28.16)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 months ago
dependabot[bot] 1f846bc131 github-actions: bump codecov/codecov-action from 5.4.0 to 5.4.2
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](0565863a31...ad3126e916)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 months ago
Jason Ish 4c695b1075 doc/devguide: document the rate filter callback
Ticket: #7673
3 months ago
Jason Ish f968a7bfb0 doc: add rst header order recommendation
Ticket: #7396
3 months ago
Jason Ish 60c429e04d detect: add callback for when rate filter changes action
This callback will be called when alert action has been changed due to a
rate filter. The user can then reset or customize the action in their
callback per their own logic.

As the callback is added to the current detection engine, make sure its
copied to the new detection engine on reload.

Ticket: #7673
3 months ago
Jason Ish 23c5fafe5c decode: documentation group for packet alert flags
As #define's like this can't be logically grouped into an enum, try
Doxygen documentation groups, which create a group just of these flag
values and documents them together on a page.
3 months ago
Jason Ish 1b7496bf5b decode: use BIT macros for flags; consistent naming
Use the BIT_U8 macros for packet alert flags and rename
PACKET_ALERT_RATE_FILTER_MODIFIED to
PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED for consistency.
3 months ago
Victor Julien e3ae4b005e detect/ftpbounce: reuse generic hook 3 months ago
Victor Julien 3c5ce91cbb ftp: per direction tx progress
For request side, having a tx means the request is done.

For response, wait for tx to be marked complete.

Remove unused states.
3 months ago
Jason Ish 810a47cd60 github-ci: pin bindgen test to bindgen v0.66.0 3 months ago
Jason Ish 8102fbfd0c doc/userguide: fix typo in lua flowvar lib
Was importing suricata.flow, not suricata.flowvar.
3 months ago
Jason Ish 8a5bc12156 lua: convert lua flowint functions to lib: suricata.flowintlib
Ticket: #7487
3 months ago
Jason Ish 12e149b99b build: separate private headers from installed headers
Create a new list of headers for headers that should never be
installed, such as private headers that should only be available
within the Suricata project.

For now, just the util-device-private.h belongs to this set.
3 months ago
Jason Ish 8540627b4e examples: add simple c++ example
For now just used to make sure a C++ variation of our custom example
can build.
3 months ago
Jason Ish 9d5158594f util-device: break into public and private definitions
util-device.h exposes some details that are particularly problematic
for C++, even when wrapped in 'extern "C"'. To address this, break the
header into public and private parts. The public part exposes
LiveDevice as an opaque data structure, while the private header has
the actual definition.

The idea is that only Suricata C source files should include the
private header, it should not be re-included in any other header
file. And this is the header library users should use, however we
don't enforce it with tecnical means, a library user could still
include the private header, but the clue there is in the name.
3 months ago
Jason Ish 12fdd6b802 device: move LiveDeviceName from header into source
This data structure is only used by the C file and has no reason to be
exposed in the header.
3 months ago
Jason Ish 272d6c8903 libsuricata-config: fix static library dependency order
When static linking we have a circular dependency between
libsuricata_rust, and libsuricata_c, so we have to list each twice.

An alternative is to use "-Wl,--start-group", but that isn't portable
outside the GNU toolchain.
3 months ago
Jason Ish 49f242b306 libsuricata-config: fix type (status -> static) 3 months ago
Jason Ish 49edd247f7 misc: add c++ support to some headers
For now, just the headers required by our examples.
3 months ago
Jason Ish 23eaa65185 misc: only define _GNU_SOURCE if not defined
C++ compilers on Linux (g++, clang++) appear to always define this.
3 months ago
Victor Julien ff0d609a9f threads: rename function to make scope more clear
SCTmThreadsSlotPktAcqLoopFinish ss now used outside of
just pktacq as well.
3 months ago
Victor Julien 12f8f03532 threads: fix autofp shutdown race condition
Sometimes a single flow pcap would log 2 flows. It turns out FlowWorkToDoCleanup
ran before all the packet threads had processed their "wire" packets. It then
removed a flow that a wire packet would still have needed, leading to the worker
thread creating a new flow for it.

This could happen due to the logic in TmThreadDisableReceiveThreads which calls
TmThreadDrainPacketThreads to made sure it only returns when all autofp-workers
have processed all the packets the autofp-capture thread fed to them.

However, the way it checked this is by checking the size of the autofp-worker's
input queue. If 0, it assumes it is done.

What this missed, is that a worker thread could have just taken the last packet
from the input queue, but it is not yet done processing it. If then the
FlowWorkToDoCleanup is ran as well, it would race the worker thread to the flow
handling logic. When it won, the flow was evicted and the packet thread
created a new flow.

This patch improves the shutdown logic to force the worker threads to
enter a "flow loop" (THV_FLOW_LOOP) state before moving on to the
FlowWorkToDoCleanup step. This makes sure that any in progress packets
in the worker threads have been processed.

Bug: #7681.
3 months ago
Victor Julien b42eea67d5 threads: remove unused flag 3 months ago
Philippe Antoine 22abad746a lua: convert hassh function into suricata.hassh lib
Ticket: 7603

We use suricata.ssh lib but also enable hassh.
3 months ago
Jason Ish 096aa9250e lua/flowvarlib: fix unchecked null
Use checkudata, instead of testudata which won't return in case of
NULL, but raise an error in the Lua script.

Fixes:

** CID 1646748:  Null pointer dereferences  (NULL_RETURNS)
/src/util-lua-flowvarlib.c: 89 in LuaFlowvarValue()
3 months ago
Jason Ish 35cf378233 lua/flowvarlib: fix formatting inside clang-format off 3 months ago
Jeff Lucovsky d1f78c3e18 gen/typo: Correct configure output grammar
Fixup the grammar for the Napatech option -- was "Enabled Napatech".
3 months ago
Philippe Antoine 033e0480cf detect/single-buf: helper with more explicit direction 3 months ago
Philippe Antoine dadf9012fc rust: bindgen detect-engine-buffer.h
Ticket: 7667

And prefix SCDetectBufferSetActiveList to be exported

Allows less use of suricata crate in plugin as we get the functions
prototypes from suricata_sys and they are more correct.
3 months ago
Philippe Antoine 0024de5e9e src: new file detect-engine-buffer.h
Taken from detect-engine.h so that we can bindgen this smaller
unit.
3 months ago
Philippe Antoine 31e30d4aa1 sdp: use rust join
It is much faster as it does not do an allocation for each element
3 months ago
Philippe Antoine 6436a5cebe websocket: limit allocation for small sizes
Fixes: 16f74c68aa ("websocket: use max window bits of 15")

We do not need to allocate 8kbytes for a small message
3 months ago
Jason Ish 35b03b4077 lua: convert flowvar functions to lib
New Lua lib, "suricata.flowvar" for working with flowvars from Lua.

Replaces functions:
- SCFlowvarGet (and ScFlowvarGet)
- SCFlowvarSet (and SCFlowvarSet)

Of note, the DetectLuaData has been made available to the init and
thread_init methods, instead of just the match. This is due to an
issue that if a flow variable is not registered in init, it will not
be logged, registering in thread_init is too late.

Ticket: #7486
3 months ago
Philippe Antoine daabab7381 doc/ssh: document hooks
Ticket: 7607
3 months ago
Philippe Antoine 1d4ff8a8fd detect: flow friendly error on hook incompatibility 3 months ago
Philippe Antoine 1f2cb21786 ssh: rustfmt 3 months ago
Philippe Antoine 76d7ab5418 lua: convert ssh function into suricata.ssh lib
Ticket: 7607
3 months ago
Philippe Antoine fcac063cfe ssh: make hooks available
Allows signature like `alert ssh:request_banner_done`
3 months ago
Philippe Antoine bbc007b4d4 rust: derive for AppLayerState
To enable easily hooks for rust app-layers such as SSH
3 months ago
Philippe Antoine 78dc70f5fd dns/lua: remove now unused includes
Completes commit 1206c1c5af
3 months ago
Jeff Lucovsky 87b7a0cef6 ftp: Apply rustfmt changes 3 months ago
Jeff Lucovsky ff59f215d6 doc/ftp: Document ftp.dynamic_port keyword
Document the sticky buffer for ftp.dynamic_port
3 months ago
Jeff Lucovsky 19fe098e88 detect/ftp: Add ftp.dynamic_port keyword
Issue: 7504

Add implementation of the ftp.dynamic_port rule keyword. The
implementation uses the U16 integer matching/parsing and thus supports
the comparison operations such as <, >, <=, >=, !, !=, and range (-).
3 months ago
Jeff Lucovsky 04bf28d6a1 app/ftp: Use common API naming
Modify the Rust API functions to conform to project naming format:
SCFTP*

Issue: 7504
3 months ago
Philippe Antoine 808f8a877a detect/multi-buf: helper with more explicit direction 3 months ago