Commit Graph

17596 Commits (0bc21eec486075e5e83a29e21e0d0c51a5f07de5)
 

Author SHA1 Message Date
Eric Leblond 0bc21eec48 datajson: fix thread safety violation 1 month ago
Eric Leblond 40f86571d9 datajson: reduce size length 1 month ago
Eric Leblond b8e2791482 datajson: fix string format in error message 1 month ago
Eric Leblond 61ac7b46c1 eve/schema: remove reference to datajson 1 month ago
Eric Leblond a652eee508 doc/userguide: remove left over datajson reference 1 month ago
Eric Leblond 7d28758a54 doc/userguide: improve datajson doc
Patch adds ``remove_key`` option and clarifies the text.
1 month ago
Eric Leblond 3dde17fb75 datajson: add remove_key option to dataset
This option allows to remove the key corresponding to the match
value from the JSON object before creating the JSON object that
will be added to the `extra` data.

For example, matching on the following JSON on the `ip` key:

```json
{"ip": "10.16.1.11", "test": "success", "context":3}
```

with a match like:

```
dataset:isset,src_ip,type ip,load src.lst,format jsonline,enrichment_key src_ip,value_key ip;
```

will produce the following:

```json
"extra": {
  "src_ip": {
    "ip": "10.16.1.11",
    "test": "success",
    "context": 3
  }
```

if we add the `remove_key` option to the match:

```
dataset:isset,src_ip,type ip,load src.lst,format jsonline,enrichment_key src_ip,value_key ip, remove_key;
```

it will produce the following:

```json
"extra": {
  "src_ip": {
    "test": "success",
    "context": 3
  }
```

The option is set to false by default.

Ticket: #7372
1 month ago
Eric Leblond 0ae88a408a doc/userguide: basic doc for jsonline format 1 month ago
Eric Leblond 3223d8fe59 datajson: implement jsonline format
This format allows to use a one valid JSON object per line in the
data file.

Ticket: #7372
1 month ago
Eric Leblond 8058964449 datajson: prepare jsonline format
There is just a change in the iterator to go from json to jsonline
so let's factorize the parsing functions.

Ticket: #7372
1 month ago
Eric Leblond 9873c5d2e1 doc/userguide: add dataset with json 1 month ago
Eric Leblond e2d8217934 eve/schema: document datajson output 1 month ago
Eric Leblond 0e88e36020 eve/schema: pktvars is a container
It can contain any vars so need addition properties.
1 month ago
Eric Leblond 3fbc718728 detect/pcre: add extraction for alert
With datajson infrastructure in place, it is now possible to
add data in the extra information section. Following an idea
by Jason Ish, this patch adds the feature for pcre extraction.

A PCRE such as pcre:"/(?P<alert_ua>[a-zA-Z]+)\//" will add the
content of the captured group to alert.extra.ua.
1 month ago
Eric Leblond dd94dc6cc6 datajson: introduce feature
This patch introduces new option to dataset keyword.
Where regular dataset allows match from sets, dataset with json
format allows the same but also adds JSON data to the alert
event. This data is coming from the set definition it self.
For example, an ipv4 set will look like:

  [{"ip": "10.16.1.11", "test": "success","context":3}]

The syntax is a JSON array but it can also be a JSON object
with an array inside. The idea is to directly used data coming
from the API of a threat intel management software.

The syntax of the keyword is the following:

  dataset:isset,src_ip,type ip,load src.lst,format json, \
       enrichment_key src_ip, value_key ip;

Compare to dataset, it just have a supplementary option key
that is used to indicate in which subobject the JSON value
should be added.

The information is added in the even under the alert.extra
subobject:

  "alert": {
    "extra": {
      "src_ip": {
        "ip": "10.6.1.11",
        "test": "success",
        "context": 3
      },

The main interest of the feature is to be able to contextualize
a match. For example, if you have an IOC source, you can do

 [
   {"buffer": "value1", "actor":"APT28","Country":"FR"},
   {"buffer": "value2", "actor":"APT32","Country":"NL"}
 ]

This way, a single dataset is able to produce context to the
event where it was not possible before and multiple signatures
had to be used.

The format introduced in datajson is an evolution of the
historical datarep format. This has some limitations. For example,
if a user fetch IOCs from a threat intel server there is a large
change that the format will be JSON or XML. Suricata has no support
for the second but can support the first one.

Keeping the key value may seem redundant but it is useful to have it
directly accessible in the extra data to be able to query it
independantly of the signature (where it can be multiple metadata
or even be a transformed metadata).

In some case, when interacting with data (mostly coming from
threat intel servers), the JSON array containing the data
to use is not at the root of the object and it is ncessary
to access a subobject.

This patch implements this with support of key in level1.level2.
This is done via the `array_key` option that contains the path
to the data.

Ticket: #7372
1 month ago
Eric Leblond 53ac35337a util/byte: add HexToRaw function 1 month ago
Eric Leblond 61e485446a util/ip: add IPv4 and IPv6 length 1 month ago
Victor Julien d5ae9156b9 detect: replace DetectEngineCtx flag with EngineModeIsFirewall 1 month ago
Victor Julien b0b3808a55 detect/config: supported for firewall rules 1 month ago
Victor Julien 1ee9b15a6a help: group and reorder help/usage output 1 month ago
Victor Julien fa3311a253 commandline: add --help option
Acts same as -h.
1 month ago
Victor Julien 08925eac18 firewall: add --firewall and firewall.enabled
Allows for enabling firewall mode
1 month ago
Victor Julien 0e18048ef0 firewall: move config into yaml object
To make it easier to group settings or include them.
1 month ago
Pierre Chifflier adcee8d7b5 ldap: avoid unneeded renaming of variables 1 month ago
Pierre Chifflier ebc1678c5c ldap: fix clippy warnings (unneded conversions) 1 month ago
Pierre Chifflier bda22c1f4a ldap: factorize code and remove duplicated structs, use ldap_parser where relevant 1 month ago
Pierre Chifflier c152c5c7e0 ldap: update ldap-parser to 0.5.0 1 month ago
Alice Akaki 3065374314 json/schema: link file.name to email.attachment
As a Suricata keyword.

Ticket: #7683
1 month ago
Jason Ish 8e8c3040e7 doc/upgrade: note about dns address swap on responses
Document the change in DNS addresses for ticket 6400.

Ticket: https://redmine.openinfosecfoundation.org/issues/6400
1 month ago
Philippe Antoine f6856eac9c fuzz: fix -Wshorten-64-to-32 warnings
Ticket: #6186
1 month ago
Philippe Antoine 9e64555c5e util: fix -Wshorten-64-to-32 warnings for afpacket
Ticket: #6186
1 month ago
Philippe Antoine e0e91c9302 configure: add -Wshorten-64-to-32 to the flags
when configure is run with --enable-warnings

Ticket: 6186

Also add -Wimplicit-int-conversion to the flags

Both are not compatible with unit tests
1 month ago
Philippe Antoine 7b492bc83b detect/engine: fix -Wshorten-64-to-32 warnings
Ticket: #6186

Especially take care of the case where byte_extract extracts a u64
value that does not fit in a u32
1 month ago
Victor Julien c3f054b625 time: replace usleep by SleepUsec/SleepMsec
Helps cross platform support, esp Windows
1 month ago
Victor Julien 35e711d00a threads: clean up module flags
Remove unused TM_FLAG_STREAM_TM.

Rename TM_FLAG_DETECT_TM to TM_FLAG_FLOWWORKER_TM as it was mostly used
to check if a thread is a flow worker. TM_FLAG_DETECT_TM was always set
for a flow worker, even when there was no detection in use.
1 month ago
Victor Julien bdac028fc7 threading: fix shutdown of IPS autofp modes
For IPS modes with a verdict thread in autofp there was an issue with
the verdict thread not shutting down, leading to a long shutdown time
until an error condition was reached.

The problem was that when the packet threads, of which the verdict
thread is one, were told to enter their flow timeout loop the verdict
thread got stuck as it immediately progressed to THV_RUNNING_DONE
instead of the expected THV_FLOW_LOOP.

This patch updates the shutdown logic to only apply the flow timeout
logic to the relevant threads, and skip the verdict thread(s).

Add TM_FLAG_VERDICT_TM to indicate a thread has a verdict module to more
explicitly shut it down.

Fixes: 12f8f03532 ("threads: fix autofp shutdown race condition")

Bug: #7681.
1 month ago
Philippe Antoine 6dbc421825 rust: bindgen AppLayerParserConfParserEnabled
Ticket: 7667
1 month ago
Philippe Antoine 49b2a2be5d rust: bindgen SCAppLayerParserRegisterLogger
Ticket: 7667
1 month ago
Philippe Antoine 7bfef2e1e8 rust: bindgen AppLayerParserRegisterParserAcceptableDataDirection
Ticket: 7667
1 month ago
Philippe Antoine 1ff4dbfc24 rust: bindgen AppLayerParserSetStreamDepth
Ticket: 7667
1 month ago
Philippe Antoine b29d46d81f rust: bindgen SCAppLayerParserStateIssetFlag
Ticket: 7667
1 month ago
Philippe Antoine 6d56beffef rust: bindgen AppLayerParserStateSetFlag
Ticket: 7667
1 month ago
Philippe Antoine 249131e9de src: clean includes for app-layer-parser.h
To prepare bindgening
1 month ago
Victor Julien f2faba5a23 detect/config: add flow tracking doc 2 months ago
Victor Julien 00336c45f4 detect/config: remove unused include 2 months ago
Victor Julien 67902c791d detect/config: add func docs 2 months ago
Victor Julien ec6081363c detect/config: remove filestore reference from comments 2 months ago
Victor Julien 6e0a6abb0b detect/config: add support for skipping flow tracking
Allow rules in the `pre_flow` hook to disable flow tracking for a
packet:

    config:packet tcp:pre_flow any any <> any 12345 (           \
        config: tracking disable, type flow, scope packet;      \
        sid:1;)

This rule will be evaluated before a packet is handled by the flow
engine, and a match will ensure that the flow engine is skipped.

Ticket: #7715.
2 months ago
Victor Julien f1fdc1801e detect: set detect table for non-firewall mode as well
This also exposed a difference between the handling of TD alerts in
firewall vs non-firewall mode. In firewall mode the table/hook is also
part of the alert ordering to make sure actions from packet:td are
applied before app:td. Handle that explicitly for now.
2 months ago
Victor Julien 7896148798 detect/config: allow setting a scope for action config 2 months ago