Commit Graph

15638 Commits (3f5d228b9e244f536b7a647e14ff89bb0cef27a1)
 

Author SHA1 Message Date
Shivani Bhardwaj 83aba93f40 detect/port: remove the port cut/insertion stage
As this is already taken care of and a list of ports is available for
use by the next stage.

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj 4ac2382f26 detect/port: create list of small port ranges
Using the unique port points, create a list of small port ranges which
contain the DetectPort objects and the designated SGHs found by finding
the overlaps with the existing ports and copying the SGHs accordingly.

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj a02c44a3a4 detect/port: create a tree of given ports
After all the SGHs have been appropriately copied to the designated
ports, create an interval tree out of it for a faster lookup when later
a search for overlaps is made.

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj c9a911b6f8 detect/port: find unique port points
In order to create the smallest possible port ranges, it is convenient
to first have a list of unique ports. Then, the work becomes simple. See
below:

Given, a port range P1 = [1, 8]; SGH1
and another, P2 = [3, 94]; SGH2

right now, the code will follow a logic of recursively cutting port
ranges until we create the small ranges. But, with the help of unique
port points, we get, unique_port_points = [1, 3, 8, 94]

So, now, in a later stage, we can create the ranges as
[1, 2], [3, 7], [8, 8], [9, 94] and copy the designated SGHs where they
belong. Note that the intervals are closed which means that the range
is inclusive of both the points.

The final result becomes:
1. [1, 2]; SGH1
2. [3, 7]; SGH1 + SGH2
3. [8, 8]; SGH1 + SGH2
4. [9, 94]; SGH2

There would be 3 unique rule groups made for the case above.
Group 1: [1, 2]
Group 2: [3, 7], [8, 8]
Group 3: [9, 94]

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj 86f89e0966 util/interval-tree: suppress cppcheck warnings
Warning was:
src/util-port-interval-tree.c:50:1: warning: Either the condition 'tmp!=NULL' is redundant or there is possible null pointer dereference: tmp. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'tmp!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'oleft!=NULL' is redundant or there is possible null pointer dereference: oleft. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'oleft!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'oright!=NULL' is redundant or there is possible null pointer dereference: oright. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'oright!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'left!=NULL' is redundant or there is possible null pointer dereference: left. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'left!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
1 year ago
Shivani Bhardwaj 54558f1b4a util/interval-tree: add utility fns
Add new utility files to deal with the interval trees. These cover the
basic ops:
1. Creation/Destruction of the tree
2. Creation/Destruction of the nodes

It also adds the support for finding overlaps for a given set of ports.
This function is used by the detection engine is the Stage 2 of
signature preparation.

Ticket 6792
Bug 6414

Co-authored-by: Victor Julien <vjulien@oisf.net>
1 year ago
Shivani Bhardwaj a08e065c7c detect/port: make DetectPortInit non static
as this fn will be called upon and further used by other files later on.

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj d36d03a428 interval-tree: add augmentation fns to the tree
An interval tree uses red-black tree as its base data structure and
follows all the properties of a usual red-black tree. The additional
params are:
1. An interval such as [low, high] per node.
2. A max attribute per node. This attribute stores the maximum high
   value of any subtree rooted at this node.

At any point in time, an inorder traversal of an interval tree should
give the port ranges sorted by the low key in ascending order.

This commit modifies the IRB_AUGMENT macro and it's call sites to make
sure that on every insertion, the max attribute of the tree is properly
updated.

Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj 30b6e4d368 interval-tree: remove splay tree implementation
Ticket 6792
Bug 6414
1 year ago
Shivani Bhardwaj fde4ca5608 interval-tree: add base data structure
Ticket 6792
Bug 6414
1 year ago
Victor Julien fb9680bb7b detect/engine: fix whitelisting check
In the commit 4a00ae607, the whitelisting check was updated in a quest
to make use of the conditional better but it made things worse as every
range would be whitelisted as long as it had any of the default
whitelisted port which is very common.
1 year ago
Lukas Sismis 566e89a0d6 dpdk: output unknown NIC's NUMA node message only on multi-node systems
Ticket: #6715
1 year ago
dependabot[bot] c6c1eac301 github-actions: bump actions/download-artifact from 4.1.3 to 4.1.4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](87c55149d9...c850b930e6)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
dependabot[bot] f1b0f7c46b github-actions: bump github/codeql-action from 3.24.5 to 3.24.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.5 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.5...v3.24.6)

---
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>
1 year ago
Jason Ish 0dc3de332a examples: minimal example capture plugin for ci
Create a mininal capture plugin that injects one packet. While it can
also be a template, we should be able to run this in CI to test the
loading and registration of the capture plugin mechanisms.
1 year ago
Jason Ish acfc1c9395 threads: tm-modules.h depends on Packet so include decode.h 1 year ago
Jason Ish 25d0e0b68c plugins: initialize plugins earlier
Capture plugins need to be registered before LiveDeviceFinalize,
otherwise Suricata errors before the plugin gets a chance to load.

Bug: #6811
1 year ago
Jason Ish 96e61b043c thread modules: separate initialization from registration
Move the zero'ing to the thread module array InitGlobal in an effort
to fix capture modules.

At some point device validation moved to a point in startup before
plugins are loaded meaning that capture plugins could not be
used. Moving plugin registration early enough caused some of their
registration to be wiped out as clearing the array was done after.

Bug: #6811
1 year ago
Jason Ish c2ecae9b82 schema: add flow.wrong_thread 1 year ago
Victor Julien 6d0e11e76c dependabot: reduce to monthly update 1 year ago
Hadiqa Alamdar Bukhari 4b81851097 dns: add dns.rrtype keyword
It matches the rrtype field in DNS
It's an unsigned integer match
valid ranges = [0-65535]
Does not support prefilter
Supports flow in both directions
Feature #6666
1 year ago
Jason Ish 5f0853599b pfring: fix leak of configuration data and in single mode
Fix leak of configuration data on exit. Also, in single mode set
thread count to one instead of the CPU count.

Bug: #4734
1 year ago
Jason Ish 358f1e35ee pfring: fix leak of packet on exit
Bug: #4734
1 year ago
Philippe Antoine d255a5c7a3 output/filestore: delay snprintf until needed
Perf optimization so that we do not call snprintf in the
common code path.

Ticket: 6796
1 year ago
Philippe Antoine 7641c07af9 output/filestore: remove duplicate snprintf
Ticket: 6796
1 year ago
Philippe Antoine c41540f839 output: log tx only when there is a fresh app update
Ticket: 6796

Similar to commit for detection
9240ae250c

We only have more logging to do if the app update was fresh,
ie if p->app_update_direction != 0

If we have data acknowledged in one direction,
and then many packets in the other direction,
the APP_UPDATED flow flags did not get reset because we did not
run detection yet in this direction,
but there is nothing more to do after the first packet in the
other direction.
1 year ago
dependabot[bot] c283e8565a github-actions: bump codecov/codecov-action from 4.0.1 to 4.1.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](e0b68c6749...54bcd8715e)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
dependabot[bot] 13da6498b5 github-actions: bump actions/download-artifact from 4.1.2 to 4.1.3
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](eaceaf801f...87c55149d9)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
Giuseppe Longo 3dc24a967a doc: add upgrade section for 8 1 year ago
Giuseppe Longo fe77def816 rust/sip: register pattern matching
This permits to detect the SIP protocol using pattern matching instead of
probing parser.

Since it is no longer used, the respective probing functions have been removed.
1 year ago
Giuseppe Longo add95002b9 suricata.yaml: define SIP_PORTS 1 year ago
Giuseppe Longo 9c9b1a4230 rust/sip: add direction to transaction
This patch permits to set a direction when a new transaction is created in order
to avoid 'signature shadowing' as reported by Eric Leblond in commit
5aaf50760f
1 year ago
Giuseppe Longo c9d309219e rust/sip: register parser for tcp
This patch lets the parser to work over tcp protocol, taking care of handling
data before calling the request/response parsers.

Ticket #3351.
1 year ago
Giuseppe Longo 69f841c998 sip/parser: enforce valid chars for sip version
The `is_version_char` function incorrectly allowed characters that are not
part of the valid SIP version "SIP/2.0".

For instance, 'HTTP/1.1' was mistakenly accepted as a valid SIP version,
although it's not.

This commit fixes the issue by updating the condition to strictly
check for the correct version string.
1 year ago
Giuseppe Longo 7e993d5081 sip/parser: accept valid chars
Accepts valid characters as defined in RFC3261.
1 year ago
Giuseppe Longo 8ff80cb84d rust/sip: rustfmt sip module 1 year ago
Philippe Antoine 497394eec6 detect: do not run tx detection on non established packets
Follows commit 2fb5059

Ticket: 6775
1 year ago
Philippe Antoine e22217bda8 doc: there is no right shift for integer bitmasks
Ticket: 6628
1 year ago
dependabot[bot] 07ec8b202e github-actions: bump github/codeql-action from 3.24.3 to 3.24.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.3 to 3.24.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.3...v3.24.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>
1 year ago
Jason Ish 089dd6e761 build: don't build the lib example by default
Don't build the library example by default as it is not needed by most
users.
1 year ago
Jason Ish 5ed3f905ac examples/lib: work with bundled libhtp
The simple example Makefile.am was unconditionally including
$(HTP_LDADD) which might be empty resulting in "../.." ending up in the
Makefile causing the build to fail.

Instead, also make HTP_LDADD a conditional, so we can only include it
when actually set, and its only set when libhtp is bundled.

The reason this Makefile needs to include the path components "../.."
is because the HTP_LDADD value is relative to the top level "src/"
directory.
1 year ago
Victor Julien 69f0e85785 af-xdp: suppress cppcheck false positive
As the cppcheck test suite does as well:
https://github.com/danmar/cppcheck/blob/main/test/cfg/posix.c#L311

Requires cppcheck --inline-suppr option to be used.
1 year ago
Victor Julien eb1d0c2cc2 detect: fix memory leak in error handling
Pointed out by cppcheck:

src/detect-parse.c:1544:9: error: Memory leak: sig.init_data [memleak]
        SCFree(sig);
        ^

Bug: #6527.
1 year ago
Victor Julien 78703bbc86 detect/address: avoid cppcheck false positive
src/detect-engine-address.c:1386:5: error: Memory leak: map.string [memleak]
    return true;
    ^

Seems cppcheck looses track of the pointer after the unnecessary cast to
void.

Bug: #6527.
1 year ago
Hadiqa Alamdar Bukhari 6c193b1a3d dns: add missing dns keywords to schema.json
Found and added missing dns fields in schema.json after manual code review.
Added description to these newly added dns fields.
Feature #5642
1 year ago
Lukas Sismis ebf465a11b tcp: do not assign TCP flags to pseudopackets
Previously pseudopackets were assigned with ACK flag which falsely turned
"SYN" flows to "SYN/ACK" flows when Suricata ran with raw content-matching
rules. The problem occured during the flow timeout or Suricata shutdown,
essentially, when the flow was being kicked out (with a pseudopacket).

When Suricata ran without raw content-matching rules (the ruleset did not
contain content matching keywords or it only contained keywords that are
app-layer content-matching) then raw stream reassembly tracking is turned off
(SignatureHasStreamContent()).
This in turn disabled a check in StreamNeedsReassembly() and the right edge
was not checked with the raw stream progress. In turn, it did not generate
a pseudopacket that would go through the detection engine. Suricata with
raw content-matching keywords would therefore on a flow with SYN packet only
return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION which would generate
the pseudopacket.

In Suricata versions <= 6.0.x, the flow output was correct because
only the commit 1bb6f44ff0 started to
differentiate the right edge calculation between the raw and application
layer streams. The older Suricata versions used only the application layer
right edge equation and therefore did not generate a pseudopacket.

Ticket: #6733
1 year ago
Lukas Sismis 2a085ccb83 dpdk: remove redundant port checks and set copy iface socket id correctly
The function to retrieve port ID from the port name was used multiple times.
This commit removes the redundant usage of the function.

Additionally, in the DeviceConfigureIPS(), the socket ID was wrongly retrieved
for the original interface and not for the out port interface.
1 year ago
Lukas Sismis 9185ca8f38 dpdk: add a user warning on the change of RX/TX descriptors
Ticket: #6739
1 year ago
Lukas Sismis e5f7a9ad55 dpdk: refactor log messages to have the same error format 1 year ago
Lukas Sismis 63016aaa7b dpdk: split out the configure function into smaller ones 1 year ago