--- /dev/null
+#! /bin/sh
+
+# Test the flow record metadata.
+test $(cat ./eve.json | \
+ jq -c 'select(.event_type == "flow")' | \
+ jq -c .metadata.flowbits[0]) == \"traffic/label/cli-http\"
+
+# Test the alert record metadata.
+test $(cat ./eve.json | \
+ jq -c 'select(.event_type == "alert")' | \
+ jq -c .metadata.flowbits[0]) == \"traffic/label/cli-http\"
+
+# Test the netflow records. We should have 2 of those, so do a line
+# count on netflow records with the required flowbit.
+test $(cat ./eve.json | \
+ jq -c 'select(.event_type == "netflow")' | \
+ jq -c 'select(.metadata.flowbits[0] == "traffic/label/cli-http")' |\
+ wc -l | xargs) -eq 2
+
--- /dev/null
+%YAML 1.1
+---
+
+include: ../../etc/suricata-4.0.3.yaml
+
+# Configure the type of alert (and other) logging you would like.
+outputs:
+ - eve-log:
+ enabled: yes
+ filetype: regular
+ filename: eve.json
+
+ # Enable to disable top-level metadata logging. Default: yes.
+ #metadata: no
+
+ types:
+ - alert
+ - http:
+ extended: yes
+ - dns:
+ query: yes # enable logging of DNS queries
+ answer: yes # enable logging of DNS answers
+ - tls:
+ extended: yes # enable this for extended logging information
+ - files:
+ force-magic: no # force logging magic on all logged files
+ - smtp:
+ - ssh
+ - stats:
+ totals: yes # stats for all threads merged together
+ threads: no # per thread stats
+ deltas: no # include delta values
+ - flow
+ - netflow
+ - metadata
--- /dev/null
+# Silly rule to set the flowbit "traffic/label/cli-http" on
+# the curl user-agent.
+alert http any any -> any any (content:"curl"; http_user_agent; flowbits:set,traffic/label/cli-http; sid:1; rev:1;)
+
+# Capture the UID as a pktvar.
+alert http any any -> any any (pcre:"/uid=(\d+)/, pkt:uid"; noalert; sid:2; rev:1;)
+
+# Capture the GID as a flowvar.
+alert http any any -> any any (pcre:"/gid=(\d+)/, flow:gid"; noalert; sid:3; rev:1;)
--- /dev/null
+requires:
+
+ # Require that we have metadata support, checked by looking for a
+ # function.
+ script:
+ - grep JsonAddMetadata src/output-json.h > /dev/null
+
+checks:
+
+ - filter:
+ count: 1
+ match:
+ event_type: flow
+ metadata.flowbits[0]: traffic/label/cli-http
+ metadata.flowvars.gid: "0"
+
+ - filter:
+ count: 1
+ match:
+ event_type: alert
+ metadata.flowbits[0]: traffic/label/cli-http
+
+ - filter:
+ count: 2
+ match:
+ event_type: netflow
+ metadata.flowbits[0]: traffic/label/cli-http
+
+ - filter:
+ count: 1
+ match:
+ event_type: metadata
+ metadata.pktvars[0].uid: "0"
+ metadata.flowvars.gid: "0"