Commit Graph

16358 Commits (1591ad4408a68f86b4c928ed33993a64686ba637)
 

Author SHA1 Message Date
Shivani Bhardwaj a7af371843 applayer/htp-range: fix off by one in expiry check 2 years ago
Shivani Bhardwaj c66f1f4488 doc: add note about datasets string memcaps
Bug 3910
2 years ago
Shivani Bhardwaj f1b44ca8c7 datasets: fix memuse to include string len
So far, when the data size was passed to the THash API, it was sent as
a sizeof(Struct) which works fine for the other data types as they have
a fixed length but not for the StringType.
However, because of the sizeof construct, the length of a string type
dataset was always taken to be 16 Bytes which is only the size of the struct
itself. It did not accomodate the actual size of the string that the
StringType holds. Fix this so that the memuse that is used to determine
whether memcap was reached also takes into consideration the size of the
actual string.

Bug 3910
2 years ago
Shivani Bhardwaj 00f7038beb util/thash: add a length getter fn
In order to have access to the length of datatypes with variable lengths
to correctly update memuse to calculate memcaps.

Bug 3910
2 years ago
Philippe Antoine df5dcfef5f bypass: really bypass udp flow from first packet
Ticket: 7053

As flow state would be overwritten by established...
2 years ago
dependabot[bot] efbf627dbd
github-actions: bump actions/checkout from 3.6.0 to 4.1.7
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.6.0...692973e3d937129bcbf40652eb9f2f61becf3332)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jason Ish 5530fd34b8 github-ci: add non-bundled libhtp build 2 years ago
Jason Ish a0cb7b21f4 github-ci/builds: don't run if only doc changes
A new workflow, "docs" has been created for only doc changes.

Factor out prepare-deps into a reusable action.
2 years ago
Philippe Antoine 7dfddab9ed detect: parse units for integer for every cases
Ticket: #6423

Not just equality, but also >3MB should work
For example flow.bytes_toserver>3MB
2 years ago
Victor Julien f59c43b1c7 smb/ntlmssp: improve version check
Don't assume the ntlmssp version field is always present if the flag is
set. Instead keep track of the offsets of the data of the various blobs
and see if there is space for the version.

Inspired by how Wireshark does the parsing.

Bug: #7121.
2 years ago
dependabot[bot] 653e702aa7 github-actions: bump github/codeql-action from 3.25.7 to 3.25.11
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.7 to 3.25.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.25.7...v3.25.11)

---
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>
2 years ago
dependabot[bot] 54b63f896d github-actions: bump codecov/codecov-action from 4.4.1 to 4.5.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.1 to 4.5.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](125fc84a9a...e28ff129e5)

---
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>
2 years ago
Victor Julien 6767694b39 github-actions: remove centos:7 build due to EOL 2 years ago
Philippe Antoine 1854503465 qa: remove depcrecated files
lgtm has been superseded by codeql github action
docker and travis are obsolete

Preparatory work for ticket 2696 libhtp rust conversion
2 years ago
Philippe Antoine 6b56d5971a output/tx: use dynamic number of app-layer protos
OutputTxLoggerThreadData gets allocated after the number of app-layer
protos is definite
2 years ago
Philippe Antoine 6a942f589c detect/profiling: use dynamic number of app-layer protos 2 years ago
Philippe Antoine f74997f5c7 app-layer: use already defined constant
FLOW_PROTO_APPLAYER_MAX
2 years ago
Philippe Antoine deb4a5a8cc detect/file-data: use dynamic number of app-layer protos 2 years ago
Philippe Antoine 647e878f7c detect: helper function for multibuffer 2 years ago
Victor Julien afc318737a doc/userguide: document threshold backoff type 2 years ago
Victor Julien 9e735fd6bd stream: enable backoff on event rules
Enable backoff for most rules. The rules looking at the session start up
use a count of 1 and a multiplier of 2.

Post-3whs rules use a count of 1 and a multiplier of 10.
2 years ago
Victor Julien 12130df21c detect/threshold: implement backoff type
Implement new `type backoff` for thresholding. This allows alerts to be
limited.

A count of 1 with a multiplier of 10 would generate alerts for matching packets:
1, 10, 100, 1000, 10000, 100000, etc.

A count of 1 with a multiplier of 2 would generate alerts for matching packets:
1, 2, 4, 8, 16, 32, etc.

Like with other thresholds, rule actions like drop and setting of
flowbits will still be performed for each matching packet.

Current implementation is only for the by_flow tracker and for per rule
threshold statements.

Tracking is done using uint32_t. When it reaches this value, the rest of
the packets in the tracker will use the silent match.

Ticket: #7120.
2 years ago
Victor Julien a0d515bfdd detect/threshold: regex cleanup 2 years ago
Victor Julien 2abe0df136 detect/threshold: format file 2 years ago
Victor Julien e362a01f8d doc/userguide: document new threshold config options 2 years ago
Victor Julien 7d4fcc311c detect/threshold: make hash size and memcap configurable 2 years ago
Victor Julien 10eaf550b7 detect/threshold: includes cleanup 2 years ago
Victor Julien 7bcf364095 detect/threshold: expand cache support for rule tracking
Use the same hash key as for the regular threshold storage,
so include gid, rev, tentant id.
2 years ago
Victor Julien 1e9fdc4005 detect/threshold: consider tenant id in tracking
Ticket: #6967.
2 years ago
Victor Julien 2be998fbcd detect/threshold: include rev in threshold tracking 2 years ago
Victor Julien 3471c0f6ad detect/threshold: improve hash function 2 years ago
Victor Julien b8028bf386 thresholds: use dedicated storage
Instead of a Host and IPPair table thresholding layer, use a dedicated
THash to store both. This allows hashing on host+sid+tracker or
ippair+sid+tracker, to create more unique hash keys.

This allows for fewer hash collisions.

The per rule tracking also uses this, so that the single big lock is no
longer a single point of contention.

Reimplement storage for flow thresholds to reuse as much logic as
possible from the host/ippair/rule thresholds.

Ticket: #426.
2 years ago
Victor Julien ac400af8f4 range: use thash expiry API for timeout 2 years ago
Victor Julien 00e1e89449 thash: add expiration logic
Add a callback and helper function to handle data expiration.

Update datasets to explicitly not use expiration.
2 years ago
Victor Julien 114fc37294 detect/address: constify ipv6 cmp funcs 2 years ago
Victor Julien 3a7247b1ed detect/threshold: minor rate filter cleanup 2 years ago
Victor Julien ab5e04525f detect/threshold: minor code cleanup
Packet pointer is not used during allocation.
2 years ago
Victor Julien 6622dc7444 detect/threshold: minor cleanup 2 years ago
Victor Julien c08c81cacf detect/threshold: implement per thread cache
Thresholding often has 2 stages:

1. recording matches
2. appling an action, like suppress

E.g. with something like:
threshold:type limit, count 10, seconds 3600, track by_src;
the recording state is about counting 10 first hits for an IP,
then followed by the "suppress" state that might last an hour.

By_src/by_dst are expensive, as they do a host table lookup and lock
the host. If many threads require this access, lock contention becomes
a serious problem.

This patch adds a thread local cache to avoid the synchronization
overhead. When the threshold for a host enters the "apply" stage,
a thread local hash entry is added. This entry knows the expiry
time and the action to apply. This way the action can be applied
w/o the synchronization overhead.

A rbtree is used to handle expiration.

Implemented for IPv4.
2 years ago
Victor Julien c963158443 detect: add ticket id to var related todos 2 years ago
Victor Julien 405491c3fc detect/detection_filter: add support for track by_flow 2 years ago
Victor Julien 3f04af7c7f doc: add thresholding by_flow 2 years ago
Victor Julien f028648750 detect/content: fix wrong value for depth check
Limits propegation checked for DETECT_DEPTH as a content flag,
which appears to have worked by chance. After reshuffling the
keyword id's it no longer worked. This patch uses the proper
flag DETECT_CONTENT_DEPTH.
2 years ago
Victor Julien d0f3f2d462 detect: group content inspect keyword id's 2 years ago
Victor Julien 022173d7ab detect: group types used in traffic variables
Traffic variables (flowvars, flowbits, xbits, etc) use a smaller int for
their type than detection types. As a workaround make sure the values fit
in a uint8_t.
2 years ago
Victor Julien cfd55ead74 threshold: add by_flow support for global thresholds
Allow rate_filter and thresholds from the global config to specify
tracking "by_flow".
2 years ago
Victor Julien 1552f0953a detect/threshold: implement tracking 'by_flow'
Add support for 'by_flow' track option. This allows using the various
threshold options in the context of a single flow.

Example:

    alert tcp ... stream-event:pkt_broken_ack; \
        threshold:type limit, track by_flow, count 1, seconds 3600;

The example would limit the number of alerts to once per hour for
packets triggering the 'pkt_broken_ack' stream event.

Implemented as a special "flowvar" holding the threshold entries. This
means no synchronization is required, making this a cheaper option
compared to the other trackers.

Ticket: #6822.
2 years ago
Victor Julien a81b23254c util/var: add comments explaining types 2 years ago
Victor Julien 1fa13e4b81 util/var: remove printf; add assert 2 years ago
Philippe Antoine 5bd17934df http2: do not expand duplicate headers
Ticket: 7104

As this can cause a big mamory allocation due to the quadratic
nature of the HPACK compression.
2 years ago