suricata
output-json-anomaly.c
Go to the documentation of this file.
1 /* Copyright (C) 2019-2020 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 "debug.h"
29 #include "detect.h"
30 #include "flow.h"
31 #include "conf.h"
32 #include "app-layer.h"
33 #include "app-layer-events.h"
34 #include "app-layer-parser.h"
35 
36 #include "threads.h"
37 #include "tm-threads.h"
38 #include "threadvars.h"
39 #include "util-debug.h"
40 
41 #include "util-misc.h"
42 
43 #include "detect-parse.h"
44 #include "detect-engine.h"
45 #include "util-logopenfile.h"
46 
47 #include "output.h"
48 #include "output-json.h"
49 #include "output-json-anomaly.h"
50 
51 #include "util-byte.h"
52 #include "util-enum.h"
53 #include "util-privs.h"
54 #include "util-print.h"
55 #include "util-proto-name.h"
56 #include "util-optimize.h"
57 #include "util-buffer.h"
58 #include "util-crypt.h"
59 #include "util-validate.h"
60 
61 #define MODULE_NAME "JsonAnomalyLog"
62 
63 #define ANOMALY_EVENT_TYPE "anomaly"
64 #define LOG_JSON_DECODE_TYPE BIT_U16(0)
65 #define LOG_JSON_STREAM_TYPE BIT_U16(1)
66 #define LOG_JSON_APPLAYER_TYPE BIT_U16(2)
67 #define LOG_JSON_PACKETHDR BIT_U16(3)
68 
69 #define LOG_JSON_PACKET_TYPE (LOG_JSON_DECODE_TYPE | LOG_JSON_STREAM_TYPE)
70 #define ANOMALY_DEFAULTS LOG_JSON_APPLAYER_TYPE
71 
72 #define TX_ID_UNUSED UINT64_MAX
73 
74 typedef struct AnomalyJsonOutputCtx_ {
76  uint16_t flags;
79 
80 typedef struct JsonAnomalyLogThread_ {
81  /** LogFileCtx has the pointer to the file and a mutex to allow multithreading */
86 
87 static int AnomalyDecodeEventJson(ThreadVars *tv, JsonAnomalyLogThread *aft,
88  const Packet *p)
89 {
90  const bool is_ip_pkt = PKT_IS_IPV4(p) || PKT_IS_IPV6(p);
91 
92  char timebuf[64];
93  CreateIsoTimeString(&p->ts, timebuf, sizeof(timebuf));
94 
95  const uint16_t log_type = aft->json_output_ctx->flags;
96  const bool log_stream = log_type & LOG_JSON_STREAM_TYPE;
97  const bool log_decode = log_type & LOG_JSON_DECODE_TYPE;
98  for (int i = 0; i < p->events.cnt; i++) {
99  uint8_t event_code = p->events.events[i];
100  bool is_decode = EVENT_IS_DECODER_PACKET_ERROR(event_code);
101  if (is_decode && !log_decode)
102  continue;
103  if (!is_decode && !log_stream)
104  continue;
105 
107 
109  if (unlikely(js == NULL)) {
110  return TM_ECODE_OK;
111  }
112 
113  json_t *ajs = json_object();
114  if (unlikely(ajs == NULL)) {
115  json_decref(js);
116  return TM_ECODE_OK;
117  }
118 
119  if (!is_ip_pkt) {
120  json_object_set_new(js, "timestamp", json_string(timebuf));
121  } else {
122  JsonAddCommonOptions(&aft->json_output_ctx->cfg, p, p->flow, js);
123  }
124 
126  JsonPacket(p, js, GET_PKT_LEN(p) < 32 ? GET_PKT_LEN(p) : 32);
127  }
128 
129  if (event_code < DECODE_EVENT_MAX) {
130  const char *event = DEvents[event_code].event_name;
131  json_object_set_new(ajs, "type",
132  EVENT_IS_DECODER_PACKET_ERROR(event_code) ?
133  json_string("decode") : json_string("stream"));
134  json_object_set_new(ajs, "event", json_string(event));
135  } else {
136  json_object_set_new(ajs, "type", json_string("unknown"));
137  json_object_set_new(ajs, "code", json_integer(event_code));
138  }
139 
140  /* anomaly */
141  json_object_set_new(js, ANOMALY_EVENT_TYPE, ajs);
142  OutputJSONBuffer(js, aft->file_ctx, &aft->json_buffer);
143 
144  json_object_clear(js);
145  json_decref(js);
146  }
147 
148  return TM_ECODE_OK;
149 }
150 
151 static int AnomalyAppLayerDecoderEventJson(JsonAnomalyLogThread *aft,
152  const Packet *p, AppLayerDecoderEvents *decoder_events,
153  bool is_pktlayer, const char *layer, uint64_t tx_id)
154 {
155  const char *alprotoname = AppLayerGetProtoName(p->flow->alproto);
156 
157  SCLogDebug("decoder_events %p event_count %d (last logged %d) %s",
158  decoder_events, decoder_events->cnt,
159  decoder_events->event_last_logged,
160  tx_id != TX_ID_UNUSED ? "tx" : "no-tx");
161 
162  for (int i = decoder_events->event_last_logged; i < decoder_events->cnt; i++) {
164 
165  json_t *js;
166  if (tx_id != TX_ID_UNUSED) {
168  ANOMALY_EVENT_TYPE, tx_id);
169  } else {
171  }
172  if (unlikely(js == NULL)) {
173  return TM_ECODE_OK;
174  }
175 
176  json_t *ajs = json_object();
177  if (unlikely(ajs == NULL)) {
178  json_decref(js);
179  return TM_ECODE_OK;
180  }
181 
182  JsonAddCommonOptions(&aft->json_output_ctx->cfg, p, p->flow, js);
183 
184  json_object_set_new(js, "app_proto", json_string(alprotoname));
185 
186  const char *event_name = NULL;
187  uint8_t event_code = decoder_events->events[i];
188  AppLayerEventType event_type;
189  int r;
190  if (is_pktlayer) {
191  r = AppLayerGetEventInfoById(event_code, &event_name, &event_type);
192  } else {
194  event_code, &event_name, &event_type);
195  }
196  if (r == 0) {
197  json_object_set_new(ajs, "type", json_string("applayer"));
198  json_object_set_new(ajs, "event", json_string(event_name));
199  } else {
200  json_object_set_new(ajs, "type", json_string("unknown"));
201  json_object_set_new(ajs, "code", json_integer(event_code));
202  }
203 
204  json_object_set_new(ajs, "layer", json_string(layer));
205 
206  /* anomaly */
207  json_object_set_new(js, ANOMALY_EVENT_TYPE, ajs);
208  OutputJSONBuffer(js, aft->file_ctx, &aft->json_buffer);
209 
210  json_object_clear(js);
211  json_decref(js);
212 
213  /* Current implementation assumes a single owner for this value */
214  decoder_events->event_last_logged++;
215  }
216 
217  return TM_ECODE_OK;
218 }
219 
220 static int JsonAnomalyTxLogger(ThreadVars *tv, void *thread_data, const Packet *p,
221  Flow *f, void *state, void *tx, uint64_t tx_id)
222 {
223  JsonAnomalyLogThread *aft = thread_data;
225  return TM_ECODE_OK;
226  }
227 
228  AppLayerDecoderEvents *decoder_events;
229  decoder_events = AppLayerParserGetEventsByTx(f->proto, f->alproto, tx);
230  if (decoder_events && decoder_events->event_last_logged < decoder_events->cnt) {
231  SCLogDebug("state %p, tx: %p, tx_id: %"PRIu64, state, tx, tx_id);
232  AnomalyAppLayerDecoderEventJson(aft, p, decoder_events, false,
233  "proto_parser", tx_id);
234  }
235  return TM_ECODE_OK;
236 }
237 
238 static inline bool AnomalyHasParserEvents(const Packet *p)
239 {
240  return (p->flow && p->flow->alparser &&
242 }
243 
244 static inline bool AnomalyHasPacketAppLayerEvents(const Packet *p)
245 {
246  return p->app_layer_events && p->app_layer_events->cnt;
247 }
248 
249 static int AnomalyJson(ThreadVars *tv, JsonAnomalyLogThread *aft, const Packet *p)
250 {
251  int rc = TM_ECODE_OK;
252 
253  /* decode or stream */
255  if (p->events.cnt) {
256  rc = AnomalyDecodeEventJson(tv, aft, p);
257  }
258  }
259 
260  /* applayer */
262  /* app layer proto detect events */
263  if (rc == TM_ECODE_OK && AnomalyHasPacketAppLayerEvents(p)) {
264  rc = AnomalyAppLayerDecoderEventJson(aft, p, p->app_layer_events,
265  true, "proto_detect", TX_ID_UNUSED);
266  }
267 
268  /* parser state events */
269  if (rc == TM_ECODE_OK && AnomalyHasParserEvents(p)) {
270  SCLogDebug("Checking for anomaly events; alproto %d", p->flow->alproto);
272  if (parser_events && (parser_events->event_last_logged < parser_events->cnt)) {
273  rc = AnomalyAppLayerDecoderEventJson(aft, p, parser_events,
274  false, "parser", TX_ID_UNUSED);
275  }
276  }
277  }
278 
279  return rc;
280 }
281 
282 static int JsonAnomalyLogger(ThreadVars *tv, void *thread_data, const Packet *p)
283 {
284  JsonAnomalyLogThread *aft = thread_data;
285  return AnomalyJson(tv, aft, p);
286 }
287 
288 static int JsonAnomalyLogCondition(ThreadVars *tv, const Packet *p)
289 {
290  return p->events.cnt > 0 ||
291  (p->app_layer_events && p->app_layer_events->cnt > 0) ||
292  AnomalyHasParserEvents(p);
293 }
294 
295 static TmEcode JsonAnomalyLogThreadInit(ThreadVars *t, const void *initdata, void **data)
296 {
298  if (unlikely(aft == NULL)) {
299  return TM_ECODE_FAILED;
300  }
301 
302  if (initdata == NULL) {
303  SCLogDebug("Error getting context for EveLogAnomaly. \"initdata\" argument NULL");
304  SCFree(aft);
305  return TM_ECODE_FAILED;
306  }
307 
309  if (aft->json_buffer == NULL) {
310  SCFree(aft);
311  return TM_ECODE_FAILED;
312  }
313 
314  /** Use the Output Context (file pointer and mutex) */
315  AnomalyJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
316  aft->file_ctx = json_output_ctx->file_ctx;
317  aft->json_output_ctx = json_output_ctx;
318 
319  *data = (void *)aft;
320  return TM_ECODE_OK;
321 }
322 
323 static TmEcode JsonAnomalyLogThreadDeinit(ThreadVars *t, void *data)
324 {
326  if (aft == NULL) {
327  return TM_ECODE_OK;
328  }
329 
331 
332  /* clear memory */
333  memset(aft, 0, sizeof(JsonAnomalyLogThread));
334 
335  SCFree(aft);
336  return TM_ECODE_OK;
337 }
338 
339 static void JsonAnomalyLogDeInitCtxSub(OutputCtx *output_ctx)
340 {
341  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
342 
343  AnomalyJsonOutputCtx *json_output_ctx = (AnomalyJsonOutputCtx *) output_ctx->data;
344 
345  if (json_output_ctx != NULL) {
346  SCFree(json_output_ctx);
347  }
348  SCFree(output_ctx);
349 }
350 
351 #define DEFAULT_LOG_FILENAME "anomaly.json"
352 static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
353 {
354  DEBUG_VALIDATE_BUG_ON(conf == NULL);
355  const char *setting = ConfNodeLookupChildValue(conf, name);
356  if (setting != NULL) {
357  if (ConfValIsTrue(setting)) {
358  *out_flags |= flag;
359  } else {
360  *out_flags &= ~flag;
361  }
362  }
363 }
364 
365 static void JsonAnomalyLogConf(AnomalyJsonOutputCtx *json_output_ctx,
366  ConfNode *conf)
367 {
368  static bool warn_no_flags = false;
369  static bool warn_no_packet = false;
370  uint16_t flags = ANOMALY_DEFAULTS;
371  if (conf != NULL) {
372  /* Check for metadata to enable/disable. */
373  ConfNode *typeconf = ConfNodeLookupChild(conf, "types");
374  if (typeconf != NULL) {
375  SetFlag(typeconf, "applayer", LOG_JSON_APPLAYER_TYPE, &flags);
376  SetFlag(typeconf, "stream", LOG_JSON_STREAM_TYPE, &flags);
377  SetFlag(typeconf, "decode", LOG_JSON_DECODE_TYPE, &flags);
378  }
379  SetFlag(conf, "packethdr", LOG_JSON_PACKETHDR, &flags);
380  }
381  if (((flags & (LOG_JSON_DECODE_TYPE | LOG_JSON_PACKETHDR)) == LOG_JSON_PACKETHDR) && !warn_no_packet) {
382  SCLogWarning(SC_WARN_ANOMALY_CONFIG, "Anomaly logging configured to include packet headers, however decode "
383  "type logging has not been selected. Packet headers will not be logged.");
384  warn_no_packet = true;
386  }
387 
388  if (flags == 0 && !warn_no_flags) {
389  SCLogWarning(SC_WARN_ANOMALY_CONFIG, "Anomaly logging has been configured; however, no logging types "
390  "have been selected. Select one or more logging types.");
391  warn_no_flags = true;
392  }
393  json_output_ctx->flags |= flags;
394 }
395 
396 /**
397  * \brief Create a new LogFileCtx for "fast" output style.
398  * \param conf The configuration node for this output.
399  * \return A LogFileCtx pointer on success, NULL on failure.
400  */
401 static OutputInitResult JsonAnomalyLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
402 {
403  OutputInitResult result = { NULL, false };
404  OutputJsonCtx *ajt = parent_ctx->data;
405  AnomalyJsonOutputCtx *json_output_ctx = NULL;
406 
407  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
408  if (unlikely(output_ctx == NULL))
409  return result;
410 
411  json_output_ctx = SCCalloc(1, sizeof(AnomalyJsonOutputCtx));
412  if (unlikely(json_output_ctx == NULL)) {
413  goto error;
414  }
415 
416  json_output_ctx->file_ctx = ajt->file_ctx;
417  JsonAnomalyLogConf(json_output_ctx, conf);
418  json_output_ctx->cfg = ajt->cfg;
419 
420  output_ctx->data = json_output_ctx;
421  output_ctx->DeInit = JsonAnomalyLogDeInitCtxSub;
422 
423  result.ctx = output_ctx;
424  result.ok = true;
425  return result;
426 
427 error:
428  SCFree(output_ctx);
429 
430  return result;
431 }
432 
434 {
436  "eve-log.anomaly", JsonAnomalyLogInitCtxSub, JsonAnomalyLogger,
437  JsonAnomalyLogCondition, JsonAnomalyLogThreadInit, JsonAnomalyLogThreadDeinit,
438  NULL);
439 
441  "eve-log.anomaly", JsonAnomalyLogInitCtxSub, ALPROTO_UNKNOWN,
442  JsonAnomalyTxLogger, JsonAnomalyLogThreadInit,
443  JsonAnomalyLogThreadDeinit, NULL);
444 }
util-byte.h
tm-threads.h
detect-engine.h
TX_ID_UNUSED
#define TX_ID_UNUSED
Definition: output-json-anomaly.c:72
CreateIsoTimeString
void CreateIsoTimeString(const struct timeval *ts, char *str, size_t size)
Definition: util-time.c:194
PKT_IS_IPV6
#define PKT_IS_IPV6(p)
Definition: decode.h:253
OutputJsonCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json.h:81
LOG_JSON_PACKET_TYPE
#define LOG_JSON_PACKET_TYPE
Definition: output-json-anomaly.c:69
SCFree
#define SCFree(a)
Definition: util-mem.h:322
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SC_WARN_ANOMALY_CONFIG
@ SC_WARN_ANOMALY_CONFIG
Definition: util-error.h:356
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:308
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:335
AppLayerParserGetEventsByTx
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
Definition: app-layer-parser.c:857
Flow_::proto
uint8_t proto
Definition: flow.h:359
JSON_OUTPUT_BUFFER_SIZE
#define JSON_OUTPUT_BUFFER_SIZE
Definition: output-json.h:44
threads.h
OutputJsonCtx_
Definition: output-json.h:78
Flow_
Flow data structure.
Definition: flow.h:340
OutputJsonCommonSettings_
Definition: output-json.h:69
AppLayerEventType
enum AppLayerEventType_ AppLayerEventType
LogFileCtx_
Definition: util-logopenfile.h:52
AnomalyJsonOutputCtx_::flags
uint16_t flags
Definition: output-json-anomaly.c:76
AppLayerDecoderEvents_::event_last_logged
uint8_t event_last_logged
Definition: app-layer-events.h:42
LOG_JSON_APPLAYER_TYPE
#define LOG_JSON_APPLAYER_TYPE
Definition: output-json-anomaly.c:66
util-privs.h
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:79
ANOMALY_DEFAULTS
#define ANOMALY_DEFAULTS
Definition: output-json-anomaly.c:70
AppLayerDecoderEvents_
Data structure to store app layer decoder events.
Definition: app-layer-events.h:34
Packet_::app_layer_events
AppLayerDecoderEvents * app_layer_events
Definition: decode.h:568
Packet_::events
PacketEngineEvents events
Definition: decode.h:566
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:566
OutputCtx_::data
void * data
Definition: tm-modules.h:81
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:78
ANOMALY_EVENT_TYPE
#define ANOMALY_EVENT_TYPE
Definition: output-json-anomaly.c:63
AppLayerParserGetEventInfoById
int AppLayerParserGetEventInfoById(uint8_t ipproto, AppProto alproto, int event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-parser.c:1075
OutputCtx_
Definition: tm-modules.h:78
Flow_::alparser
AppLayerParserState * alparser
Definition: flow.h:451
AnomalyJsonOutputCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json-anomaly.c:77
LOG_JSON_PACKETHDR
#define LOG_JSON_PACKETHDR
Definition: output-json-anomaly.c:67
JsonPacket
void JsonPacket(const Packet *p, json_t *js, unsigned long max_length)
Jsonify a packet.
Definition: output-json.c:408
JsonAnomalyLogRegister
void JsonAnomalyLogRegister(void)
Definition: output-json-anomaly.c:433
util-debug.h
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:42
DEvents
const struct DecodeEvents_ DEvents[]
Definition: decode-events.c:29
output-json.h
util-print.h
util-crypt.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
AnomalyJsonOutputCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-anomaly.c:75
OutputInitResult_::ok
bool ok
Definition: output.h:43
AppLayerGetEventInfoById
int AppLayerGetEventInfoById(int event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-events.c:51
app-layer-parser.h
AppLayerDecoderEvents_::cnt
uint8_t cnt
Definition: app-layer-events.h:38
JsonAnomalyLogThread
struct JsonAnomalyLogThread_ JsonAnomalyLogThread
output-json-anomaly.h
MODULE_NAME
#define MODULE_NAME
Definition: output-json-anomaly.c:61
Packet_
Definition: decode.h:408
SCCalloc
#define SCCalloc(nm, a)
Definition: util-mem.h:253
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:225
conf.h
TmEcode
TmEcode
Definition: tm-threads-common.h:77
util-proto-name.h
MemBuffer_
Definition: util-buffer.h:27
LOG_JSON_STREAM_TYPE
#define LOG_JSON_STREAM_TYPE
Definition: output-json-anomaly.c:65
DecodeEvents_::event_name
const char * event_name
Definition: decode-events.h:271
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:815
MemBufferReset
#define MemBufferReset(mem_buffer)
Reset the mem buffer.
Definition: util-buffer.h:42
OutputInitResult_
Definition: output.h:41
Packet_::flow
struct Flow_ * flow
Definition: decode.h:446
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-json.h:37
flags
uint8_t flags
Definition: decode-gre.h:2
Packet_::ts
struct timeval ts
Definition: decode.h:452
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:84
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output sub-module.
Definition: output.c:213
CreateJSONHeader
json_t * CreateJSONHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type)
Definition: output-json.c:710
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:82
JsonAnomalyLogThread_::json_output_ctx
AnomalyJsonOutputCtx * json_output_ctx
Definition: output-json-anomaly.c:84
LOG_JSON_DECODE_TYPE
#define LOG_JSON_DECODE_TYPE
Definition: output-json-anomaly.c:64
JsonAnomalyLogThread_
Definition: output-json-anomaly.c:80
JsonAddCommonOptions
void JsonAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, json_t *js)
Definition: output-json.c:390
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, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:411
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
util-optimize.h
app-layer-events.h
threadvars.h
util-validate.h
JsonAnomalyLogThread_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-anomaly.c:82
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
ConfNode_
Definition: conf.h:32
util-logopenfile.h
AppLayerParserGetDecoderEvents
AppLayerDecoderEvents * AppLayerParserGetDecoderEvents(AppLayerParserState *pstate)
Definition: app-layer-parser.c:844
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:771
AnomalyJsonOutputCtx_
Definition: output-json-anomaly.c:74
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:79
OutputJSONBuffer
int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer)
Definition: output-json.c:809
JsonAnomalyLogThread_::json_buffer
MemBuffer * json_buffer
Definition: output-json-anomaly.c:83
util-misc.h
flow.h
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:423
util-enum.h
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:252
AppLayerParserHasDecoderEvents
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
Definition: app-layer-parser.c:1360
AppLayerDecoderEvents_::events
uint8_t * events
Definition: app-layer-events.h:36
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:262
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:111
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
debug.h
output.h
AnomalyJsonOutputCtx
struct AnomalyJsonOutputCtx_ AnomalyJsonOutputCtx
CreateJSONHeaderWithTxId
json_t * CreateJSONHeaderWithTxId(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, uint64_t tx_id)
Definition: output-json.c:783
app-layer.h
LOGGER_JSON_ANOMALY
@ LOGGER_JSON_ANOMALY
Definition: suricata-common.h:453
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:307
EVENT_IS_DECODER_PACKET_ERROR
#define EVENT_IS_DECODER_PACKET_ERROR(e)
Definition: decode-events.h:265
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:843