suricata
output-json-anomaly.c
Go to the documentation of this file.
1 /* Copyright (C) 2019-2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Jeff Lucovsky <jeff@lucovsky.org>
22  *
23  * Logs anomalies in JSON format.
24  *
25  */
26 
27 #include "suricata-common.h"
28 #include "detect.h"
29 #include "flow.h"
30 #include "conf.h"
31 #include "app-layer.h"
32 #include "app-layer-events.h"
33 #include "app-layer-parser.h"
34 
35 #include "threads.h"
36 #include "tm-threads.h"
37 #include "threadvars.h"
38 #include "util-debug.h"
39 
40 #include "util-misc.h"
41 
42 #include "detect-parse.h"
43 #include "detect-engine.h"
44 #include "util-logopenfile.h"
45 
46 #include "output.h"
47 #include "output-json.h"
48 #include "output-json-anomaly.h"
49 
50 #include "util-byte.h"
51 #include "util-enum.h"
52 #include "util-privs.h"
53 #include "util-print.h"
54 #include "util-proto-name.h"
55 #include "util-optimize.h"
56 #include "util-buffer.h"
57 #include "util-validate.h"
58 
59 #define MODULE_NAME "JsonAnomalyLog"
60 
61 #define ANOMALY_EVENT_TYPE "anomaly"
62 #define LOG_JSON_DECODE_TYPE BIT_U16(0)
63 #define LOG_JSON_STREAM_TYPE BIT_U16(1)
64 #define LOG_JSON_APPLAYER_TYPE BIT_U16(2)
65 #define LOG_JSON_PACKETHDR BIT_U16(3)
66 
67 #define LOG_JSON_PACKET_TYPE (LOG_JSON_DECODE_TYPE | LOG_JSON_STREAM_TYPE)
68 #define ANOMALY_DEFAULTS LOG_JSON_APPLAYER_TYPE
69 
70 #define TX_ID_UNUSED UINT64_MAX
71 
72 typedef struct AnomalyJsonOutputCtx_ {
73  uint16_t flags;
76 
77 typedef struct JsonAnomalyLogThread_ {
81 
82 /*
83  * Restrict the anomaly logger count due to decoder state maintenance issues
84  */
85 
86 #define MAX_ANOMALY_LOGGERS 1
87 static int anomaly_loggers = 0;
88 static bool OutputAnomalyLoggerEnable(void)
89 {
90  if (anomaly_loggers < MAX_ANOMALY_LOGGERS) {
91  anomaly_loggers++;
92  return true;
93  }
94  return false;
95 }
96 
97 static void OutputAnomalyLoggerDisable(void)
98 {
99  if (anomaly_loggers)
100  anomaly_loggers--;
101 }
102 
103 static int AnomalyDecodeEventJson(ThreadVars *tv, JsonAnomalyLogThread *aft,
104  const Packet *p)
105 {
106  const uint16_t log_type = aft->json_output_ctx->flags;
107  const bool log_stream = log_type & LOG_JSON_STREAM_TYPE;
108  const bool log_decode = log_type & LOG_JSON_DECODE_TYPE;
109 
110  for (int i = 0; i < p->events.cnt; i++) {
111  uint8_t event_code = p->events.events[i];
112  bool is_decode = EVENT_IS_DECODER_PACKET_ERROR(event_code);
113  if (is_decode && !log_decode)
114  continue;
115  if (!is_decode && !log_stream)
116  continue;
117 
118  JsonBuilder *js = CreateEveHeader(
120  if (unlikely(js == NULL)) {
121  return TM_ECODE_OK;
122  }
123 
124  jb_open_object(js, ANOMALY_EVENT_TYPE);
125 
126  if (event_code < DECODE_EVENT_MAX) {
127  const char *event = DEvents[event_code].event_name;
128  if (EVENT_IS_DECODER_PACKET_ERROR(event_code)) {
129  JB_SET_STRING(js, "type", "decode");
130  } else {
131  JB_SET_STRING(js, "type", "stream");
132  }
133  jb_set_string(js, "event", event);
134  } else {
135  JB_SET_STRING(js, "type", "unknown");
136  jb_set_uint(js, "code", event_code);
137  }
138 
139  /* Close anomaly object. */
140  jb_close(js);
141 
143  EvePacket(p, js, GET_PKT_LEN(p) < 32 ? GET_PKT_LEN(p) : 32);
144  }
145 
146  OutputJsonBuilderBuffer(tv, p, p->flow, js, aft->ctx);
147  jb_free(js);
148  }
149 
150  return TM_ECODE_OK;
151 }
152 
153 static int AnomalyAppLayerDecoderEventJson(ThreadVars *tv, JsonAnomalyLogThread *aft,
154  const Packet *p, AppLayerDecoderEvents *decoder_events, bool is_pktlayer, const char *layer,
155  uint64_t tx_id)
156 {
157  const char *alprotoname = AppLayerGetProtoName(p->flow->alproto);
158 
159  SCLogDebug("decoder_events %p event_count %d (last logged %d) %s",
160  decoder_events, decoder_events->cnt,
161  decoder_events->event_last_logged,
162  tx_id != TX_ID_UNUSED ? "tx" : "no-tx");
163 
164  for (int i = decoder_events->event_last_logged; i < decoder_events->cnt; i++) {
165  JsonBuilder *js;
166  if (tx_id != TX_ID_UNUSED) {
168  aft->json_output_ctx->eve_ctx);
169  } else {
170  js = CreateEveHeader(
172  }
173  if (unlikely(js == NULL)) {
174  return TM_ECODE_OK;
175  }
176 
177 
178  jb_open_object(js, ANOMALY_EVENT_TYPE);
179 
180  jb_set_string(js, "app_proto", alprotoname);
181 
182  const char *event_name = NULL;
183  uint8_t event_code = decoder_events->events[i];
184  AppLayerEventType event_type;
185  int r;
186  if (is_pktlayer) {
187  r = AppLayerGetEventInfoById(event_code, &event_name, &event_type);
188  } else {
190  event_code, &event_name, &event_type);
191  }
192  if (r == 0) {
193  JB_SET_STRING(js, "type", "applayer");
194  jb_set_string(js, "event", event_name);
195  } else {
196  JB_SET_STRING(js, "type", "unknown");
197  jb_set_uint(js, "code", event_code);
198  }
199 
200  jb_set_string(js, "layer", layer);
201 
202  /* anomaly */
203  jb_close(js);
204  OutputJsonBuilderBuffer(tv, p, p->flow, js, aft->ctx);
205  jb_free(js);
206 
207  /* Current implementation assumes a single owner for this value */
208  decoder_events->event_last_logged++;
209  }
210 
211  return TM_ECODE_OK;
212 }
213 
214 static int JsonAnomalyTxLogger(ThreadVars *tv, void *thread_data, const Packet *p,
215  Flow *f, void *state, void *tx, uint64_t tx_id)
216 {
217  JsonAnomalyLogThread *aft = thread_data;
219  return TM_ECODE_OK;
220  }
221 
222  AppLayerDecoderEvents *decoder_events;
223  decoder_events = AppLayerParserGetEventsByTx(f->proto, f->alproto, tx);
224  if (decoder_events && decoder_events->event_last_logged < decoder_events->cnt) {
225  SCLogDebug("state %p, tx: %p, tx_id: %"PRIu64, state, tx, tx_id);
226  AnomalyAppLayerDecoderEventJson(tv, aft, p, decoder_events, false, "proto_parser", tx_id);
227  }
228  return TM_ECODE_OK;
229 }
230 
231 static inline bool AnomalyHasParserEvents(const Packet *p)
232 {
233  return (p->flow && p->flow->alparser &&
235 }
236 
237 static inline bool AnomalyHasPacketAppLayerEvents(const Packet *p)
238 {
239  return p->app_layer_events && p->app_layer_events->cnt;
240 }
241 
242 static int AnomalyJson(ThreadVars *tv, JsonAnomalyLogThread *aft, const Packet *p)
243 {
244  int rc = TM_ECODE_OK;
245 
246  /* decode or stream */
248  if (p->events.cnt) {
249  rc = AnomalyDecodeEventJson(tv, aft, p);
250  }
251  }
252 
253  /* applayer */
255  /* app layer proto detect events */
256  if (rc == TM_ECODE_OK && AnomalyHasPacketAppLayerEvents(p)) {
257  rc = AnomalyAppLayerDecoderEventJson(
258  tv, aft, p, p->app_layer_events, true, "proto_detect", TX_ID_UNUSED);
259  }
260 
261  /* parser state events */
262  if (rc == TM_ECODE_OK && AnomalyHasParserEvents(p)) {
263  SCLogDebug("Checking for anomaly events; alproto %d", p->flow->alproto);
265  if (parser_events && (parser_events->event_last_logged < parser_events->cnt)) {
266  rc = AnomalyAppLayerDecoderEventJson(
267  tv, aft, p, parser_events, false, "parser", TX_ID_UNUSED);
268  }
269  }
270  }
271 
272  return rc;
273 }
274 
275 static int JsonAnomalyFlush(ThreadVars *tv, void *thread_data, const Packet *p)
276 {
277  JsonAnomalyLogThread *aft = thread_data;
278  SCLogDebug("%s flushing %s", tv->name, ((LogFileCtx *)(aft->ctx->file_ctx))->filename);
279  OutputJsonFlush(aft->ctx);
280  return 0;
281 }
282 
283 static int JsonAnomalyLogger(ThreadVars *tv, void *thread_data, const Packet *p)
284 {
285  JsonAnomalyLogThread *aft = thread_data;
286  return AnomalyJson(tv, aft, p);
287 }
288 
289 static bool JsonAnomalyLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
290 {
291  return p->events.cnt > 0 ||
292  (p->app_layer_events && p->app_layer_events->cnt > 0) ||
293  AnomalyHasParserEvents(p);
294 }
295 
296 static TmEcode JsonAnomalyLogThreadInit(ThreadVars *t, const void *initdata, void **data)
297 {
299  if (unlikely(aft == NULL)) {
300  return TM_ECODE_FAILED;
301  }
302 
303  if (initdata == NULL) {
304  SCLogDebug("Error getting context for EveLogAnomaly. \"initdata\" argument NULL");
305  goto error_exit;
306  }
307 
308  /** Use the Output Context (file pointer and mutex) */
309  AnomalyJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
310 
311  aft->ctx = CreateEveThreadCtx(t, json_output_ctx->eve_ctx);
312  if (!aft->ctx) {
313  goto error_exit;
314  }
315  aft->json_output_ctx = json_output_ctx;
316 
317  *data = (void *)aft;
318  return TM_ECODE_OK;
319 
320 error_exit:
321  SCFree(aft);
322  return TM_ECODE_FAILED;
323 }
324 
325 static TmEcode JsonAnomalyLogThreadDeinit(ThreadVars *t, void *data)
326 {
328  if (aft == NULL) {
329  return TM_ECODE_OK;
330  }
331 
332  FreeEveThreadCtx(aft->ctx);
333 
334  /* clear memory */
335  memset(aft, 0, sizeof(JsonAnomalyLogThread));
336 
337  SCFree(aft);
338  return TM_ECODE_OK;
339 }
340 
341 static void JsonAnomalyLogDeInitCtxSubHelper(OutputCtx *output_ctx)
342 {
343  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
344 
345  AnomalyJsonOutputCtx *json_output_ctx = (AnomalyJsonOutputCtx *) output_ctx->data;
346 
347  if (json_output_ctx != NULL) {
348  SCFree(json_output_ctx);
349  }
350  SCFree(output_ctx);
351 }
352 
353 static void JsonAnomalyLogDeInitCtxSub(OutputCtx *output_ctx)
354 {
355  OutputAnomalyLoggerDisable();
356 
357  JsonAnomalyLogDeInitCtxSubHelper(output_ctx);
358 }
359 
360 static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
361 {
362  DEBUG_VALIDATE_BUG_ON(conf == NULL);
363  const char *setting = ConfNodeLookupChildValue(conf, name);
364  if (setting != NULL) {
365  if (ConfValIsTrue(setting)) {
366  *out_flags |= flag;
367  } else {
368  *out_flags &= ~flag;
369  }
370  }
371 }
372 
373 static void JsonAnomalyLogConf(AnomalyJsonOutputCtx *json_output_ctx,
374  ConfNode *conf)
375 {
376  static bool warn_no_flags = false;
377  static bool warn_no_packet = false;
378  uint16_t flags = ANOMALY_DEFAULTS;
379  if (conf != NULL) {
380  /* Check for metadata to enable/disable. */
381  ConfNode *typeconf = ConfNodeLookupChild(conf, "types");
382  if (typeconf != NULL) {
383  SetFlag(typeconf, "applayer", LOG_JSON_APPLAYER_TYPE, &flags);
384  SetFlag(typeconf, "stream", LOG_JSON_STREAM_TYPE, &flags);
385  SetFlag(typeconf, "decode", LOG_JSON_DECODE_TYPE, &flags);
386  }
387  SetFlag(conf, "packethdr", LOG_JSON_PACKETHDR, &flags);
388  }
389  if (((flags & (LOG_JSON_DECODE_TYPE | LOG_JSON_PACKETHDR)) == LOG_JSON_PACKETHDR) && !warn_no_packet) {
390  SCLogWarning("Anomaly logging configured to include packet headers, however decode "
391  "type logging has not been selected. Packet headers will not be logged.");
392  warn_no_packet = true;
394  }
395 
396  if (flags == 0 && !warn_no_flags) {
397  SCLogWarning("Anomaly logging has been configured; however, no logging types "
398  "have been selected. Select one or more logging types.");
399  warn_no_flags = true;
400  }
401  json_output_ctx->flags |= flags;
402 }
403 
404 static OutputInitResult JsonAnomalyLogInitCtxHelper(ConfNode *conf, OutputCtx *parent_ctx)
405 {
406  OutputInitResult result = { NULL, false };
407  OutputJsonCtx *ajt = parent_ctx->data;
408  AnomalyJsonOutputCtx *json_output_ctx = NULL;
409 
410  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
411  if (unlikely(output_ctx == NULL))
412  return result;
413 
414  json_output_ctx = SCCalloc(1, sizeof(AnomalyJsonOutputCtx));
415  if (unlikely(json_output_ctx == NULL)) {
416  goto error;
417  }
418 
419  JsonAnomalyLogConf(json_output_ctx, conf);
420  json_output_ctx->eve_ctx = ajt;
421 
422  output_ctx->data = json_output_ctx;
423  output_ctx->DeInit = JsonAnomalyLogDeInitCtxSubHelper;
424 
425  result.ctx = output_ctx;
426  result.ok = true;
427  return result;
428 
429 error:
430  SCFree(output_ctx);
431 
432  return result;
433 }
434 
435 /**
436  * \brief Create a new LogFileCtx for "fast" output style.
437  * \param conf The configuration node for this output.
438  * \return A LogFileCtx pointer on success, NULL on failure.
439  */
440 static OutputInitResult JsonAnomalyLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
441 {
442 
443  if (!OutputAnomalyLoggerEnable()) {
444  OutputInitResult result = { NULL, false };
445  SCLogError("only one 'anomaly' logger "
446  "can be enabled");
447  return result;
448  }
449 
450  OutputInitResult result = JsonAnomalyLogInitCtxHelper(conf, parent_ctx);
451  if (result.ok) {
452  result.ctx->DeInit = JsonAnomalyLogDeInitCtxSub;
453  }
454 
455  return result;
456 }
457 
459 {
460  OutputPacketLoggerFunctions output_logger_functions = {
461  .LogFunc = JsonAnomalyLogger,
462  .FlushFunc = JsonAnomalyFlush,
463  .ConditionFunc = JsonAnomalyLogCondition,
464  .ThreadInitFunc = JsonAnomalyLogThreadInit,
465  .ThreadDeinitFunc = JsonAnomalyLogThreadDeinit,
466  .ThreadExitPrintStatsFunc = NULL,
467  };
468 
469  OutputRegisterPacketSubModule(LOGGER_JSON_ANOMALY, "eve-log", MODULE_NAME, "eve-log.anomaly",
470  JsonAnomalyLogInitCtxSub, &output_logger_functions);
471 
472  OutputRegisterTxSubModule(LOGGER_JSON_ANOMALY, "eve-log", MODULE_NAME, "eve-log.anomaly",
473  JsonAnomalyLogInitCtxHelper, ALPROTO_UNKNOWN, JsonAnomalyTxLogger,
474  JsonAnomalyLogThreadInit, JsonAnomalyLogThreadDeinit);
475 }
util-byte.h
tm-threads.h
OutputJsonFlush
void OutputJsonFlush(OutputJsonThreadCtx *ctx)
Definition: output-json.c:975
detect-engine.h
EvePacket
void EvePacket(const Packet *p, JsonBuilder *js, uint32_t max_length)
Jsonify a packet.
Definition: output-json.c:422
TX_ID_UNUSED
#define TX_ID_UNUSED
Definition: output-json-anomaly.c:70
ThreadVars_::name
char name[16]
Definition: threadvars.h:65
LOG_JSON_PACKET_TYPE
#define LOG_JSON_PACKET_TYPE
Definition: output-json-anomaly.c:67
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:287
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
AppLayerParserGetEventsByTx
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
Definition: app-layer-parser.c:833
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
Flow_::proto
uint8_t proto
Definition: flow.h:376
threads.h
OutputJsonCtx_
Definition: output-json.h:81
MAX_ANOMALY_LOGGERS
#define MAX_ANOMALY_LOGGERS
Definition: output-json-anomaly.c:86
Flow_
Flow data structure.
Definition: flow.h:354
LogFileCtx_
Definition: util-logopenfile.h:72
OutputJsonBuilderBuffer
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:981
AnomalyJsonOutputCtx_::flags
uint16_t flags
Definition: output-json-anomaly.c:73
AppLayerDecoderEvents_::event_last_logged
uint8_t event_last_logged
Definition: app-layer-events.h:44
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
OutputRegisterTxSubModule
void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Definition: output.c:380
LOG_JSON_APPLAYER_TYPE
#define LOG_JSON_APPLAYER_TYPE
Definition: output-json-anomaly.c:64
util-privs.h
JsonAnomalyLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-anomaly.c:79
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:81
ANOMALY_DEFAULTS
#define ANOMALY_DEFAULTS
Definition: output-json-anomaly.c:68
AppLayerDecoderEvents_
Data structure to store app layer decoder events.
Definition: app-layer-events.h:36
Packet_::app_layer_events
AppLayerDecoderEvents * app_layer_events
Definition: decode.h:601
Packet_::events
PacketEngineEvents events
Definition: decode.h:599
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:536
OutputCtx_::data
void * data
Definition: tm-modules.h:87
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:80
ANOMALY_EVENT_TYPE
#define ANOMALY_EVENT_TYPE
Definition: output-json-anomaly.c:61
OutputCtx_
Definition: tm-modules.h:84
OutputJsonThreadCtx_
Definition: output-json.h:89
Flow_::alparser
AppLayerParserState * alparser
Definition: flow.h:476
AnomalyJsonOutputCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-anomaly.c:74
LOG_JSON_PACKETHDR
#define LOG_JSON_PACKETHDR
Definition: output-json-anomaly.c:65
JsonAnomalyLogRegister
void JsonAnomalyLogRegister(void)
Definition: output-json-anomaly.c:458
util-debug.h
JB_SET_STRING
#define JB_SET_STRING(jb, key, val)
Definition: rust.h:26
AppLayerParserGetEventInfoById
int AppLayerParserGetEventInfoById(uint8_t ipproto, AppProto alproto, uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-parser.c:1116
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
DEvents
const struct DecodeEvents_ DEvents[]
Definition: decode-events.c:29
output-json.h
CreateEveHeader
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
Definition: output-json.c:823
util-print.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
OutputInitResult_::ok
bool ok
Definition: output.h:48
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:249
app-layer-parser.h
AppLayerDecoderEvents_::cnt
uint8_t cnt
Definition: app-layer-events.h:40
CreateEveHeaderWithTxId
JsonBuilder * CreateEveHeaderWithTxId(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, uint64_t tx_id, OutputJsonCtx *eve_ctx)
Definition: output-json.c:919
JsonAnomalyLogThread
struct JsonAnomalyLogThread_ JsonAnomalyLogThread
output-json-anomaly.h
MODULE_NAME
#define MODULE_NAME
Definition: output-json-anomaly.c:59
Packet_
Definition: decode.h:476
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:204
conf.h
TmEcode
TmEcode
Definition: tm-threads-common.h:79
name
const char * name
Definition: tm-threads.c:2081
OutputJsonThreadCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:91
util-proto-name.h
LOG_JSON_STREAM_TYPE
#define LOG_JSON_STREAM_TYPE
Definition: output-json-anomaly.c:63
DecodeEvents_::event_name
const char * event_name
Definition: decode-events.h:324
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:781
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
OutputInitResult_
Definition: output.h:46
Packet_::flow
struct Flow_ * flow
Definition: decode.h:515
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-json.h:37
flags
uint8_t flags
Definition: decode-gre.h:0
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:90
JsonAnomalyLogThread_::json_output_ctx
AnomalyJsonOutputCtx * json_output_ctx
Definition: output-json-anomaly.c:78
OutputPacketLoggerFunctions_::LogFunc
PacketLogger LogFunc
Definition: output.h:88
LOG_JSON_DECODE_TYPE
#define LOG_JSON_DECODE_TYPE
Definition: output-json-anomaly.c:62
JsonAnomalyLogThread_
Definition: output-json-anomaly.c:77
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, OutputPacketLoggerFunctions *output_logger_functions)
Register a packet output sub-module.
Definition: output.c:208
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
util-optimize.h
app-layer-events.h
threadvars.h
util-validate.h
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
AppLayerParserGetDecoderEvents
AppLayerDecoderEvents * AppLayerParserGetDecoderEvents(AppLayerParserState *pstate)
Definition: app-layer-parser.c:825
detect-parse.h
util-buffer.h
AppLayerGetProtoName
const char * AppLayerGetProtoName(AppProto alproto)
Given the internal protocol id, returns a string representation of the protocol.
Definition: app-layer.c:1008
AppLayerGetEventInfoById
int AppLayerGetEventInfoById(uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-events.c:63
AnomalyJsonOutputCtx_
Definition: output-json-anomaly.c:72
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
util-misc.h
flow.h
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:448
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
util-enum.h
OutputPacketLoggerFunctions_
Definition: output.h:87
AppLayerParserHasDecoderEvents
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
Definition: app-layer-parser.c:1493
AppLayerDecoderEvents_::events
uint8_t * events
Definition: app-layer-events.h:38
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:102
output.h
AnomalyJsonOutputCtx
struct AnomalyJsonOutputCtx_ AnomalyJsonOutputCtx
app-layer.h
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:315
LOGGER_JSON_ANOMALY
@ LOGGER_JSON_ANOMALY
Definition: suricata-common.h:490
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:286
EVENT_IS_DECODER_PACKET_ERROR
#define EVENT_IS_DECODER_PACKET_ERROR(e)
Definition: decode-events.h:318
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:809