Commit Graph

35 Commits (9fa0033966be34b73a86e178c9f0d95ddb795e51)

Author SHA1 Message Date
Philippe Antoine 02f2602dde src: rework includes as per cppclean 3 years ago
Juliana Fajardini a6bda3596b unittests: alloc Packet with PacketGetFromAlloc
Some unittests used SCMalloc for allocating new Packet the unittests.
While this is valid, it leads to segmentation faults when we move to
dynamic allocation of the maximum alerts allowed to be triggered by a
single packet.

This massive patch uses PacketGetFromAlloc, which initializes a Packet
in such a way that any dynamic allocated structures within will also be
initialized.

Related to
Task #4207
4 years ago
Victor Julien 0437ca61ff unittests: clean up packet clear logic 4 years ago
Modupe Falodun dff7e7d34e detect/hostbits: remove unittests
These tests are reimplemented as Suricata-Verify tests

Task: 4911
4 years ago
Philippe Antoine 3de99a214c pcre2: migrate keywords parsing 4 years ago
Jeff Lucovsky 1eeb96696b general: Cleanup bool usage 5 years ago
Victor Julien 6ab323d323 detect: hide RegisterTests behind ifdef UNITTESTS
Update all callers to more aggressively use UNITTESTS guards as well.
5 years ago
Victor Julien 26bcc97515 detect/keywords: dynamic version part of doc URL 6 years ago
Jeff Lucovsky d3a65fe156 detect: Provide `de_ctx` to free functions
This commit makes sure that the `DetectEngineCtx *` is available
to each detector's "free" function.
6 years ago
Jeff Lucovsky 7f6af10fed general: copyright bump 6 years ago
Jeff Lucovsky 4b0085b03c detect: Update to take advantage of PCRE refactor
This commit changes the keyword detectors to use the refactored PCRE
modifications from detect-parse.[ch]
6 years ago
Victor Julien 14896365ef detect: remove Threadvars argument from API calls
Remove it as it's (almost) never used. If it is really needed it can
be accessed through DetectEngineThreadCtx::tv as well.
6 years ago
Eric Leblond 2b1fa53c66 detect-hostbits: error on some invalid config 7 years ago
Victor Julien ca1161d798 detect: suppress coverity deadcode warnings
Suppress as scan-build-7 relies on this 'dead' code to not issue
a warning.
7 years ago
Victor Julien 2ef2febc7c bits: avoid memory leak in case of adding types 7 years ago
Victor Julien 979f964260 hostbits: fix test setup 8 years ago
Victor Julien ab1200fbd7 compiler: more strict compiler warnings
Set flags by default:

    -Wmissing-prototypes
    -Wmissing-declarations
    -Wstrict-prototypes
    -Wwrite-strings
    -Wcast-align
    -Wbad-function-cast
    -Wformat-security
    -Wno-format-nonliteral
    -Wmissing-format-attribute
    -funsigned-char

Fix minor compiler warnings for these new flags on gcc and clang.
9 years ago
Victor Julien 22f3205664 var-names: expose outside of detect engine
Until now variable names, such as flowbit names, were local to a detect
engine. This made sense as they were only ever used in that context.

For the purpose of logging these names, this needs a different approach.
The loggers live outside of the detect engine. Also, in the case of
reloads and multi-tenancy, there are even multiple detect engines, so
it would be even more tricky to access them from the outside.

This patch brings a new approach. A any time, there is a single active
hash table mapping the variable names and their id's. For multiple
tenants the table is shared between tenants.

The table is set up in a 'staging' area, where locking makes sure that
multiple loading threads don't mess things up. Then when the preparing
of a detection engine is ready, but before the detect threads are made
aware of the new detect engine, the active varname hash is swapped with
the staging instance.

For this to work, all the mappings from the 'current' or active mapping
are added to the staging table.

After the threads have reloaded and the new detection engine is active,
the old table can be freed.

For multi tenancy things are similar. The staging area is used for
setting up until the new detection engines / tenants are applied to
the system.

This patch also changes the variable 'id'/'idx' field to uint32_t. Due
to data structure padding and alignment, this should have no practical
drawback while allowing for a lot more vars.
9 years ago
Victor Julien bfd4bc8233 detect: constify Signature/SigMatch use at runtime 9 years ago
Eric Leblond a2e2f50fb9 documentation: fix list keywords URLs
Update URLs in keyword definition to point to sphinx documentation.
9 years ago
Victor Julien 56ff853e73 hostbits: test fixes 9 years ago
Jason Ish 3c5d8e65d4 hostbits: use new unittest macros 9 years ago
Jason Ish c4945607e3 hostbits: fail parse on unexpected trailing data
Address issue https://redmine.openinfosecfoundation.org/issues/1889
for hostbits. This involves updating the regular expresssion
to capture any trailing data as the regex already keeps
spaces out of the name.

A unit test was converted to new macros to find out which
line it was failing at after updating regex.
9 years ago
Victor Julien e67ae0f174 detect keywords: use parse regex util func 10 years ago
Jason Ish 796dd5223b tests: no longer necessary to provide successful return code
1 pass, 0 is fail.
10 years ago
Jason Ish 26fc5682ad hostbits: ignore leading and trailing white space
Ignore leading and trailing space around the name and
direction tokens.
11 years ago
Victor Julien 1a83fee5f5 xbits: fix coverity warnings
Switch statement would contain NOALERT even though this was
unreachable.
11 years ago
Victor Julien 00d6298666 host: handle timeout
Set expiration for regular hostbits keyword.
11 years ago
Victor Julien 67dd5c0430 host: implement hostbits/xbits expire 11 years ago
Victor Julien 57d93cbcfe hostbits: prepare for xbits integration 11 years ago
Victor Julien dea8dda3c1 vars: redo var name <-> idx handling
Can't use sm type anymore as multiple var carriers (host/flow/etc) will
all have xbits.
11 years ago
Victor Julien 4c6d564211 hostbits: unittest cleanups 11 years ago
Victor Julien 2cb0df7cf9 hostbits: allow for src/dst parameter
By default, the hostbit checks the 'src' host. By adding the dst option
the dst host is used instead.
11 years ago
Victor Julien be725a5ba2 hostbits: add more tests, include sigorder 11 years ago
Victor Julien 5c880377ae detect: hostbits keyword
Per host bit similar to 'flowbits'.

Initial code that uses just the 'src' ip for the operations.
11 years ago