Commit Graph

12861 Commits (1e653249400ec6217af6d3f153f774ec133d5357)
 

Author SHA1 Message Date
Pierre Chifflier b8f767d84c rust/mime: convert parser to nom7 3 years ago
Victor Julien 8a73b242e3 detect/address: use common cidr code 3 years ago
Victor Julien 38aec1439c radix: fix unittests after stict checks 3 years ago
Victor Julien 7fd6fe732b radix: improve address range handling
Handle non-exact address ranges from string. This can come directly
from user input, so here it is accepted but the address is converted
to the address range start. A warning will be issued.

Debug validation checks are added to catch this.

This issue could lead to bad input from iprep (with cidr), defrag config
and htp server personalities to produce a bad radix tree.

Bug: #5084.
Bug: #5085.
Bug: #5086.
3 years ago
Victor Julien 51d4e0dced detect/iponly: fix netmask handling
If the ipaddress was not the address range start, it was not masked to turn
it into that. So 1.2.3.4/24 was not stored as address 1.2.3.0 with netmask 24,
but as 1.2.3.4 with netmask 24. This was then propagated into the radix tree,
where it was used as an exact key in exact lookups, giving unexpected results.

This patch implements the netmask handling for IPv4 and IPv6, and adds a set
of tests for it.

Bug: #5081.
Bug: #5066.
3 years ago
Victor Julien 311085dd34 radix: fix unittest not cleaning up 3 years ago
Victor Julien 860daceb04 detect/iponly: update SigNumArray comment 3 years ago
Victor Julien d04dface20 radix: cleanup test 3 years ago
Victor Julien 89b7ac0a60 radix: add tests for Bug #5066
Bug: #5066.
3 years ago
Victor Julien 6aa6e3f953 radix: fix FP/FN issue in IP-only
A bug was reported about the IP-only rules not correctly matching. This was
traced to the rules in question not getting recorded into the IP-only radix
tree correctly.

Sequence:

- 100.117.241.0/25 inserted into the tree

- 100.117.241.0/26 inserted into the tree

Both are part of the same radix node, but recorded by their different netmasks
in the user data portion.

Then faulty insert happens:

- 100.117.241.64/26

For reference, these net blocks compute to:

- 100.117.241.0/25:  100.117.241.0  - 100.117.241.127
- 100.117.241.0/26:  100.117.241.0  - 100.117.241.63
- 100.117.241.64/26: 100.117.241.64 - 100.117.241.127

The IP-only engine first does a search to get to the user data it may need to
include. It does so for with `SCRadixFindKeyIPV4ExactMatch` for single IPs, or
using `SCRadixFindKeyIPV4Netblock` in case of a netblock. Any "match" from
either of these is considered an "exact match" by the IP-only setup code.

This exact match expectation turned out to be wrong and
`SCRadixFindKeyIPV4Netblock` behaved more like "best match" instead, which is
a non-exact match, but its the next best match if no exact match is found.

The way the look up for 100.117.241.64/26 went wrong, is that it returned
the user data for 100.117.241.0/26. This happens as follows:

- first it would do an exact find, which didn't give a result

- then it removed bits from the keystream until it found a matching node
  and explore if any of the netmasks it contained matched. Here the first
  step of the bug started:

  it considered the netmask (with user data) a match that matched the
  number of bits of the matching key, but not of the actual range netmask cidr
  value.

  So in this case the number of shared bits between `100.117.241.0/25` and
  `100.117.241.64/26` was 25, so it assumed that the user data for the
  netmask 25 was the match.

  To summarize this step, there are 2 problems with this:
  1. it returns a match on something that isn't an exact match
  2. it considered the wrong netmask value

- the radix code then took the returned node, and did the netmask check
  again. This time it did use its own netmask value, so this time
  it did find the netmask 26 (+ user data). However because of the node that
  was returned, this netmask (+user data) belongs to `100.117.241.0`, not to
  `100.117.241.64`.

- the IP-only detection code was satisfied with what it assumed to be
  "exact match" and just updated the user data to include the user data that
  should have been associated with `100.117.241.64/26` to `100.117.241.0/26`.

This patch addresses the issue as follows:

It makes `SCRadixFindKeyIPV4Netblock` also return an exact match by propagating
the netmask in the search and in the evaluation of the stored netmasks.

It does away with the secondary netmask (+user data) evaluation.
`SCRadixFindKeyIPV4Netblock` is expected to handle this correctly.

The IP-only engine will fall back to the "not found" path, which does an explicit
"best match" lookup and then insert a new entry into the radix tree based on
the user data of the "best match".

Issue was present for IPv6 as well.

Bug: #5066.
3 years ago
Victor Julien 6381b1a643 detect/iponly: cleanups 3 years ago
Victor Julien de4354abcb detect/iponly: minor debug 'Print' improvements 3 years ago
Victor Julien 3ca3c9dfbe radix: minor debug 'Print' improvements 3 years ago
Victor Julien e04d378e58 util/cidr: simplify IPv4 CIDR handling; add IPv6
Instead of building a table at init just calculate it on demand.

Callsites are all during init, so its not performance critical.

Add similar function for IPv6.
3 years ago
Victor Julien e04fcfcf2f doc/userguide: minor rewording and reformatting for runmodes 3 years ago
Juliana Fajardini 28b5f4a555 devguide: add page about app-layer frame support
This explains the frame support from the perspective of a developer,
with introductory explanation on how to add frame support to an
applayer proto.

Doc #4697
3 years ago
Juliana Fajardini e0b9f0e175 http: add comment tags to support documentation
With these, the portion of code within the tags should be included
in the related code-snippets (for frame support documentation) w/o
errors, even if the code within changes. The tags can also work as
a reminder that the existing code is being shown elsewhere, so folks
know documentation might need updates, in case of major changes.
3 years ago
Juliana Fajardini 5a7645fac1 rust: add comment tags to support documentation
With these, the portion of code within the tags should be included
in the related code-snippets (for frame support documentation) w/o
errors, even if the code within changes. The tags can also work as
a reminder that the existing code is being shown elsewhere, so folks
know documentation might need updates, in case of major changes.
3 years ago
Juliana Fajardini e0dd1820c2 sip: apply rustfmt to a few functions
Our current rust code isn't always documentation friendly when it
comes to using code snippets. Used rustfmt to apply rust default
formatting on functions that we wanted to show in our documentation
for Frame support
3 years ago
Juliana Fajardini 71cbd2bf0e telnet: apply rustfmt to parse_request
When we want to share our code in our documentation pages, the current
rust formatting isn't so nice to read. Formatted just the portion of
the code that will be shown, for now.
3 years ago
Philippe Antoine 8adf172ab8 nfs: limits the number of active transactions per flow
Ticket: 4530
3 years ago
Philippe Antoine 0e85dea3ff nfs: remove unused events variable 3 years ago
Philippe Antoine e4f2f8f78d nfs: derive AppLayerEvent for NFSEvent 3 years ago
Philippe Antoine 5fe9188a95 fuzz: test for too many open txs in a flow
so as to avoid performance problems coming from this.
3 years ago
Victor Julien e1f7c63fa8 swf: fix coverity warnings
*** CID 1499365:    (UNINIT)
/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

*** CID 1499363:  Error handling issues  (CHECKED_RETURN)
/src/util-file-swf-decompression.c: 97 in FileSwfZlibDecompression()
91
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
>>>     CID 1499363:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "inflateInit_(&infstream, "1.2.11", 112)" without checking return value. This library function may fail and return an error code.
97         inflateInit(&infstream);
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:

Bug: #5079.
3 years ago
Victor Julien 4312676aed dnp3/eve: regenerate object logging code
To propagate jb_set_string_from_bytes() generator update.

Bug: #5080.
3 years ago
Victor Julien 08346cb239 dnp3: update gen script to use jb_set_string_from_bytes
Bug: #5080.
3 years ago
Jason Ish 2ebb525f7e build: remove configure check for cargo vendor
cargo vendor has been part of the core cargo command since Rust 1.37,
and are minimum Rust version is not 1.41, so remove the check. Its
always available now.
3 years ago
Jason Ish 62cc813f88 rust/make: fix maintainer-clean-local target
Was using the wrong name, so vendored Rust crates were not being
cleaned up on make maintainer-clean.
3 years ago
Pierre Chifflier 8dc3431d86 rust/dcerpc: convert parser to nom7 functions 3 years ago
Jeff Lucovsky a3443845fb log/stack: Propagate original signal
Issue: 4550

This commit modifies the "stack trace on signal" to propagate the
original signal received instead of always raising SIGABRT.
3 years ago
Pierre Chifflier b5166bdb93 rust/ntp: upgrade dependency on ntp-parser 3 years ago
Victor Julien 251b52ab07 github: bump MSRV and minimum known version 3 years ago
Victor Julien c1be27cb45 github: remove xenial build 3 years ago
Pierre Chifflier fa63945bdc rust/ike: convert parser to nom7 functions and upgrade dependency 3 years ago
Pierre Chifflier 3493537ec3 rust/rfb: convert parser to nom7 functions 3 years ago
Victor Julien 377ce6b679 codecov: fix informational; disable github annotations 3 years ago
Victor Julien 84d91e2e0d app-layer: fix counter setup logic
Completes 0ccf5b9147
3 years ago
Victor Julien 27cd54dc0d frames: address coverity issue
Minor cleanups to assist coverity.

Bug: #5065.
3 years ago
Modupe Falodun 786cf41599 detect-bytetest: remove unittests
These tests are reimplemented as Suricata-Verify

Task: 4911
3 years ago
Victor Julien da7eff61cc codecov: set to informational 3 years ago
Victor Julien d1071c151c ci: formatting errors are now fatal 3 years ago
Victor Julien 474e0e3644 sip: enable for 5061/udp 3 years ago
Victor Julien 1203750388 sip: add frames support
Frames:
- sip.pdu
- sip.request_line
- sip.response_line
- sip.request_headers
- sip.response_headers
- sip.request_body
- sip.response_body

The `sip.pdu` frame is always created, the rest only if the record
parser succeeded.

Ticket: #5036.
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.
3 years ago
Victor Julien 97ef60cd9b output/file: remove 'waldo' code
It was no longer used after "file-store v1" was removed.
3 years ago
Victor Julien f9c04992c3 file/store: warning grammer fixup 3 years ago
Victor Julien b06bd1a1fe htp: rearrange tx user data for more efficiency 3 years ago
Victor Julien 39b1f1aca6 output/lua: minor cleanups 3 years ago
Victor Julien e5fd0d4f76 output/streaming: use unique thread data name 3 years ago