Skip to content

Commit 07f6a85

Browse files
committed
doc/userguide: improve datajson doc
Patch adds ``remove_key`` option and clarifies the text.
1 parent a211a81 commit 07f6a85

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

doc/userguide/rules/datasets.rst

+15-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Syntax::
8080

8181
dataset:<set|unset|isset|isnotset>,<name> \
8282
[, type <string|md5|sha256|ipv4|ip>, save <file name>, load <file name>, state <file name>, memcap <size>, hashsize <size>
83-
, format <csv|json|jsonline>, enrichment_key <output_key>, value_key <json_key>, array_key <json_path>];
83+
, format <csv|json|jsonline>, enrichment_key <output_key>, value_key <json_key>, array_key <json_path>,
84+
remove_key];
8485

8586
type <type>
8687
the data type: string, md5, sha256, ipv4, ip
@@ -108,6 +109,9 @@ value_key <key>
108109
array_key <key>
109110
the key to use for the array of the alert
110111
for json format
112+
remove_key
113+
if set, the JSON object pointed by value key will be removed
114+
from the alert event
111115

112116

113117
.. note:: 'type' is mandatory and needs to be set.
@@ -161,7 +165,7 @@ The rules will only match if the data is in the list and the reputation
161165
value is higher than 200.
162166

163167

164-
.. _datasets_datajson:
168+
.. _datasets_json:
165169

166170
dataset with json
167171
~~~~~~~~~~~~~~~~~
@@ -188,12 +192,17 @@ Example rules could look like::
188192

189193
In this example, the match will occur if the destination IP is in the set and the
190194
alert will have an ``alert.extra.bad_ones`` subobject that will contain the JSON
191-
data associated to the value.
195+
data associated to the value (``bad_ones`` coming from ``enrichment_key`` option).
192196

193-
If ``json_key`` is present then the data file has to contains a valid JSON object containing an array
194-
where every elemeents have to contain a key equal to ``json_key``.
197+
When format is ``json`` or ``jsonline``, the ``value_key`` is used to get
198+
the value in the line (``jsonline`` format) or in the array (``json`` format).
199+
At least one single element needs to be have the ``value_key`` present in the data file to
200+
have a successful load.
195201
If ``array_key`` is present, Suricata will extract the corresponding subobject that has to be
196-
a JSON array. This is only valid for ``json`` format.
202+
a JSON array and search for element to add to the set in this array. This is only valid for ``json`` format.
203+
204+
If you don't want to have the ``value_key`` in the alert, you can use the
205+
``remove_key`` option. This will remove the key from the alert event.
197206

198207
See :ref:`Datajson format <datajson_data>` for more information.
199208

0 commit comments

Comments
 (0)