Skip to content

Commit

Permalink
output/drop: add verdict field
Browse files Browse the repository at this point in the history
Related to
Bug OISF#5464
  • Loading branch information
jufajardini committed Jul 12, 2023
1 parent d0cce2b commit b0c5bba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,9 @@
},
"reason": {
"type": "string"
},
"verdict": {
"$ref": "#/$defs/verdict_type"
}
},
"additionalProperties": false
Expand Down
15 changes: 13 additions & 2 deletions src/output-json-drop.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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_ {
uint8_t flags;
Expand Down Expand Up @@ -158,6 +159,10 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
/* Close drop. */
jb_close(js);

if (aft->drop_ctx->flags & LOG_DROP_VERDICT) {
GetVerdictJson(js, p);
}

if (aft->drop_ctx->flags & LOG_DROP_ALERTS) {
int logged = 0;
int i;
Expand Down Expand Up @@ -273,7 +278,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");
Expand All @@ -287,6 +292,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->eve_ctx = ajt;
Expand Down

0 comments on commit b0c5bba

Please sign in to comment.