From ce5ea1edb4107ba5b0996fc2fe0b54e85d88b2be Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 3 Oct 2024 23:04:07 +0200 Subject: [PATCH] docs: basic datajson documentation Ticket: #7372 --- doc/userguide/rules/datasets.rst | 41 ++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/doc/userguide/rules/datasets.rst b/doc/userguide/rules/datasets.rst index bf6ab9b1edd3..c84cc03cbd06 100644 --- a/doc/userguide/rules/datasets.rst +++ b/doc/userguide/rules/datasets.rst @@ -3,8 +3,8 @@ Datasets ======== -Using the ``dataset`` and ``datarep`` keyword it is possible to match on -large amounts of data against any sticky buffer. +Using the ``dataset`` and ``datarep`` and ``datajson`` keyword it is possible +to match on large amounts of data against any sticky buffer. For example, to match against a DNS black list called ``dns-bl``:: @@ -145,6 +145,26 @@ reputation lists. A MD5 list, a SHA256 list, and a raw string (buffer) list. The rules will only match if the data is in the list and the reputation value is higher than 200. +datajson +~~~~~~~~ + +DataJSON allows matching data against a set and output data attached to the matching +value in the event. + +Syntax:: + + datajson:,,; + + datajson:, \ + [, type , load , memcap , hashsize , key ]; + +Example rules could look like:: + + alert http any any -> any any (msg:"IP match"; ip.dst; datajson:isset,bad_ips, type ip, load bad_ips.csv, key bad_ones; sid:8000001;) + +In this example, the match will occur if the destination IP is in the set and the +alert will have an ``alert.extra.bad_ones`` subobject that will contain the JSON +data associated to the value. Rule Reloads ------------ @@ -292,6 +312,23 @@ Syntax:: , + +datajson +~~~~~~~~ + +The datajson format follows the dataset, except that there is a comma +separator followed by a second field that must contain a valid JSON +object: + +Syntax:: + + , + +e.g. for ua-seen with type string:: + + TW96aWxsYS80LjAgKGNvbXBhdGlibGU7ICk=,{"agent": "Mozilla", "version": "4.0"} + + .. _datasets_file_locations: File Locations