Commit Graph

1008 Commits (39f5c7f56ab7c70616304ad55be4a118edee2530)

Author SHA1 Message Date
Victor Julien e042cd785e error: use SC_ENOMEM for alloc errors 3 years ago
Philippe Antoine 62352ad030 src: fix remaining cppclean warnings 3 years ago
Victor Julien cd2a5ec84f packet: move action functions to packet files 3 years ago
Victor Julien 6c200c7793 detect: issue drop to root packet in all cases
Update DROP action handling in tunnel packets. DROP/REJECT action is set
to outer (root) and inner packet.

Check action flags both against outer (root) and inner packet.

Remove PACKET_SET_ACTION macro. Replace with RESET for the one reset usecase.
The reason to remove is to make the logic easier to understand.

Reduce scope of RESET macros.

Rename PacketTestAction to PacketCheckAction except in unittests. Keep
PacketTestAction as a wrapper around PacketCheckAction. This makes it
easier to trace the action handling in the real code.

Fix rate_filter setting actions directly.

General code cleanups.

Bug: #5571.
3 years ago
Victor Julien ad0a29cabc detect: remove wrapper func 3 years ago
Victor Julien 1bff888947 detect: fix duplicate detect state issue
For protocols with multi buffer inspection there could be multiple times
the same sid would be queued into the candidates queue. This triggered
a debug validation check.

W/o debug validation this would lead to duplicate work and possibly multiple
alerts where a single one would be appropriate.

Bug: 5419.
3 years ago
Juliana Fajardini 1774ff18a6 decode: make PacketDrop use action as parameter
A Packet may be dropped due to several different reasons. This change
adds action as a parameter, so we can update the packet action when we
drop it, instead of setting it to drop.

Related to
Bug #5458
3 years ago
Philippe Antoine 02f2602dde src: rework includes as per cppclean 3 years ago
Victor Julien a83f02d4cd detect/dcerpc: apply dcerpc to smb as well
So 'alert dcerpc' also matches if the DCERPC is over SMB.

Explicitly refuse smb keywords for the 'dcerpc' app proto setting:
`alert dceprc ... smb.share; ...` is rejected.

Remove a now useless special case in the stateless rule processing
matching for dcerpc/smb.

Bug: #5208.
3 years ago
Philippe Antoine b8524e70d9 detect: change InspectEngineFuncPtr2 to return uint8_t 3 years ago
Philippe Antoine c5cf2967b3 detect: fix integer warnings
Ticket: #4516
3 years ago
Victor Julien 0035673208 eve/drop: log drop reason
Ticket: #5202.
3 years ago
Juliana Fajardini 192360aa05 detect: update copyright years 3 years ago
Juliana Fajardini 877b32c1e4 detect/stats: log out total of suppressed alerts
Related to
Task #4943
Task #5179
3 years ago
Juliana Fajardini 8616c90fe7 detect/stats: log out total of discarded alerts
Add a counter to our stats log with the total of alerts that have been
discarded due to packet alert queue overflow.

Task #5179
3 years ago
Juliana Fajardini a85340b1ab detect/alert: use tx id in alert if frame has it
Task #4943
3 years ago
Juliana Fajardini aa547a8de3 detect/engine: use alert queue from det_ctx
Task #4943
3 years ago
Juliana Fajardini 88805f03ee detect/alert: add infra for new alert queue
Initial work to bring part of the alert queue processing to
DetectEngineThreadCtx.

Task #4943
3 years ago
Victor Julien 4bb00964ac detect: fix rule inspection order
Fix rules from the 'match' list getting added to the tx candidates list
unsorted. In some cases this could lead to the same sid getting inspected
twice leading to a DEBUG_VALIDATION_BUG_ON trigger.

Bug: #5144.
3 years ago
Victor Julien c96d22e8a1 frames: support UDP frames
UDP frames point to the UDP packet payloads.

The frames are removed after each packet.

Ticket: #4983.
4 years ago
Victor Julien f6f124f283 detect/engine: support frames
Implement the low level detect engine support for inspecting frames,
including MPM, transforms and inspect API's.
4 years ago
Victor Julien bb3d49d5bf detect: use bool for uint16_t used as bool 4 years ago
Jason Ish 1ad71b96da app-layer: remove tx detect state setter and getter
Instead access detect state through AppLayerParserGetTxData.
4 years ago
Victor Julien ed87784907 detect: enforce max app-layer progress
Allow progress values in the range 0-47 so we have 48 bits to track
prefilter engines.

Mark bits 48-62 as reserved explicitly.

Add debug validation checks to make sure the reserved space isn't used.
4 years ago
Victor Julien 932cf0b6a6 detect: track prefilter by progress, not engine
Fix FNs in case of too many prefilter engines. A transaction was tracking
which engines have run using a u64 bit array. The engines 'local_id' was
used to set and check this bit. However the bit checking code didn't
handle int types correctly, leading to an incorrect left shift result of
a u32 to a u64 bit value.

This commit addresses that by fixing the int handling, but also by
changing how the engines are tracked.

To avoid wasting prefilter engine tracking bit space, track what
ran by the progress they are registered at, instead of the individual
engine id's. While we can have many engines, the protocols use far
fewer unique progress values. So instead of tracking for dozens of
prefilter id's, we track for the handful of progress values.

To allow for this the engine array is sorted by tx_min_progress, then
app_proto and finally local_id. A new field is added to "know" when
the last relevant engine for a progress value is reached, so that we
can set the prefilter bit then.

A consquence is that the progress values have a ceiling now that
needs to fit in a 64 bit bitarray. The values used by parsers currently
does not exceed 5, so that seems to be ok.

Bug: #4685.
4 years ago
Victor Julien e36b9b89a1 detect/tests: improve detection entry
Lots of tests still use SigMatchSignatures as their main detection
entry function, which bypassed some logic. Make it match main logic
more closely.
4 years ago
Victor Julien 802c1ffee3 detect: enforce flow drops earlier
Enforcing flow drops is now done earlier in the detection engine and
moved out of the IP-only engine where it didn't belong.
4 years ago
Victor Julien aa93984b7e detect: unify alert handling; fix bugs
Unify handling of signature matches between various rule types and
between noalert and regular rules.

"noalert" sigs are added to the alert queue initially, but removed
from it after handling their actions. This way all actions are applied
from a single place.

Make sure flow drop and pass are mutually exclusive.

The above addresses issue with pass and drops not getting applied
correctly in various cases.

Bug: #4663
Bug: #4670
4 years ago
Victor Julien ae89874b06 detect: remove dead code 4 years ago
Victor Julien dfe71bb773 detect: remove ticker
Last consumer of it has been converted.
4 years ago
Joshua Lumb cf9b2b5fd1 detect-dsize: Add ! operator for dsize matching 4 years ago
Victor Julien e7a74348d7 detect/profile: add support for tx inspection
Add 'inspect_type' "packet" and "tx" for the two record types. Add more metadata
when available.
4 years ago
Victor Julien 4c7eb64411 decode: convert 'action' macros to inline funcs
Make sure most common branch is handled first to assist branch
prediction.

Macros still play a small role to please our 'action' cocci check.
4 years ago
Victor Julien beb6b1e0d1 packets: more detailed entry debug for detect/stream 4 years ago
Philippe Antoine c8dbe24fb6 proto: introduce signature protocol, as extension to flow protocol
AppProtoEquals function allows to check if a flow protocol
matches a signature protocol
5 years ago
Jason Ish 7525295e63 hashing: remove remaining HAVE_NSS guards
For features, we pretend to HAVE_NSS so scripts, external tests
continue to work.
5 years ago
Victor Julien 3c7c361b60 detect/stream: fix async stream inspection
Move raw progress forward only if detect uses stream data, indicated
by the PKT_DETECT_HAS_STREAMDATA flag.
5 years ago
Victor Julien d694dac5a8 detect: remove inspect v1 API 5 years ago
Victor Julien 4664444067 detect: fix inspection order with stateful rules
When stateful detection rules, for which detection has already started
for a previous packet, are added to the candidates array, the array
is sorted to mantain the correct inspection order. However, due to a
trivial error in the sort helper the array was sorted in descending
instead of ascending order.
5 years ago
Victor Julien e799357d9f detect: optimize prefilter result handling 5 years ago
Victor Julien a2f249cc86 app-layer: handle AppLayerTxData being NULL
Http parser can have 'NULL' user data in case of memcap limit getting
reached.
5 years ago
Victor Julien 8fe9faecb2 app-layer: remove DetectFlags API. Replaced by AppLayerTxData 5 years ago
Victor Julien e15995e2d2 detect: store detect flags in AppLayerTxData 5 years ago
Victor Julien de6c9b9441 detect: clarify and slightly cleanup non-pf logic 5 years ago
Victor Julien 500e8da63a files: tracking flag update
Improve flow file flags and file flags updates. Introduce a mask
that is set at start up to avoid lots of runtime checks.

Disable cocci flags check as it doesn't support the more dynamic
nature of the flag updates.
6 years ago
Victor Julien 44d7f636f2 threading: remove post_pq argument from 'SlotFunc'
This was not in use anywhere.
6 years ago
Victor Julien 502a8b5fb3 detect: fix inspection buffer for packet engines
Fix buffers not being reset per inspection round for packet engines.

Bug #3341.
6 years ago
Victor Julien 58e48bcb87 debug: make it easier to trace flush logic 6 years ago
Victor Julien edd2cd626f jansson: remove HAVE_LIBJANSSON guards 6 years ago
Victor Julien 7384744c3e detect: fix FP on ICMP unreachable errors
ICMP unreachable errors are linked to the flow they send an error for.
This would lead to the detection engine calling the TX inspection
engines on them.

The stream inspect engine would default to a match for non-UDP
and non-TCP as for ICMP we're not expected to use a TX inspect engine
for stream data.

This all would lead to a false positive match.

This patch fixes this by making sure the TX engines are not called if
the packet protocol and flow protocol are not the same.

Bug #2769.
6 years ago