]> git.ipfire.org Git - thirdparty/suricata.git/commit
datajson: add remove_key option to dataset
authorEric Leblond <el@stamus-networks.com>
Sat, 29 Mar 2025 07:49:12 +0000 (08:49 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 11 Jun 2025 18:49:18 +0000 (20:49 +0200)
commit3dde17fb75d131013ca586d82a184d3194245feb
tree207ae48c1a18f962376fb8785be797f61222c5eb
parent0ae88a408a898bc8577762cc6c00ff0427fa058e
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
src/datajson.c
src/datajson.h
src/datasets.h
src/detect-dataset.c