Commit Graph

12535 Commits (86b5c81ea2606de66bf08b00fdfb8ec0735e7df4)
 

Author SHA1 Message Date
Victor Julien 8b08b0343d af-packet: define all current TP_STATUS_* flags 3 years ago
Modupe Falodun fac33118cc detect-rfb-secresult: convert unittest to FAIL/PASS APIs
Bug: #4055
3 years ago
Modupe Falodun e9779b0fa0 detect-sameip: convert unittests to FAIL/PASS APIs
Bug: #4057
3 years ago
Sam Muhammed 025fd385cd detect/event: convert unittests to FAIL/PASS APIs
Task #4025
3 years ago
Victor Julien 07ce871da4 packetpool: reset PacketRelease on return to pool
Reset PacketRelease callback to make sure its not set to a capture
specific callback.

As an example:

  0x000055e00af09d35 in AFPReleaseDataFromRing (p=0x7f1d884cb830) at source-af-packet.c:653
  0x000055e00af09dd0 in AFPReleasePacket (p=0x7f1d884cb830) at source-af-packet.c:678
  0x000055e00ab53d7e in TmqhOutputPacketpool (t=0x55e00fb79250, p=0x7f1d884cb830) at tmqh-packetpool.c:465
  0x000055e00af08dec in TmThreadsSlotProcessPkt (tv=0x55e00fb79250, s=0x55e012134790, p=0x7f1d884cb830) at tm-threads.h:201
  0x000055e00af08e70 in TmThreadsCaptureInjectPacket (tv=0x55e00fb79250, p=0x7f1d884cb830) at tm-threads.h:221
  0x000055e00af08f2e in TmThreadsCaptureHandleTimeout (tv=0x55e00fb79250, p=0x0) at tm-threads.h:245
  0x000055e00af0ba76 in ReceiveAFPLoop (tv=0x55e00fb79250, data=0x7f1d884ccb60, slot=0x55e01198e4b0) at source-af-packet.c:1321
  0x000055e00ab55257 in TmThreadsSlotPktAcqLoop (td=0x55e00fb79250) at tm-threads.c:312
  0x00007f1dca9d5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
  0x00007f1dca7c6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Here the packet was a pseudo packet to handle a timeout condition. But
the ReleasePacket callback was still set to AFPReleasePacket from a
previous use of the Packet.

Bug: #4807.
3 years ago
Sam Muhammed 214ea9bea5 detect/payload: convert unittests to FAIL/PASS APIs
Task #4026
3 years ago
Modupe Falodun a59299d128 detect-gid: convert unittests to FAIL/PASS APIs
Bug: #4041
3 years ago
Juliana Fajardini d581fc82b1 util/unittests: delete PASS_IF macro
The logic flow we want to achieve with unittests, where first we have
all FAIL statements and then just one PASS statement could become more
convoluted with the existence of the PASS_IF macro. Besides, what could
be written as a FAIL_IF might in some cases be written in not so clear
ways with the PASS_IF option available.

Also: fix inverted check values in documentation, update copyright year

Optimization: #4795
3 years ago
Juliana Fajardini f328ba527a detect/dsize: convert unittests to FAIL/PASS API
Also: change them to comply with the deletion of PASS_IF macro &
condense checks for invalid dsizes in one test, have all checks on same
valid dsize happen in a single test.

Task: #4021
3 years ago
Juliana Fajardini b3743cf5c0 unittests (assorted): remove PASS_IF macro
Also small documentation clean up and test adjusments where that
was needed.

affected: counters, decode-vntag, detect-mark

Related to #4795
3 years ago
Juliana Fajardini c6e97222b7 devguide: add page about rust unittests
Part of the task to offer better guidance on how and when to write
unit tests or suricata-verify tests
Also updated linking and index files, as well as testing page to refer
to the unit tests pages

Doc: #4590
3 years ago
Juliana Fajardini 747d225c84 devguide: repurpose unittests page to unittests-c
Part of ongoing task to add more guidance on how to create unittests
and suricata-verify tests for suri. There will also be a unittests-rust
page.

Doc: #4590
3 years ago
Juliana Fajardini 5b4c575f3b devguide: add page about testing
This page offers guidance about when to use unittests or s-v tests,
and how to create input for those. Also lists other common ways to test
Suri, such as fuzzing and the CI checks.

Doc: #4590
3 years ago
Pierre Chifflier ce652511bd rust/tftp: convert parser to nom7 functions 3 years ago
Pierre Chifflier c525a1337c rust/dns: convert parser to nom7 functions 3 years ago
Pierre Chifflier 74be8b94ec rust/ssh: convert parser to nom7 functions 3 years ago
Pierre Chifflier 8a584c211e rust/mqtt: convert parser to nom7 functions 3 years ago
Pierre Chifflier d27125d77a rust/sip: convert parser to nom7 functions 3 years ago
Pierre Chifflier 1046a7d1a3 rust/ftp: convert parser to nom7 functions 3 years ago
Pierre Chifflier ebd5883da8 rust/dhcp: convert parser to nom7 functions 3 years ago
Pierre Chifflier 17170c41aa rust: add nom7 dependency 3 years ago
Modupe Falodun a87c7e5c08 rust: remove unnecessary nested match
Bug: #4605
3 years ago
Modupe Falodun 74c39500c3 rust: fix inherent to string
Bug: OISF#4618
3 years ago
Sam Muhammed 922a453da5 rust(lint): use is_null() instead of ptr::null_mut()
Bug: #4594
3 years ago
Sam Muhammed 23768c7181 rust(lint): use is_null() instead of ptr::null()
Bug: #4594
3 years ago
Sam Muhammed da0a976e23 rust(lint): use let for binding single value
`match` is better used with binding to multiple variables,
for binding to a single value, `let` statement is recommended.

Bug: #4616
3 years ago
Sam Muhammed 42d4eb6943 detect-engine: convert unittests to FAIL/PASS APIs 3 years ago
Victor Julien 286c510ece flow: immediately evict tcp reused flows
Since we already know we're going to no longer use it, might as well
evict it right away.
3 years ago
Victor Julien 536291054c flow/bypass: clear memory on bypass
Previously the flow would hold on to the app-layer and segment data
until the end of the flow, even though it would never be accessed again.

This patch clears app-layer and stream data, but not stream ssn as its
used in flow logging.

Bug: #4778.
3 years ago
Victor Julien b19d1df69f flow/bypass: add util func to check if flow is bypassed
To hide the ifdefs for capture offload.
3 years ago
Victor Julien ab8f289bb6 flow/worker: run housekeeping for bypassed packets
Run flow eviction and flow inject queues for bypassed packets as well,
to avoid a scenario where these won't get run at all if too much of the
traffic is bypassed.

Bug: #4779.
3 years ago
Victor Julien 41fee41722 flow/manager: remove obsolete code 3 years ago
Victor Julien ec7e0561e8 flow/bypass: use_cnt desync'd on bypassed flows
Locally bypassed flows had unsafe updates to `Flow::use_cnt` leading to a race
issue. For a packet it would do the flow lookup, attach the flow to the packet,
increment the `use_cnt`. Then it would detect that the flow is in the bypass
state, and unlock it while holding a reference (so alos not decrementing the
`use_cnt`). When the packet was then returned to the packet pool, the flow would
be disconnected from the packet, which would decrement `use_cnt` without holding
the flow lock.

This patch addresses this issue by disconnecting the flow from the packet
immediately when the bypassed state is detected. This moves the `use_cnt`
decrement to within the lock.

Bug: #4766.
3 years ago
Philippe Antoine 416575ea02 pcrexform: use substring and not whole match 3 years ago
Philippe Antoine c9d664b0a0 tftp: StringToAppProto case
So, fuzz_applayerparserparse_tftp will fuzz tftp
3 years ago
Philippe Antoine 5bd065cb3c range: checks that end is after start for HTTP2
As was done only for HTTP1 in previous commit

The verification part stays separated from the parsing part,
as we want to keep on logging invalid ranges values.
3 years ago
Jason Ish 07370ed5c0 queue.h: suppress scan-build warnings
If running under scan-build, use our own implementations of all
the macros which include some code to satisfy scan-build
warnings.
3 years ago
Philippe Antoine 77604d86d6 range: move back files ownership in one case
In the case, we receive a range request with expected
overlap then new bytes, but the response does not get to the
new bytes, we are still skipping, but the HttpRangeContainerBlock
had the ownership of the files, and need to give it back
3 years ago
Philippe Antoine bba70607e8 range: checks that end is after start
Otherwise, we end up allocating too much memory
3 years ago
Philippe Antoine 27b4f165b1 loopback: decodes IPv6 from all OSes
As does wireshark
3 years ago
Philippe Antoine accdad7881 ike: do not keep server transforms in state
Fixes #4534

Now, only the tx with the transforms will match
with ike.chosen_sa_attribute
3 years ago
Philippe Antoine 83887510a8 modbus: tx iterator
When there are a lot of open transactions, as is possible with
modbus, the default tx_iterator will loop for the whole
transacations vector to find each transaction, that means
quadratic complexity.

Reusing the tx_iterator from the template, and keeping as a state
the last index where to start looking avoids this quadratic
complexity.
3 years ago
Philippe Antoine b34c025b52 util: avoid calling snprintf in PrintStringsToBuffer
As we print only one character
3 years ago
Philippe Antoine 53ef65d390 http2: enable by default, even if not in config 3 years ago
Philippe Antoine 424dcda2c0 http2: enable by default 3 years ago
Philippe Antoine fa4c7626bd http2: null check during upgrade 3 years ago
Philippe Antoine ea4a509a54 app-layer: disable by default if not in configuration
DNP3, ENIP, HTTP2 and Modbus are supposed to be disabled
by default. That means the default configuration does it,
but that also means that, if they are not in suricata.yaml,
the protocol should stay disabled.
3 years ago
Jason Ish 75bc9d9dd8 queue.h: wrap the system sys/queue.h
Instead of using local implementations for the queue.h macro,
wrap the system provided queue.h and then adding missing
features as needed.

The idea is that Suricata when integrated with another library
that includes sys/queue.h can look at the same source of truth
for these macros.

But not all operating systems include a queue.h with the same
features, and some don't include it at all, like Windows. So
on Windows this will be a full implementation of all the queue.h
features Suricata needs.
3 years ago
Philippe Antoine 6fadb97d5d alert: fixes leak in ThresholdHandlePacketRule
ThresholdHandlePacketRule may take ownership of an allocated
DetectThresholdEntry, and places it in a position of the
array th_entry. But it never got released
3 years ago
Philippe Antoine d21a252238 fuzz: target must use the rules it parsed
DetectEngineReloadThreads does not work for the fuzz targets
as there is no_of_detect_tvs = 0 as we did not register
real threads and slots.

So, we force the flow worker module to use the newly detect engine
conetxt with all it needs
3 years ago