Commit Graph

17043 Commits (ed2a81dc050e54c8bda678a78ba80ce206593bdb)
 

Author SHA1 Message Date
Jeff Lucovsky ed2a81dc05 doc/entropy: Add documentation for the entropy keyword
This commits adds documentation for the entropy keyword.
The entropy keyword calculates the Shannon entropy value for content
with the calculated value used to determine whether an alert occurs.
3 months ago
Jeff Lucovsky b93c70fbd8 detect/entropy: Use entropy matching when needed
This commit causes the content inspection engine to recognize and
invoke the entropy "match" function when the entropy keyword is used.

Issue: 4162
3 months ago
Jeff Lucovsky fdc0ac590e detect/entropy: Add entropy keyword
This commit adds keyword/build support for the entropy keyword. The
entropy keyword compares an entropy value with a value calculated
according to the Shannon entropy on the available content.

Issue: 4162
3 months ago
Jeff Lucovsky c92f0f6d27 rust/detect: Add entropy support
This commit adds
- Parser for the entropy keyword
- Calculation of content the Shannon entropy value

Issue: 4162

The entropy keyword syntax is the keyword entropy followed by options
and the entropy value for comparison.

The minimum entropy keyword specification is:
entropy: value <entropy-spec>

This results in the calculated entropy value being compared with
<entropy-spec> with the equality operator.

Calculated entropy values are between 0.0 and 8.0, inclusive.

A match occurs when the values and operator agree. This example matches
if the calculated and entropy value are the same.

When entropy keyword options are specified, all options and "value" must
be comma-separated. Options and value may be specified in any order.

Options have default values:
- bytes is equal to the current content length
- offset is 0
- comparison with value is equality

entropy: [bytes <byteval>] [offset <offsetval>] value <entropy-spec>

Using default values:
entropy: bytes 0, offset 0, value =<entropy-spec>

<entropy-spec> is: <operator> (see below) and a value, e.g., "< 4.1"

The following operators are available from the float crate:
    - =  (default): Match when calculated entropy value equals specified entropy value
    - <  Match when calculated entropy value is strictly less than specified entropy value
    - <= Match when calculated entropy value is less than or equal to specified entropy value
    - >  Match when calculated entropy value is strictly greater than specified entropy value
    - >= Match when calculated entropy value is greater than or equal to specified entropy value
    - != Match when calculated entropy value is not equal to specified entropy value
    - x-y Match when calculated entropy value is in the range, exclusive
    - !x-y Match when calculated entropy value is not in the range, exclusive
3 months ago
Jeff Lucovsky d527021234 float: General purpose floating point functions
Issue: 4162

This commit adds a floating-point analog to `uint.rs` targeted
initially to be used by the forthcoming entropy keyword.
3 months ago
Shivani Bhardwaj 65349442f8 doc: add http library supported fns
Task 7604
3 months ago
Shivani Bhardwaj 5ba0ccaf4b doc: remove http cookie ua from list of buffers
as they are available via library using the tx
- tx:request_header("Cookie")
- tx:response_header("Cookie")
- tx:request_header("User-Agent")
3 months ago
Shivani Bhardwaj eca7936390 lua: convert http fns into suricata.http lib
Expose the existing lua fns through the library as suricata.http module.
All existing fns are accessible like before with a transaction.

Task 7604
3 months ago
Shivani Bhardwaj 04c9e16348 util/lua: change arg name to reflect correctness
lua fns do not care about the argument count, they work with the index of
the item in the stack. Before library, there was just one item on the stack
so it worked out, however, with the library, the first item in the stack is
the library userdata, so, the fn would fail with the existing hard coded
setting of 1 for argc which can easily be confused with the number of
arguments passed to the fn.
3 months ago
Jason Ish 455aef7a22 github-ci: add test for custom lib example
Ticket: #7240
3 months ago
Jason Ish de91a23b18 examples/lib: include cleanup
Requires tm-threads.h.

Ticket: #7240
3 months ago
Jason Ish 461e9110b6 examples/lib: use packet setter functions
Instead of direct field access.

Ticket: #7240
3 months ago
Jason Ish a8ad7b1d28 packet: add set functions for some packet fields
- SCPacketSetReleasePacket
- SCPacketSetLiveDevice
- SCPacketSetDatalink
- SCPacketSetTime
- SCPacketSetSource

Prevents direct access by library users and provides more ABI
stability.

Ticket: #7240
3 months ago
Jason Ish 5679ecc6d8 lib: remove TmModuleLibHandlePacket
This is better handled directly in the library user program so the
user has more control of the Packet structure, before and after
handling.

Ticket: #7240
3 months ago
Jason Ish b46e3ebeab examples/lib: use a main loop to wait for exit
Instead of immediately entering shutdown, use SuricataMainLoop to wait
for the end of the pcap.

Ticket: #7240
3 months ago
Jason Ish 897e7cdd6a lib: remove SCRunModeLibDestroyWorker
This was a one line wrapper around SCTmThreadsSlotPktAcqLoopFinish, so
library users can call that directly instead.

Ticket: #7240
3 months ago
Jason Ish 04161155ec examples/lib: create threadvars from main thread
This also allows us to remove the sleep, as the ThreadVars are now
guaranteed to be created before PostInit.

Ticket: #7240
3 months ago
Jason Ish b100b42315 examples/lib: update library example for ips drop
Add a release packet callback where the action can be checked for drop.

Ticket: #7240
3 months ago
Jason Ish ad8e8dd0e8 runmodes: typedef runmode enum and use as type
Also remove function to set the library mode. This is easy enough to
do with SCRunmodeSet, and we don't want to add a specific setter for
each and every runmode.

Ticket: #7240
3 months ago
Jason Ish b3513d7073 lib: reorganize to avoid static prototypes
Ticket: #7240
3 months ago
Jason Ish a55dbdfae3 lib: consistent naming style
And add SC prefix.

Ticket: #7240
3 months ago
Jason Ish 35d7d77ddb threads: refactor TmThreadsSlotPktAcqLoop for user threads
Refactor TmThreadsSlotPktAcqLoop for user provided thread by breaking
out the init and finish code into their own functions.

For user provided threads, Suricata should not "drive" the thread, but
the setup and finish code is the same.

The finish function is exported so it can be called by the user
application when its receive loop or equivalent is done.

Also remove obsolete comment.

Ticket: #7240
3 months ago
Jason Ish 04b29aa8d3 lib: take pointer to LiveDevice, not name
In the library capture example, show how the packet counter can be
updated.

Ticket: #7240
3 months ago
Jason Ish 60860e43ac lib: remove global worker id variable
Update ThreadVars creation in lib mode to have the worker_id provided
by the user.

Ticket: #7240
3 months ago
Jason Ish 201b3a6001 lib: rename threadvars creation function
Also use a proper return type (ThreadVars *).

Ticket: #7240
3 months ago
Jason Ish 5e94be63ce examples/lib: better command line handling
Use the more conventional "--" command line handling to separate the
arguments. The first set will be passed to Suricata, and the args
after "--" will be handled by the example. Currently this is a single
PCAP filename, but will be extended to a list of PCAP filenames.

Also hard code logging to the current directory.

Ticket: #7240
3 months ago
Jason Ish 421e0a2bf9 threads: don't attempt to join threads with an id of 0
Worker threads not created by Suricata, but instead a library user
should not be joined, as Suricata does not have access to their thread
handle, and it may in-fact be an unjoinable thread, such as the main
process.

When the thread ID is 0, assume the thread is "externally" managed,
but still mark is as dead to satisfy Suricata's view of the thread.

Ticket: #7240
3 months ago
Jason Ish 4df33c496e .gitignore: add more files
- the generated binaries for lib examples
- LSP files
- man pages
3 months ago
Jason Ish 4b715a84cf examples: rename lib capture example to custom
To keep the simple example simple, move the lib based capture method
example to its own example.

Ticket: #7240
3 months ago
Angelo Mirabella ee9714e593 libsuricata: add library runmode
Add library source and runmode modules. Reorganized
library example to create a worker thread and replay a pcap
file using the library mode.
No API layer is added at this stage.

Edits by Jason Ish:
- fix guard
- add copyright/license headers

Ticket: #7240
3 months ago
Juliana Fajardini d8c6a56a62 doc/exceptions: change stats counters names
As we've changed them for more search-friendly ones.

Related to
Task #7185
3 months ago
Juliana Fajardini 78b16a9b76 exceptions: move midstream stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Juliana Fajardini 9a3b1553cc exceptions: move reassembly memcap stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Juliana Fajardini 3e83ae9a5f exceptions: move ssn memcap stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Juliana Fajardini 0f81190d2a exceptions: move flow memcap stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Juliana Fajardini b4c216a4ba exceptions: move defrag stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Juliana Fajardini 6c484064d8 exceptions: move app_layer stats to common counter
Part of making the exception policy stats counters more search
friendly.

Task #7185
3 months ago
Jeff Lucovsky a8b9965f69 output: Add linktype name
Issue: 6954

This commit adds the linktype name to the output stream. The name is
determined from the pcap utility function pcap_datalink_val_to_name
3 months ago
Jeff Lucovsky 462091114e output/datalink: Use Rust-based linktype hashmap
Use the hasmap to gather linktype display names.

Issue: 6954
3 months ago
Jeff Lucovsky 8e373e46a3 decode/datalink: Add datalink value/name logic
Issue: 6954

Add Rust based logic that maintains a hash map of link type values and
their associated output names.
3 months ago
Jason Ish 6c57d85ecb github-ci: use git cli command for netmap instead of action
This action hits API limits often, however our other uses of git clone
do not seem to, so try use git clone here instead of the github
action.
4 months ago
Jason Ish bfd6c29f5a detect: SC prefix for extern pub Rust functions
Ticket: #7498
4 months ago
Jason Ish 27fd2fe74b snmp: rust naming and visibility cleanups
Ticket: #7498
4 months ago
Lukas Sismis 9272fd9d98 dpdk: adjust auto mempool calculation when no TX queues set 4 months ago
Lukas Sismis 4f2ce17dc5 dpdk: allow zero TX queues when running in IDS mode
When running in non-forwarding (IDS) mode, it is not required
to create TX queues for the interface.
This can be acheived by setting tx-descriptors configuration
field to 0.

Ticket: 7633
4 months ago
Lukas Sismis 1be1c65b6e docs: double quote technical terms in DPDK section 4 months ago
Lukas Sismis e6811c51c6 dpdk: NULL freed variables
The DPDKDeviceResourcesDeinit function now accepts second-level
reference to NULL the provided variable after deinitialization..
4 months ago
Lukas Sismis fbe5ce7a2b dpdk: document vlan stripping offload
Ticket: 5838
4 months ago
Lukas Sismis 640d0985c2 dpdk: check for link up before full startup
ICE card (Intel E810) was not receiving packets immediatelly
after startup, Suricata workers would act as processing while
it was not. This eliminates the problem by only continuing
in the initialization if the link is already up.

The setting can be turned off manually from the configuraiton
file.

Ticket: 7381
4 months ago
Lukas Sismis 31fbfc322c dpdk: use default iface-copy value if not specified
Ticket: 7374
4 months ago