]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/drop: add verdict field
authorJuliana Fajardini <jufajardini@oisf.net>
Fri, 28 Jul 2023 18:42:35 +0000 (15:42 -0300)
committerJuliana Fajardini <jufajardini@oisf.net>
Tue, 1 Aug 2023 17:01:30 +0000 (14:01 -0300)
Related to
Bug #5464

(cherry picked from commit 0437173848d98812f74a28f283c327178bf500dd)

doc/userguide/output/eve/eve-json-output.rst
src/output-json-drop.c
suricata.yaml.in

index 5cd9e62192c43abf9082897a5579bed0c3a4c7ed..bc0637bf0db7f8567429ee548804eb95fd61a105 100644 (file)
@@ -288,6 +288,22 @@ enabled, then the log gets more verbose.
 
 By using ``custom`` it is possible to select which TLS fields to log.
 
+Drops
+~~~~~
+
+Drops are event types logged when the engine drops a packet.
+
+Config::
+
+    - drop:
+        alerts: yes      # log alerts that caused drops
+        flows: all       # start or all: 'start' logs only a single drop
+                         # per flow direction. All logs each dropped pkt.
+        # Enable logging the final action taken on a packet by the engine
+        # (will show more information in case of a drop caused by 'reject')
+        verdict: yes
+
+
 Date modifiers in filename
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 90ca0dba61088f04c438bc830e9941acef53ac92..f547178532ae21ef9981d7b7a0f03bcb3fd993b7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2020 Open Information Security Foundation
+/* Copyright (C) 2007-2023 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -58,7 +58,8 @@
 
 #define MODULE_NAME "JsonDropLog"
 
-#define LOG_DROP_ALERTS 1
+#define LOG_DROP_ALERTS  BIT_U8(1)
+#define LOG_DROP_VERDICT BIT_U8(2)
 
 typedef struct JsonDropOutputCtx_ {
     LogFileCtx *file_ctx;
@@ -155,6 +156,10 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
     /* Close drop. */
     jb_close(js);
 
+    if (aft->drop_ctx->flags & LOG_DROP_VERDICT) {
+        EveAddVerdict(js, p);
+    }
+
     if (aft->drop_ctx->flags & LOG_DROP_ALERTS) {
         int logged = 0;
         int i;
@@ -280,7 +285,7 @@ static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_
         const char *extended = ConfNodeLookupChildValue(conf, "alerts");
         if (extended != NULL) {
             if (ConfValIsTrue(extended)) {
-                drop_ctx->flags = LOG_DROP_ALERTS;
+                drop_ctx->flags |= LOG_DROP_ALERTS;
             }
         }
         extended = ConfNodeLookupChildValue(conf, "flows");
@@ -294,6 +299,12 @@ static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_
                         "'flow' are 'start' and 'all'");
             }
         }
+        extended = ConfNodeLookupChildValue(conf, "verdict");
+        if (extended != NULL) {
+            if (ConfValIsTrue(extended)) {
+                drop_ctx->flags |= LOG_DROP_VERDICT;
+            }
+        }
     }
 
     drop_ctx->file_ctx = ajt->file_ctx;
index f284111c9e88477a2b212c7b72c0b93f00980eb4..5a2329e14dea44a985445638b35d4418e5344398 100644 (file)
@@ -254,6 +254,9 @@ outputs:
         #    alerts: yes      # log alerts that caused drops
         #    flows: all       # start or all: 'start' logs only a single drop
         #                     # per flow direction. All logs each dropped pkt.
+        #    verdict: yes     # Enable logging the final action taken on a packet
+                              # by the engine (will show more information in case
+                              # of a drop caused by 'reject')
         - smtp:
             #extended: yes # enable this for extended logging information
             # this includes: bcc, message-id, subject, x_mailer, user-agent