suricata
output-json-alert.c
Go to the documentation of this file.
1 /* Copyright (C) 2013-2026 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 Tom DeCanio <td@npulsetech.com>
22  *
23  * Logs alerts in JSON format.
24  *
25  */
26 
27 #include "suricata-common.h"
28 #include "packet.h"
29 #include "detect.h"
30 #include "flow.h"
31 #include "conf.h"
32 
33 #include "stream.h"
34 #include "threadvars.h"
35 #include "util-debug.h"
36 #include "stream-tcp.h"
37 
38 #include "util-logopenfile.h"
39 #include "util-misc.h"
40 
41 #include "detect-parse.h"
42 #include "detect-engine.h"
43 #include "detect-metadata.h"
44 #include "app-layer-parser.h"
45 #include "app-layer-htp-xff.h"
46 #include "app-layer-ftp.h"
47 #include "app-layer-frames.h"
48 #include "log-pcap.h"
49 
50 #include "output.h"
51 #include "output-json.h"
52 #include "output-json-alert.h"
53 #include "output-json-http.h"
54 #include "rust.h"
55 #include "output-json-smtp.h"
57 #include "output-json-nfs.h"
58 #include "output-json-smb.h"
59 #include "output-json-flow.h"
60 #include "output-json-ike.h"
61 #include "output-json-frame.h"
62 
63 #include "util-print.h"
64 #include "util-buffer.h"
65 #include "util-reference-config.h"
66 #include "util-validate.h"
67 
68 #include "action-globals.h"
69 
70 #define MODULE_NAME "JsonAlertLog"
71 
72 #define LOG_JSON_PAYLOAD BIT_U16(0)
73 #define LOG_JSON_PACKET BIT_U16(1)
74 #define LOG_JSON_PAYLOAD_BASE64 BIT_U16(2)
75 #define LOG_JSON_TAGGED_PACKETS BIT_U16(3)
76 #define LOG_JSON_APP_LAYER BIT_U16(4)
77 #define LOG_JSON_FLOW BIT_U16(5)
78 #define LOG_JSON_HTTP_BODY BIT_U16(6)
79 #define LOG_JSON_HTTP_BODY_BASE64 BIT_U16(7)
80 #define LOG_JSON_RULE_METADATA BIT_U16(8)
81 #define LOG_JSON_RULE BIT_U16(9)
82 #define LOG_JSON_VERDICT BIT_U16(10)
83 #define LOG_JSON_WEBSOCKET_PAYLOAD BIT_U16(11)
84 #define LOG_JSON_WEBSOCKET_PAYLOAD_BASE64 BIT_U16(12)
85 #define LOG_JSON_PAYLOAD_LENGTH BIT_U16(13)
86 #define LOG_JSON_REFERENCE BIT_U16(14)
87 
88 #define METADATA_DEFAULTS ( LOG_JSON_FLOW | \
89  LOG_JSON_APP_LAYER | \
90  LOG_JSON_RULE_METADATA)
91 
92 #define JSON_BODY_LOGGING \
93  (LOG_JSON_HTTP_BODY | LOG_JSON_HTTP_BODY_BASE64 | LOG_JSON_WEBSOCKET_PAYLOAD | \
94  LOG_JSON_WEBSOCKET_PAYLOAD_BASE64)
95 
96 #define JSON_STREAM_BUFFER_SIZE 4096
97 
98 typedef struct AlertJsonOutputCtx_ {
100  uint16_t flags;
106 
107 typedef struct JsonAlertLogThread_ {
112 
113 static void AlertJsonSourceTarget(
114  const Packet *p, const PacketAlert *pa, SCJsonBuilder *js, JsonAddrInfo *addr)
115 {
116  SCJbOpenObject(js, "source");
117  if (pa->s->flags & SIG_FLAG_DEST_IS_TARGET) {
118  SCJbSetString(js, "ip", addr->src_ip);
119  switch (p->proto) {
120  case IPPROTO_ICMP:
121  case IPPROTO_ICMPV6:
122  break;
123  case IPPROTO_UDP:
124  case IPPROTO_TCP:
125  case IPPROTO_SCTP:
126  SCJbSetUint(js, "port", addr->sp);
127  break;
128  }
129  } else if (pa->s->flags & SIG_FLAG_SRC_IS_TARGET) {
130  SCJbSetString(js, "ip", addr->dst_ip);
131  switch (p->proto) {
132  case IPPROTO_ICMP:
133  case IPPROTO_ICMPV6:
134  break;
135  case IPPROTO_UDP:
136  case IPPROTO_TCP:
137  case IPPROTO_SCTP:
138  SCJbSetUint(js, "port", addr->dp);
139  break;
140  }
141  }
142  SCJbClose(js);
143 
144  SCJbOpenObject(js, "target");
145  if (pa->s->flags & SIG_FLAG_DEST_IS_TARGET) {
146  SCJbSetString(js, "ip", addr->dst_ip);
147  switch (p->proto) {
148  case IPPROTO_ICMP:
149  case IPPROTO_ICMPV6:
150  break;
151  case IPPROTO_UDP:
152  case IPPROTO_TCP:
153  case IPPROTO_SCTP:
154  SCJbSetUint(js, "port", addr->dp);
155  break;
156  }
157  } else if (pa->s->flags & SIG_FLAG_SRC_IS_TARGET) {
158  SCJbSetString(js, "ip", addr->src_ip);
159  switch (p->proto) {
160  case IPPROTO_ICMP:
161  case IPPROTO_ICMPV6:
162  break;
163  case IPPROTO_UDP:
164  case IPPROTO_TCP:
165  case IPPROTO_SCTP:
166  SCJbSetUint(js, "port", addr->sp);
167  break;
168  }
169  }
170  SCJbClose(js);
171 }
172 
173 static void AlertJsonReference(const PacketAlert *pa, SCJsonBuilder *jb)
174 {
175  if (!pa->s->references) {
176  return;
177  }
178 
179  const DetectReference *kv = pa->s->references;
180  SCJbOpenArray(jb, "references");
181  while (kv) {
182  /* Note that the key and reference sizes have been bound
183  * checked during parsing
184  * add +2 to safisfy gcc 15 + -Wformat-truncation=2
185  */
186  const size_t size_needed = kv->key_len + kv->reference_len + 3;
188  /* DetectReferenceParse() is the only producer and sets both alongside
189  * their lengths. Trip a debug build if a future one does not, and keep
190  * a release build off the undefined behavior of "%s" with NULL. */
191  DEBUG_VALIDATE_BUG_ON(kv->key == NULL || kv->reference == NULL);
192  const char *key = kv->key ? kv->key : "";
193  const char *reference = kv->reference ? kv->reference : "";
194  char kv_store[size_needed];
195  snprintf(kv_store, size_needed, "%s%s", key, reference);
196  SCJbAppendString(jb, kv_store);
197  kv = kv->next;
198  }
199  SCJbClose(jb);
200 }
201 
202 static void AlertJsonMetadata(const PacketAlert *pa, SCJsonBuilder *js)
203 {
204  if (pa->s->metadata && pa->s->metadata->json_str) {
205  SCJbSetFormatted(js, pa->s->metadata->json_str);
206  }
207 }
208 
209 void AlertJsonHeader(const Packet *p, const PacketAlert *pa, SCJsonBuilder *js, uint16_t flags,
210  JsonAddrInfo *addr, char *xff_buffer)
211 {
212  const char *action = "allowed";
213  /* use packet action if rate_filter modified the action */
216  action = "blocked";
217  }
218  } else {
219  if (pa->action & ACTION_REJECT_ANY) {
220  action = "blocked";
221  } else if ((pa->action & ACTION_DROP) && EngineModeIsIPS()) {
222  action = "blocked";
223  }
224  }
225 
226  /* Add tx_id to root element for correlation with other events. */
227  /* json_object_del(js, "tx_id"); */
228  if (pa->flags & PACKET_ALERT_FLAG_TX) {
229  SCJbSetUint(js, "tx_id", pa->tx_id);
230  }
232  SCJbSetBool(js, "tx_guessed", true);
233  }
234 
235  SCJbOpenObject(js, "alert");
236 
237  SCJbSetString(js, "action", action);
238  if (EngineModeIsFirewall()) {
239  SCJbSetString(js, "engine", (pa->s->flags & SIG_FLAG_FIREWALL) ? "fw" : "td");
240  }
241  SCJbSetUint(js, "gid", pa->s->gid);
242  SCJbSetUint(js, "signature_id", pa->s->id);
243  SCJbSetUint(js, "rev", pa->s->rev);
244  /* TODO: SCJsonBuilder should handle unprintable characters like
245  * SCJsonString. */
246  SCJbSetString(js, "signature", pa->s->msg ? pa->s->msg : "");
247  SCJbSetString(js, "category", pa->s->class_msg ? pa->s->class_msg : "");
248  SCJbSetUint(js, "severity", pa->s->prio);
249 
250  if (p->tenant_id > 0) {
251  SCJbSetUint(js, "tenant_id", p->tenant_id);
252  }
253 
254  if (addr && pa->s->flags & SIG_FLAG_HAS_TARGET) {
255  AlertJsonSourceTarget(p, pa, js, addr);
256  }
257 
258  if ((flags & LOG_JSON_REFERENCE)) {
259  AlertJsonReference(pa, js);
260  }
261 
263  AlertJsonMetadata(pa, js);
264  }
265 
266  if (pa->json_info != NULL) {
267  SCJbOpenObject(js, "context");
268  const struct PacketContextData *json_info = pa->json_info;
269  while (json_info) {
270  SCLogDebug("JSON string '{%s}'", json_info->json_string);
271  /* The string is valid json as it is validated by JANSSON
272  during parsing and included later via a format string */
273  SCJbSetFormatted(js, json_info->json_string);
274  json_info = json_info->next;
275  }
276  SCJbClose(js);
277  }
278  if (flags & LOG_JSON_RULE) {
279  SCJbSetString(js, "rule", pa->s->sig_str);
280  }
281  if (xff_buffer && xff_buffer[0]) {
282  SCJbSetString(js, "xff", xff_buffer);
283  }
284 
285  SCJbClose(js);
286 }
287 
288 static void AlertJsonTunnel(const Packet *p, SCJsonBuilder *js, OutputJsonCommonSettings *cfg)
289 {
290  if (p->root == NULL) {
291  return;
292  }
293 
294  SCJbOpenObject(js, "tunnel");
295 
296  enum PktSrcEnum pkt_src;
298  JsonAddrInfoInit(p->root, 0, &addr, cfg);
299  pkt_src = p->root->pkt_src;
300 
301  SCJbSetString(js, "src_ip", addr.src_ip);
302  SCJbSetUint(js, "src_port", addr.sp);
303  SCJbSetString(js, "dest_ip", addr.dst_ip);
304  SCJbSetUint(js, "dest_port", addr.dp);
305  SCJbSetString(js, "proto", addr.proto);
306 
307  if (p->tunnel_id > 0 && p->tunnel_id != PKT_TUNNEL_UNKNOWN) {
308  SCJbSetUint(js, "tunnel_id", p->tunnel_id);
309  }
310  SCJbSetUint(js, "depth", p->recursion_level);
311  uint64_t pcap_cnt = PcapPacketCntGet(p->root);
312  if (pcap_cnt != 0) {
313  SCJbSetUint(js, "pcap_cnt", pcap_cnt);
314  }
315  SCJbSetString(js, "pkt_src", PktSrcToString(pkt_src));
316  SCJbClose(js);
317 }
318 
319 static void AlertAddPayload(AlertJsonOutputCtx *json_output_ctx, SCJsonBuilder *js, const Packet *p)
320 {
321  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_BASE64) {
322  SCJbSetBase64(js, "payload", p->payload, p->payload_len);
323  }
324  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_LENGTH) {
325  SCJbSetUint(js, "payload_length", p->payload_len);
326  }
327 
328  if (json_output_ctx->flags & LOG_JSON_PAYLOAD) {
329  SCJbSetPrintAsciiString(js, "payload_printable", p->payload, p->payload_len);
330  }
331 }
332 
333 static void AlertAddAppLayerStates(const Packet *p, const AppProto alproto, const uint8_t sub_state,
334  void *tx, SCJsonBuilder *jb)
335 {
336  const int ts = AppLayerParserGetStateProgress(p->flow->proto, alproto, tx, STREAM_TOSERVER);
337  const int tc = AppLayerParserGetStateProgress(p->flow->proto, alproto, tx, STREAM_TOCLIENT);
338  if (sub_state == 0) {
339  SCJbSetString(jb, "ts_progress",
340  AppLayerParserGetStateNameById(p->flow->proto, alproto, ts, STREAM_TOSERVER));
341  SCJbSetString(jb, "tc_progress",
342  AppLayerParserGetStateNameById(p->flow->proto, alproto, tc, STREAM_TOCLIENT));
343  } else {
344  const char *sname = AppLayerParserGetSubStateName(alproto, sub_state);
345  if (sname != NULL) {
346  SCJbSetString(jb, "sub_state", sname);
347  }
348  SCJbSetString(jb, "ts_progress",
350  alproto, sub_state, (uint8_t)ts, STREAM_TOSERVER));
351  SCJbSetString(jb, "tc_progress",
353  alproto, sub_state, (uint8_t)tc, STREAM_TOCLIENT));
354  }
355 }
356 
357 static void AlertAddAppLayer(const Packet *p, SCJsonBuilder *jb, const uint64_t tx_id,
358  const uint8_t sub_state, const uint16_t option_flags)
359 {
362  void *state = FlowGetAppState(p->flow);
363  void *tx = NULL;
364  if (state) {
365  tx = AppLayerParserGetTx(p->flow->proto, proto, state, tx_id);
366  }
367  if (tx == NULL)
368  return;
369 
370  AlertAddAppLayerStates(p, proto, sub_state, tx, jb);
371 
372  SCJsonBuilderMark mark = { 0, 0, 0 };
373  if (al && al->LogTx) {
374  SCJbGetMark(jb, &mark);
375  switch (proto) {
376  // first check some protocols need special options for alerts logging
377  case ALPROTO_WEBSOCKET:
378  if (option_flags &
380  const bool pp = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD) != 0;
381  const bool pb64 = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD_BASE64) != 0;
382  if (!SCWebSocketLogDetails(tx, jb, pp, pb64)) {
383  SCJbRestoreMark(jb, &mark);
384  }
385  // nothing more to log or do
386  return;
387  }
388  }
389  if (!al->LogTx(tx, jb)) {
390  SCJbRestoreMark(jb, &mark);
391  }
392  return;
393  }
394 
395  switch (proto) {
396  case ALPROTO_HTTP1:
397  // TODO: Could result in an empty http object being logged.
398  SCJbOpenObject(jb, "http");
399  if (EveHttpAddMetadata(p->flow, tx_id, jb)) {
400  if (option_flags & LOG_JSON_HTTP_BODY) {
401  EveHttpLogJSONBodyPrintable(jb, p->flow, tx_id);
402  }
403  if (option_flags & LOG_JSON_HTTP_BODY_BASE64) {
404  EveHttpLogJSONBodyBase64(jb, p->flow, tx_id);
405  }
406  }
407  SCJbClose(jb);
408  break;
409  case ALPROTO_SMTP:
410  SCJbGetMark(jb, &mark);
411  SCJbOpenObject(jb, "smtp");
412  if (EveSMTPAddMetadata(p->flow, tx_id, jb)) {
413  SCJbClose(jb);
414  } else {
415  SCJbRestoreMark(jb, &mark);
416  }
417  SCJbGetMark(jb, &mark);
418  SCJbOpenObject(jb, "email");
419  if (EveEmailAddMetadata(p->flow, tx_id, jb)) {
420  SCJbClose(jb);
421  } else {
422  SCJbRestoreMark(jb, &mark);
423  }
424  break;
425  case ALPROTO_NFS:
426  /* rpc */
427  SCJbGetMark(jb, &mark);
428  SCJbOpenObject(jb, "rpc");
429  if (EveNFSAddMetadataRPC(p->flow, tx_id, jb)) {
430  SCJbClose(jb);
431  } else {
432  SCJbRestoreMark(jb, &mark);
433  }
434  /* nfs */
435  SCJbGetMark(jb, &mark);
436  SCJbOpenObject(jb, "nfs");
437  if (EveNFSAddMetadata(p->flow, tx_id, jb)) {
438  SCJbClose(jb);
439  } else {
440  SCJbRestoreMark(jb, &mark);
441  }
442  break;
443  case ALPROTO_SMB:
444  SCJbGetMark(jb, &mark);
445  SCJbOpenObject(jb, "smb");
446  if (EveSMBAddMetadata(p->flow, tx_id, jb)) {
447  SCJbClose(jb);
448  } else {
449  SCJbRestoreMark(jb, &mark);
450  }
451  break;
452  case ALPROTO_IKE:
453  SCJbGetMark(jb, &mark);
454  if (!EveIKEAddMetadata(p->flow, tx_id, jb)) {
455  SCJbRestoreMark(jb, &mark);
456  }
457  break;
458  case ALPROTO_DCERPC:
459  SCJbGetMark(jb, &mark);
460  SCJbOpenObject(jb, "dcerpc");
461  if (p->proto == IPPROTO_TCP) {
462  if (!SCDcerpcLogJsonRecordTcp(state, tx, jb)) {
463  SCJbRestoreMark(jb, &mark);
464  }
465  } else {
466  if (!SCDcerpcLogJsonRecordUdp(state, tx, jb)) {
467  SCJbRestoreMark(jb, &mark);
468  }
469  }
470  SCJbClose(jb);
471  break;
472  default:
473  break;
474  }
475 }
476 
477 static void AlertAddFiles(const Packet *p, SCJsonBuilder *jb, const uint64_t tx_id)
478 {
479  const uint8_t direction =
480  (p->flowflags & FLOW_PKT_TOSERVER) ? STREAM_TOSERVER : STREAM_TOCLIENT;
481  FileContainer *ffc = NULL;
482  if (p->flow->alstate != NULL) {
483  void *tx = AppLayerParserGetTx(p->flow->proto, p->flow->alproto, p->flow->alstate, tx_id);
484  if (tx) {
485  AppLayerGetFileState files = AppLayerParserGetTxFiles(p->flow, tx, direction);
486  ffc = files.fc;
487  }
488  }
489  if (ffc != NULL) {
490  File *file = ffc->head;
491  bool isopen = false;
492  while (file) {
493  if (!isopen) {
494  isopen = true;
495  SCJbOpenArray(jb, "files");
496  }
497  SCJbStartObject(jb);
498  EveFileInfo(jb, file, tx_id, file->flags);
499  SCJbClose(jb);
500  file = file->next;
501  }
502  if (isopen) {
503  SCJbClose(jb);
504  }
505  }
506 }
507 
508 static void AlertAddFrame(
509  const Packet *p, const int64_t frame_id, SCJsonBuilder *jb, MemBuffer *buffer)
510 {
511  if (p->flow == NULL || (p->proto == IPPROTO_TCP && p->flow->protoctx == NULL))
512  return;
513 
514  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
515  if (frames_container == NULL)
516  return;
517 
518  Frames *frames = NULL;
519  TcpStream *stream = NULL;
520  if (p->proto == IPPROTO_TCP) {
522  if (PKT_IS_TOSERVER(p)) {
523  stream = &ssn->client;
524  frames = &frames_container->toserver;
525  } else {
526  stream = &ssn->server;
527  frames = &frames_container->toclient;
528  }
529  Frame *frame = FrameGetById(frames, frame_id);
530  if (frame != NULL) {
531  FrameJsonLogOneFrame(IPPROTO_TCP, frame, p->flow, stream, p, jb, buffer);
532  }
533  } else if (p->proto == IPPROTO_UDP) {
534  if (PKT_IS_TOSERVER(p)) {
535  frames = &frames_container->toserver;
536  } else {
537  frames = &frames_container->toclient;
538  }
539  Frame *frame = FrameGetById(frames, frame_id);
540  if (frame != NULL) {
541  FrameJsonLogOneFrame(IPPROTO_UDP, frame, p->flow, NULL, p, jb, buffer);
542  }
543  }
544 }
545 
546 /**
547  * \brief Build verdict object
548  *
549  * \param p Pointer to Packet current being logged
550  * \param alert_action action bitfield from the alert: only used for ACTION_PASS
551  */
552 void EveAddVerdict(SCJsonBuilder *jb, const Packet *p, const uint8_t alert_action)
553 {
554  SCJbOpenObject(jb, "verdict");
555 
556  const uint8_t packet_action = PacketGetAction(p);
557  SCLogDebug("%" PRIu64 ": packet_action %02x alert_action %02x", PcapPacketCntGet(p),
558  packet_action, alert_action);
559  /* add verdict info */
560  if (packet_action & ACTION_REJECT_ANY) {
561  // check rule to define type of reject packet sent
562  if (EngineModeIsIPS()) {
563  JB_SET_STRING(jb, "action", "drop");
564  } else {
565  JB_SET_STRING(jb, "action", "alert");
566  }
567  if (packet_action & ACTION_REJECT) {
568  JB_SET_STRING(jb, "reject_target", "to_client");
569  } else if (packet_action & ACTION_REJECT_DST) {
570  JB_SET_STRING(jb, "reject_target", "to_server");
571  } else if (packet_action & ACTION_REJECT_BOTH) {
572  JB_SET_STRING(jb, "reject_target", "both");
573  }
574  SCJbOpenArray(jb, "reject");
575  switch (p->proto) {
576  case IPPROTO_UDP:
577  case IPPROTO_ICMP:
578  case IPPROTO_ICMPV6:
579  SCJbAppendString(jb, "icmp-prohib");
580  break;
581  case IPPROTO_TCP:
582  SCJbAppendString(jb, "tcp-reset");
583  break;
584  }
585  SCJbClose(jb);
586 
587  } else if ((packet_action & ACTION_DROP) && EngineModeIsIPS()) {
588  JB_SET_STRING(jb, "action", "drop");
589  } else if (packet_action & ACTION_ACCEPT) {
590  JB_SET_STRING(jb, "action", "accept");
591  } else if (alert_action & ACTION_PASS) {
592  JB_SET_STRING(jb, "action", "pass");
593  } else {
594  // TODO make sure we don't have a situation where this wouldn't work
595  JB_SET_STRING(jb, "action", "alert");
596  }
597 
598  /* Close verdict */
599  SCJbClose(jb);
600 }
601 
604  uint64_t last_re;
605 };
606 
607 static int AlertJsonStreamDataCallback(
608  void *cb_data, const uint8_t *input, const uint32_t input_len, const uint64_t input_offset)
609 {
610  struct AlertJsonStreamDataCallbackData *cbd = cb_data;
611  if (input_offset > cbd->last_re) {
613  cbd->payload, "[%" PRIu64 " bytes missing]", input_offset - cbd->last_re);
614  }
615 
616  int done = 0;
617  uint32_t written = MemBufferWriteRaw(cbd->payload, input, input_len);
618  if (written < input_len)
619  done = 1;
620  cbd->last_re = input_offset + input_len;
621  return done;
622 }
623 
624 /** \internal
625  * \brief try to log stream data into payload/payload_printable
626  * \retval true stream data logged
627  * \retval false stream data not logged
628  */
629 static bool AlertJsonStreamData(const AlertJsonOutputCtx *json_output_ctx, JsonAlertLogThread *aft,
630  Flow *f, const Packet *p, SCJsonBuilder *jb)
631 {
632  TcpSession *ssn = f->protoctx;
633  TcpStream *stream = (PKT_IS_TOSERVER(p)) ? &ssn->client : &ssn->server;
634 
635  MemBufferReset(aft->payload_buffer);
637  .last_re = STREAM_BASE_OFFSET(stream) };
638  uint64_t unused = 0;
639  StreamReassembleLog(ssn, stream, AlertJsonStreamDataCallback, &cbd, STREAM_BASE_OFFSET(stream),
640  &unused, false);
641  if (cbd.payload->offset) {
642  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_BASE64) {
643  SCJbSetBase64(jb, "payload", cbd.payload->buffer, cbd.payload->offset);
644  }
645  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_LENGTH) {
646  SCJbSetUint(jb, "payload_length", cbd.payload->offset);
647  }
648 
649  if (json_output_ctx->flags & LOG_JSON_PAYLOAD) {
650  SCJbSetPrintAsciiString(
651  jb, "payload_printable", cbd.payload->buffer, cbd.payload->offset);
652  }
653  return true;
654  }
655  return false;
656 }
657 
658 static void AlertJsonAddFirewall(SCJsonBuilder *jb, const Signature *s)
659 {
660  struct DetectFirewallPolicy pol = { .action = s->action, .action_scope = s->action_scope };
661 
662  SCJbOpenObject(jb, "firewall");
663  const char *hook = NULL;
664  char hook_string[256];
665  switch (s->detect_table) {
667  const uint8_t dir_flag =
668  (s->flags & SIG_FLAG_TOSERVER) ? STREAM_TOSERVER : STREAM_TOCLIENT;
670  /* sub state rules (http2 stream/global): resolve the state in
671  * the sub state table and keep the sub state in the name */
672  const char *state = AppLayerParserGetSubStateProgressName(
673  s->alproto, s->sub_state, s->app_progress_hook, dir_flag);
674  const char *sub_state_name =
676  if (state != NULL && sub_state_name != NULL) {
677  snprintf(hook_string, sizeof(hook_string), "%s:%s:%s",
678  AppProtoToString(s->alproto), sub_state_name, state);
679  hook = hook_string;
680  }
681  }
682  if (hook == NULL) {
683  /* no sub state, or the sub state lookup failed: fall back to
684  * the plain per-protocol state name */
686  IPPROTO_TCP, s->alproto, s->app_progress_hook, dir_flag);
687  if (hook != NULL) {
688  snprintf(hook_string, sizeof(hook_string), "%s:%s",
689  AppProtoToString(s->alproto), hook);
690  hook = hook_string;
691  }
692  }
693  break;
694  }
696  hook = "packet:filter";
697  break;
699  hook = "packet:pre_flow";
700  break;
702  hook = "packet:pre_stream";
703  break;
704  }
705  if (hook) {
706  SCJbSetString(jb, "hook", hook);
707  }
708  char policy_string[64] = "";
709  DetectFirewallPolicyToString(&pol, policy_string, sizeof(policy_string));
710  if (strlen(policy_string) > 0) {
711  SCJbSetString(jb, "policy", policy_string);
712  }
713  SCJbClose(jb);
714 }
715 
716 static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
717 {
718  AlertJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
719 
720  if (p->alerts.cnt == 0 && !(p->flags & PKT_HAS_TAG))
721  return TM_ECODE_OK;
722 
723  const uint8_t final_action = p->alerts.cnt > 0 ? p->alerts.alerts[p->alerts.cnt - 1].action : 0;
724  for (int i = 0; i < p->alerts.cnt; i++) {
725  const PacketAlert *pa = &p->alerts.alerts[i];
726  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
727  continue;
728  }
729 
730  /* First initialize the address info (5-tuple). */
732  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr, &json_output_ctx->eve_ctx->cfg);
733 
734  /* Check for XFF, overwriting address info if needed. */
735  HttpXFFCfg *xff_cfg = json_output_ctx->xff_cfg != NULL ? json_output_ctx->xff_cfg
736  : json_output_ctx->parent_xff_cfg;
737  int have_xff_ip = 0;
738  char xff_buffer[XFF_MAXLEN];
739  xff_buffer[0] = 0;
740  if ((xff_cfg != NULL) && !(xff_cfg->flags & XFF_DISABLED) && p->flow != NULL) {
742  if (pa->flags & PACKET_ALERT_FLAG_TX) {
743  have_xff_ip = HttpXFFGetIPFromTx(p->flow, pa->tx_id, xff_cfg,
744  xff_buffer, XFF_MAXLEN);
745  } else {
746  have_xff_ip = HttpXFFGetIP(p->flow, xff_cfg, xff_buffer,
747  XFF_MAXLEN);
748  }
749  }
750 
751  if (have_xff_ip && xff_cfg->flags & XFF_OVERWRITE) {
752  if (p->flowflags & FLOW_PKT_TOCLIENT) {
753  strlcpy(addr.dst_ip, xff_buffer, JSON_ADDR_LEN);
754  } else {
755  strlcpy(addr.src_ip, xff_buffer, JSON_ADDR_LEN);
756  }
757  /* Clear have_xff_ip so the xff field does not get
758  * logged below. */
759  have_xff_ip = false;
760  }
761  if (have_xff_ip && !(xff_cfg->flags & XFF_EXTRADATA)) {
762  // reset xff_buffer so as not to log it
763  xff_buffer[0] = 0;
764  }
765  }
766 
767  SCJsonBuilder *jb =
768  CreateEveHeader(p, LOG_DIR_PACKET, "alert", &addr, json_output_ctx->eve_ctx);
769  if (unlikely(jb == NULL))
770  return TM_ECODE_OK;
771 
772 
773  /* alert */
774  AlertJsonHeader(p, pa, jb, json_output_ctx->flags, &addr, xff_buffer);
775 
776  if (PacketIsTunnel(p)) {
777  AlertJsonTunnel(p, jb, &json_output_ctx->eve_ctx->cfg);
778  }
779 
780  if (pa->s->flags & SIG_FLAG_FIREWALL) {
781  AlertJsonAddFirewall(jb, pa->s);
782  }
783 
784  if (p->flow != NULL) {
785  if (pa->flags & PACKET_ALERT_FLAG_TX) {
786  if (json_output_ctx->flags & LOG_JSON_APP_LAYER) {
787  AlertAddAppLayer(p, jb, pa->tx_id, pa->sub_state, json_output_ctx->flags);
788  }
789  /* including fileinfo data is configured by the metadata setting */
790  if (json_output_ctx->flags & LOG_JSON_RULE_METADATA) {
791  AlertAddFiles(p, jb, pa->tx_id);
792  }
793  }
794 
795  EveAddAppProto(p->flow, jb);
796 
797  if (p->flowflags & FLOW_PKT_TOSERVER) {
798  SCJbSetString(jb, "direction", "to_server");
799  } else {
800  SCJbSetString(jb, "direction", "to_client");
801  }
802 
803  if (json_output_ctx->flags & LOG_JSON_FLOW) {
804  SCJbOpenObject(jb, "flow");
805  EveAddFlow(p->flow, jb);
806  if (p->flowflags & FLOW_PKT_TOCLIENT) {
807  SCJbSetString(jb, "src_ip", addr.dst_ip);
808  SCJbSetString(jb, "dest_ip", addr.src_ip);
809  if (addr.sp > 0) {
810  SCJbSetUint(jb, "src_port", addr.dp);
811  SCJbSetUint(jb, "dest_port", addr.sp);
812  }
813  } else {
814  SCJbSetString(jb, "src_ip", addr.src_ip);
815  SCJbSetString(jb, "dest_ip", addr.dst_ip);
816  if (addr.sp > 0) {
817  SCJbSetUint(jb, "src_port", addr.sp);
818  SCJbSetUint(jb, "dest_port", addr.dp);
819  }
820  }
821  SCJbClose(jb);
822  }
823  }
824 
825  /* payload */
826  if (json_output_ctx->flags &
828  int stream = (p->proto == IPPROTO_TCP) ?
830  1 : 0) : 0;
831  // should be impossible, as stream implies flow
832  DEBUG_VALIDATE_BUG_ON(stream && p->flow == NULL);
833 
834  /* Is this a stream? If so, pack part of it into the payload field */
835  if (stream && p->flow != NULL) {
836  const bool stream_data_logged =
837  AlertJsonStreamData(json_output_ctx, aft, p->flow, p, jb);
838  if (!stream_data_logged && p->payload_len) {
839  /* Fallback on packet payload */
840  AlertAddPayload(json_output_ctx, jb, p);
841  }
842  } else {
843  /* This is a single packet and not a stream */
844  AlertAddPayload(json_output_ctx, jb, p);
845  }
846 
847  SCJbSetUint(jb, "stream", stream);
848  }
849 
850  if (pa->flags & PACKET_ALERT_FLAG_FRAME) {
851  AlertAddFrame(p, pa->frame_id, jb, aft->payload_buffer);
852  }
853 
854  /* base64-encoded full packet */
855  if (json_output_ctx->flags & LOG_JSON_PACKET) {
856  EvePacket(p, jb, 0);
857  }
858 
860  if (pcap_filename != NULL) {
861  SCJbSetString(jb, "capture_file", pcap_filename);
862  }
863 
864  if (json_output_ctx->flags & LOG_JSON_VERDICT) {
865  EveAddVerdict(jb, p, final_action & ACTION_PASS);
866  }
867 
868  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
869  SCJbFree(jb);
870  }
871 
872  if ((p->flags & PKT_HAS_TAG) && (json_output_ctx->flags &
874  SCJsonBuilder *packetjs =
875  CreateEveHeader(p, LOG_DIR_PACKET, "packet", NULL, json_output_ctx->eve_ctx);
876  if (unlikely(packetjs != NULL)) {
877  EvePacket(p, packetjs, 0);
878  OutputJsonBuilderBuffer(tv, p, p->flow, packetjs, aft->ctx);
879  SCJbFree(packetjs);
880  }
881  }
882 
883  return TM_ECODE_OK;
884 }
885 
886 static int AlertJsonDecoderEvent(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
887 {
888  AlertJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
889 
890  if (p->alerts.cnt == 0)
891  return TM_ECODE_OK;
892 
893  const uint8_t final_action = p->alerts.alerts[p->alerts.cnt - 1].action;
894  for (int i = 0; i < p->alerts.cnt; i++) {
895  const PacketAlert *pa = &p->alerts.alerts[i];
896  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
897  continue;
898  }
899 
900  SCJsonBuilder *jb =
901  CreateEveHeader(p, LOG_DIR_PACKET, "alert", NULL, json_output_ctx->eve_ctx);
902  if (unlikely(jb == NULL))
903  return TM_ECODE_OK;
904 
905  AlertJsonHeader(p, pa, jb, json_output_ctx->flags, NULL, NULL);
906 
907  if (PacketIsTunnel(p)) {
908  AlertJsonTunnel(p, jb, &json_output_ctx->eve_ctx->cfg);
909  }
910 
911  /* base64-encoded full packet */
912  if (json_output_ctx->flags & LOG_JSON_PACKET) {
913  EvePacket(p, jb, 0);
914  }
915 
917  if (pcap_filename != NULL) {
918  SCJbSetString(jb, "capture_file", pcap_filename);
919  }
920 
921  if (json_output_ctx->flags & LOG_JSON_VERDICT) {
922  EveAddVerdict(jb, p, final_action & ACTION_PASS);
923  }
924 
925  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
926  SCJbFree(jb);
927  }
928 
929  return TM_ECODE_OK;
930 }
931 
932 static int JsonAlertLogger(ThreadVars *tv, void *thread_data, const Packet *p)
933 {
934  JsonAlertLogThread *aft = thread_data;
935 
936  if (PacketIsIPv4(p) || PacketIsIPv6(p)) {
937  return AlertJson(tv, aft, p);
938  } else if (p->alerts.cnt > 0) {
939  return AlertJsonDecoderEvent(tv, aft, p);
940  }
941  return 0;
942 }
943 
944 static bool JsonAlertLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
945 {
946  return (p->alerts.cnt || (p->flags & PKT_HAS_TAG));
947 }
948 
949 static TmEcode JsonAlertLogThreadInit(ThreadVars *t, const void *initdata, void **data)
950 {
952  if (unlikely(aft == NULL))
953  return TM_ECODE_FAILED;
954 
955  if (initdata == NULL)
956  {
957  SCLogDebug("Error getting context for EveLogAlert. \"initdata\" argument NULL");
958  goto error_exit;
959  }
960 
961  /** Use the Output Context (file pointer and mutex) */
962  AlertJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
963 
964  aft->payload_buffer = MemBufferCreateNew(json_output_ctx->payload_buffer_size);
965  if (aft->payload_buffer == NULL) {
966  goto error_exit;
967  }
968  aft->ctx = CreateEveThreadCtx(t, json_output_ctx->eve_ctx);
969  if (!aft->ctx) {
970  goto error_exit;
971  }
972 
973  aft->json_output_ctx = json_output_ctx;
974 
975  *data = (void *)aft;
976  return TM_ECODE_OK;
977 
978 error_exit:
979  if (aft->payload_buffer != NULL) {
981  }
982  SCFree(aft);
983  return TM_ECODE_FAILED;
984 }
985 
986 static TmEcode JsonAlertLogThreadDeinit(ThreadVars *t, void *data)
987 {
988  JsonAlertLogThread *aft = (JsonAlertLogThread *)data;
989  if (aft == NULL) {
990  return TM_ECODE_OK;
991  }
992 
994  FreeEveThreadCtx(aft->ctx);
995 
996  /* clear memory */
997  memset(aft, 0, sizeof(JsonAlertLogThread));
998 
999  SCFree(aft);
1000  return TM_ECODE_OK;
1001 }
1002 
1003 static void JsonAlertLogDeInitCtxSub(OutputCtx *output_ctx)
1004 {
1005  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
1006 
1007  AlertJsonOutputCtx *json_output_ctx = (AlertJsonOutputCtx *) output_ctx->data;
1008 
1009  if (json_output_ctx != NULL) {
1010  HttpXFFCfg *xff_cfg = json_output_ctx->xff_cfg;
1011  if (xff_cfg != NULL) {
1012  SCFree(xff_cfg);
1013  }
1014  SCFree(json_output_ctx);
1015  }
1016  SCFree(output_ctx);
1017 }
1018 
1019 static void SetFlag(const SCConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
1020 {
1021  DEBUG_VALIDATE_BUG_ON(conf == NULL);
1022  const char *setting = SCConfNodeLookupChildValue(conf, name);
1023  if (setting != NULL) {
1024  if (SCConfValIsTrue(setting)) {
1025  *out_flags |= flag;
1026  } else {
1027  *out_flags &= ~flag;
1028  }
1029  }
1030 }
1031 
1032 static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, SCConfNode *conf)
1033 {
1034  static bool warn_no_meta = false;
1035  uint32_t payload_buffer_size = JSON_STREAM_BUFFER_SIZE;
1036  uint16_t flags = METADATA_DEFAULTS;
1037 
1038  if (conf != NULL) {
1039  /* Check for metadata to enable/disable. */
1040  SCConfNode *metadata = SCConfNodeLookupChild(conf, "metadata");
1041  if (metadata != NULL) {
1042  if (metadata->val != NULL && SCConfValIsFalse(metadata->val)) {
1044  } else if (SCConfNodeHasChildren(metadata)) {
1045  SCConfNode *rule_metadata = SCConfNodeLookupChild(metadata, "rule");
1046  if (rule_metadata) {
1047  SetFlag(rule_metadata, "raw", LOG_JSON_RULE, &flags);
1048  SetFlag(rule_metadata, "metadata", LOG_JSON_RULE_METADATA,
1049  &flags);
1050  SetFlag(rule_metadata, "reference", LOG_JSON_REFERENCE, &flags);
1051  }
1052  SetFlag(metadata, "flow", LOG_JSON_FLOW, &flags);
1053  SetFlag(metadata, "app-layer", LOG_JSON_APP_LAYER, &flags);
1054  }
1055  }
1056 
1057  /* Non-metadata toggles. */
1058  SetFlag(conf, "payload", LOG_JSON_PAYLOAD_BASE64, &flags);
1059  SetFlag(conf, "packet", LOG_JSON_PACKET, &flags);
1060  SetFlag(conf, "tagged-packets", LOG_JSON_TAGGED_PACKETS, &flags);
1061  SetFlag(conf, "payload-printable", LOG_JSON_PAYLOAD, &flags);
1062  SetFlag(conf, "http-body-printable", LOG_JSON_HTTP_BODY, &flags);
1063  SetFlag(conf, "http-body", LOG_JSON_HTTP_BODY_BASE64, &flags);
1064  SetFlag(conf, "websocket-payload-printable", LOG_JSON_WEBSOCKET_PAYLOAD, &flags);
1065  SetFlag(conf, "websocket-payload", LOG_JSON_WEBSOCKET_PAYLOAD_BASE64, &flags);
1066  SetFlag(conf, "verdict", LOG_JSON_VERDICT, &flags);
1067  SetFlag(conf, "payload-length", LOG_JSON_PAYLOAD_LENGTH, &flags);
1068 
1069  /* Check for obsolete flags and warn that they have no effect. */
1070  static const char *deprecated_flags[] = { "http", "tls", "ssh", "smtp", "dnp3", "app-layer",
1071  "flow", NULL };
1072  for (int i = 0; deprecated_flags[i] != NULL; i++) {
1073  if (SCConfNodeLookupChildValue(conf, deprecated_flags[i]) != NULL) {
1074  SCLogWarning("Found deprecated eve-log.alert flag \"%s\", this flag has no effect",
1075  deprecated_flags[i]);
1076  }
1077  }
1078 
1079  const char *payload_buffer_value = SCConfNodeLookupChildValue(conf, "payload-buffer-size");
1080 
1081  if (payload_buffer_value != NULL) {
1082  uint32_t value;
1083  if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
1084  SCLogError("Error parsing "
1085  "payload-buffer-size - %s. Killing engine",
1086  payload_buffer_value);
1087  exit(EXIT_FAILURE);
1088  } else if (value == 0) {
1089  // you should not ask for payload if you want 0 of it
1090  SCLogError("Error payload-buffer-size should not be 0");
1091  exit(EXIT_FAILURE);
1092  } else {
1093  payload_buffer_size = value;
1094  }
1095  }
1096 
1097  if (!warn_no_meta && flags & JSON_BODY_LOGGING) {
1098  if (((flags & LOG_JSON_APP_LAYER) == 0)) {
1099  SCLogWarning("HTTP body logging has been configured, however, "
1100  "metadata logging has not been enabled. HTTP body logging will be "
1101  "disabled.");
1103  warn_no_meta = true;
1104  }
1105  }
1106  }
1107 
1108  if (flags & LOG_JSON_RULE_METADATA) {
1110  }
1111 
1112  json_output_ctx->payload_buffer_size = payload_buffer_size;
1113  json_output_ctx->flags |= flags;
1114 }
1115 
1116 static HttpXFFCfg *JsonAlertLogGetXffCfg(SCConfNode *conf)
1117 {
1118  HttpXFFCfg *xff_cfg = NULL;
1119  if (conf != NULL && SCConfNodeLookupChild(conf, "xff") != NULL) {
1120  xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
1121  if (likely(xff_cfg != NULL)) {
1122  HttpXFFGetCfg(conf, xff_cfg);
1123  }
1124  }
1125  return xff_cfg;
1126 }
1127 
1128 /**
1129  * \brief Create a new LogFileCtx for "fast" output style.
1130  * \param conf The configuration node for this output.
1131  * \return A LogFileCtx pointer on success, NULL on failure.
1132  */
1133 static OutputInitResult JsonAlertLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
1134 {
1135  OutputInitResult result = { NULL, false };
1136  OutputJsonCtx *ajt = parent_ctx->data;
1137  AlertJsonOutputCtx *json_output_ctx = NULL;
1138 
1139  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
1140  if (unlikely(output_ctx == NULL))
1141  return result;
1142 
1143  json_output_ctx = SCCalloc(1, sizeof(AlertJsonOutputCtx));
1144  if (unlikely(json_output_ctx == NULL)) {
1145  goto error;
1146  }
1147 
1148  json_output_ctx->file_ctx = ajt->file_ctx;
1149  json_output_ctx->eve_ctx = ajt;
1150 
1151  JsonAlertLogSetupMetadata(json_output_ctx, conf);
1152  json_output_ctx->xff_cfg = JsonAlertLogGetXffCfg(conf);
1153  if (json_output_ctx->xff_cfg == NULL) {
1154  json_output_ctx->parent_xff_cfg = ajt->xff_cfg;
1155  }
1156 
1157  output_ctx->data = json_output_ctx;
1158  output_ctx->DeInit = JsonAlertLogDeInitCtxSub;
1159 
1160  result.ctx = output_ctx;
1161  result.ok = true;
1162  return result;
1163 
1164 error:
1165  if (json_output_ctx != NULL) {
1166  SCFree(json_output_ctx);
1167  }
1168  if (output_ctx != NULL) {
1169  SCFree(output_ctx);
1170  }
1171 
1172  return result;
1173 }
1174 
1176 {
1177  OutputPacketLoggerFunctions output_logger_functions = {
1178  .LogFunc = JsonAlertLogger,
1179  .ConditionFunc = JsonAlertLogCondition,
1180  .ThreadInitFunc = JsonAlertLogThreadInit,
1181  .ThreadDeinitFunc = JsonAlertLogThreadDeinit,
1182  .ThreadExitPrintStatsFunc = NULL,
1183  };
1184 
1185  OutputRegisterPacketSubModule(LOGGER_JSON_ALERT, "eve-log", MODULE_NAME, "eve-log.alert",
1186  JsonAlertLogInitCtxSub, &output_logger_functions);
1187 }
SCJsonBuilder
struct SCJsonBuilder SCJsonBuilder
Definition: detect-engine-helper.h:87
XFF_MAXLEN
#define XFF_MAXLEN
Definition: app-layer-htp-xff.h:39
PacketCheckAction
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition: packet.c:51
PACKET_ALERT_FLAG_TX_GUESSED
#define PACKET_ALERT_FLAG_TX_GUESSED
Definition: decode.h:297
Packet_::proto
uint8_t proto
Definition: decode.h:550
TcpStream_
Definition: stream-tcp-private.h:106
FileContainer_
Definition: util-file.h:37
ts
uint64_t ts
Definition: source-erf-file.c:68
DetectMetadataHead::json_str
char * json_str
Definition: detect-metadata.h:40
SCConfValIsTrue
int SCConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:577
detect-engine.h
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:271
ALPROTO_IKE
@ ALPROTO_IKE
Definition: app-layer-protos.h:55
OutputJsonCtx_::xff_cfg
HttpXFFCfg * xff_cfg
Definition: output-json.h:81
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
Signature_::sig_str
char * sig_str
Definition: detect.h:744
ALPROTO_DCERPC
@ ALPROTO_DCERPC
Definition: app-layer-protos.h:44
AppLayerParserGetStateNameById
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
Definition: app-layer-parser.c:1847
DETECT_TABLE_APP_FILTER
@ DETECT_TABLE_APP_FILTER
Definition: detect.h:541
XFF_EXTRADATA
#define XFF_EXTRADATA
Definition: app-layer-htp-xff.h:31
EveAddFlow
void EveAddFlow(Flow *f, SCJsonBuilder *js)
Definition: output-json-flow.c:204
stream-tcp.h
OutputJsonCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json.h:80
HttpXFFGetCfg
void HttpXFFGetCfg(SCConfNode *conf, HttpXFFCfg *result)
Function to return XFF configuration from a configuration node.
Definition: app-layer-htp-xff.c:116
PACKET_ALERT_FLAG_STATE_MATCH
#define PACKET_ALERT_FLAG_STATE_MATCH
Definition: decode.h:287
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
EveHttpLogJSONBodyPrintable
void EveHttpLogJSONBodyPrintable(SCJsonBuilder *js, Flow *f, uint64_t tx_id)
Definition: output-json-http.c:382
ACTION_PASS
#define ACTION_PASS
Definition: action-globals.h:34
ACTION_REJECT
#define ACTION_REJECT
Definition: action-globals.h:31
Signature_::app_progress_hook
uint8_t app_progress_hook
Definition: detect.h:700
AppLayerFramesGetContainer
FramesContainer * AppLayerFramesGetContainer(const Flow *f)
Definition: app-layer-parser.c:209
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1244
LOG_JSON_RULE
#define LOG_JSON_RULE
Definition: output-json-alert.c:81
Signature_::alproto
AppProto alproto
Definition: detect.h:668
DETECT_TABLE_PACKET_PRE_STREAM
@ DETECT_TABLE_PACKET_PRE_STREAM
Definition: detect.h:538
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
AlertJsonOutputCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-alert.c:99
name
const char * name
Definition: detect-engine-proto.c:47
AlertJsonOutputCtx_::parent_xff_cfg
HttpXFFCfg * parent_xff_cfg
Definition: output-json-alert.c:103
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
Flow_::proto
uint8_t proto
Definition: flow.h:382
EveAddAppProto
void EveAddAppProto(Flow *f, SCJsonBuilder *js)
Definition: output-json-flow.c:184
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:87
AlertJsonStreamDataCallbackData::last_re
uint64_t last_re
Definition: output-json-alert.c:604
Packet_::payload
uint8_t * payload
Definition: decode.h:640
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:306
SIG_FLAG_DEST_IS_TARGET
#define SIG_FLAG_DEST_IS_TARGET
Definition: detect.h:259
SCFlowGetAppProtocol
AppProto SCFlowGetAppProtocol(const Flow *f)
Definition: flow.c:1288
action-globals.h
FramesContainer::toserver
Frames toserver
Definition: app-layer-frames.h:78
Packet_::flags
uint32_t flags
Definition: decode.h:582
CreateEveHeader
SCJsonBuilder * CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
Definition: output-json.c:816
ssn
TcpSession ssn
Definition: fuzz_dataset.c:31
LOGGER_JSON_ALERT
@ LOGGER_JSON_ALERT
Definition: suricata-common.h:501
OutputJsonCtx_
Definition: output-json.h:77
Frame
Definition: app-layer-frames.h:49
Flow_
Flow data structure.
Definition: flow.h:360
OutputJsonCommonSettings_
Definition: output-json.h:62
JsonAddrInfoInit
void JsonAddrInfoInit(const Packet *p, enum SCOutputJsonLogDirection dir, JsonAddrInfo *addr, OutputJsonCommonSettings *cfg)
Definition: output-json.c:464
AppProtoToString
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its normalized string equivalent.
Definition: app-layer-protos.c:53
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-eve.h:49
LogFileCtx_
Definition: util-logopenfile.h:85
output-json-frame.h
AlertJsonHeader
void AlertJsonHeader(const Packet *p, const PacketAlert *pa, SCJsonBuilder *js, uint16_t flags, JsonAddrInfo *addr, char *xff_buffer)
Definition: output-json-alert.c:209
PacketAlerts_::alerts
PacketAlert * alerts
Definition: decode.h:310
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
AlertJsonStreamDataCallbackData::payload
MemBuffer * payload
Definition: output-json-alert.c:603
json_addr_info_zero
const JsonAddrInfo json_addr_info_zero
Definition: output-json.c:78
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:236
rust.h
Frames
Definition: app-layer-frames.h:64
ACTION_REJECT_ANY
#define ACTION_REJECT_ANY
Definition: action-globals.h:38
FramesContainer
Definition: app-layer-frames.h:77
SCConfValIsFalse
int SCConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:602
ACTION_DROP_REJECT
#define ACTION_DROP_REJECT
Definition: action-globals.h:40
p
Packet * p
Definition: fuzz_dataset.c:30
OutputJsonBuilderBuffer
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:1020
proto
uint8_t proto
Definition: decode-template.h:0
SCConfNodeLookupChildValue
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:877
AlertJsonOutputCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-alert.c:104
app-layer-ftp.h
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:564
EngineModeIsFirewall
bool EngineModeIsFirewall(void)
Definition: suricata.c:240
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
Flow_::protoctx
void * protoctx
Definition: flow.h:440
DetectFirewallPolicy::action
uint8_t action
Definition: detect.h:918
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:641
SCConfNodeHasChildren
bool SCConfNodeHasChildren(const SCConfNode *node)
Check if a node has any children.
Definition: conf.c:833
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:657
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
EveHttpAddMetadata
bool EveHttpAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *js)
Definition: output-json-http.c:486
HttpXFFGetIP
int HttpXFFGetIP(const Flow *f, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen)
Function to return XFF IP if any. The caller needs to lock the flow.
Definition: app-layer-htp-xff.c:83
OutputCtx_::data
void * data
Definition: tm-modules.h:91
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
PcapLogGetFilename
char * PcapLogGetFilename(void)
Definition: log-pcap.c:1849
AppLayerParserGetTxFiles
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
Definition: app-layer-parser.c:963
PacketAlert_::tx_id
uint64_t tx_id
Definition: decode.h:272
EveSMBAddMetadata
bool EveSMBAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *jb)
Definition: output-json-smb.c:34
OutputCtx_
Definition: tm-modules.h:88
app-layer-htp-xff.h
PacketAlert_::action
uint8_t action
Definition: decode.h:268
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
JSON_BODY_LOGGING
#define JSON_BODY_LOGGING
Definition: output-json-alert.c:92
SIG_FLAG_FIREWALL
#define SIG_FLAG_FIREWALL
Definition: detect.h:220
OutputJsonThreadCtx_
Definition: output-json.h:85
Signature_::gid
uint32_t gid
Definition: detect.h:713
ACTION_REJECT_DST
#define ACTION_REJECT_DST
Definition: action-globals.h:32
EveIKEAddMetadata
bool EveIKEAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *js)
Definition: output-json-ike.c:64
JsonAddrInfo_::dp
Port dp
Definition: output-json.h:45
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:245
FramesContainer::toclient
Frames toclient
Definition: app-layer-frames.h:79
JsonAlertLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-alert.c:110
PacketAlert_::json_info
struct PacketContextData * json_info
Definition: decode.h:274
EveSMTPAddMetadata
bool EveSMTPAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *js)
Definition: output-json-smtp.c:98
util-debug.h
JB_SET_STRING
#define JB_SET_STRING(jb, key, val)
Definition: rust.h:36
output-json-flow.h
MODULE_NAME
#define MODULE_NAME
Definition: output-json-alert.c:70
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:256
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
LOG_JSON_APP_LAYER
#define LOG_JSON_APP_LAYER
Definition: output-json-alert.c:76
LOG_JSON_WEBSOCKET_PAYLOAD
#define LOG_JSON_WEBSOCKET_PAYLOAD
Definition: output-json-alert.c:83
output-json.h
FrameGetById
Frame * FrameGetById(Frames *frames, const int64_t id)
Definition: app-layer-frames.c:126
DetectReference_::key_len
uint16_t key_len
Definition: detect-reference.h:40
ALPROTO_SMTP
@ ALPROTO_SMTP
Definition: app-layer-protos.h:38
LOG_JSON_PAYLOAD
#define LOG_JSON_PAYLOAD
Definition: output-json-alert.c:72
STREAM_BASE_OFFSET
#define STREAM_BASE_OFFSET(stream)
Definition: stream-tcp-private.h:144
PktSrcEnum
PktSrcEnum
Definition: decode.h:68
util-reference-config.h
AlertJsonOutputCtx_::flags
uint16_t flags
Definition: output-json-alert.c:100
util-print.h
EveNFSAddMetadata
bool EveNFSAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *jb)
Definition: output-json-nfs.c:61
Signature_::references
DetectReference * references
Definition: detect.h:740
FileContainer_::head
File * head
Definition: util-file.h:38
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PacketContextData
Definition: decode.h:259
Packet_::tunnel_id
uint16_t tunnel_id
Definition: decode.h:558
DETECT_TABLE_PACKET_PRE_FLOW
@ DETECT_TABLE_PACKET_PRE_FLOW
Definition: detect.h:537
EveNFSAddMetadataRPC
bool EveNFSAddMetadataRPC(const Flow *f, uint64_t tx_id, SCJsonBuilder *jb)
Definition: output-json-nfs.c:49
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:941
DETECT_TABLE_PACKET_FILTER
@ DETECT_TABLE_PACKET_FILTER
Definition: detect.h:539
DetectFirewallPolicyToString
void DetectFirewallPolicyToString(const struct DetectFirewallPolicy *p, char *out, size_t out_size)
Definition: detect-parse.c:4283
JsonAlertLogThread
struct JsonAlertLogThread_ JsonAlertLogThread
output-json-email-common.h
OutputInitResult_::ok
bool ok
Definition: output.h:48
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
app-layer-parser.h
JsonAlertLogThread_
Definition: output-json-alert.c:107
DetectReference_
Signature reference list.
Definition: detect-reference.h:30
AppLayerParserGetStateProgress
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *tx, uint8_t flags)
get the progress value for a tx/protocol
Definition: app-layer-parser.c:1199
Signature_::sub_state
uint8_t sub_state
Definition: detect.h:704
Signature_::action
uint8_t action
Definition: detect.h:678
Signature_::flags
uint32_t flags
Definition: detect.h:664
stream.h
DetectReference_::reference_len
uint16_t reference_len
Definition: detect-reference.h:41
JsonAddrInfo_
Definition: output-json.h:41
ACTION_ALERT
#define ACTION_ALERT
Definition: action-globals.h:29
Packet_
Definition: decode.h:528
EveFileInfo
void EveFileInfo(SCJsonBuilder *jb, const File *ff, const uint64_t tx_id, const uint16_t flags)
Definition: output-json.c:121
DetectReference_::reference
char * reference
Definition: detect-reference.h:34
JSON_STREAM_BUFFER_SIZE
#define JSON_STREAM_BUFFER_SIZE
Definition: output-json-alert.c:96
LOG_JSON_PAYLOAD_BASE64
#define LOG_JSON_PAYLOAD_BASE64
Definition: output-json-alert.c:74
conf.h
DETECT_MAX_RULE_SIZE
#define DETECT_MAX_RULE_SIZE
Definition: detect.h:47
SIG_FLAG_HAS_TARGET
#define SIG_FLAG_HAS_TARGET
Definition: detect.h:261
XFF_OVERWRITE
#define XFF_OVERWRITE
Definition: app-layer-htp-xff.h:33
LOG_JSON_PAYLOAD_LENGTH
#define LOG_JSON_PAYLOAD_LENGTH
Definition: output-json-alert.c:85
TmEcode
TmEcode
Definition: tm-threads-common.h:80
SIG_FLAG_SRC_IS_TARGET
#define SIG_FLAG_SRC_IS_TARGET
Definition: detect.h:257
HttpXFFCfg_
Definition: app-layer-htp-xff.h:41
AlertJsonOutputCtx_::payload_buffer_size
uint32_t payload_buffer_size
Definition: output-json-alert.c:101
EvePacket
void EvePacket(const Packet *p, SCJsonBuilder *js, uint32_t max_length)
Jsonify a packet.
Definition: output-json.c:419
MemBuffer_
Definition: util-buffer.h:27
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:237
EveJsonSimpleAppLayerLogger
Definition: output-eve.h:57
DetectReference_::next
struct DetectReference_ * next
Definition: detect-reference.h:43
LOG_JSON_TAGGED_PACKETS
#define LOG_JSON_TAGGED_PACKETS
Definition: output-json-alert.c:75
AppLayerParserGetTx
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
Definition: app-layer-parser.c:1219
AlertJsonOutputCtx_::xff_cfg
HttpXFFCfg * xff_cfg
Definition: output-json-alert.c:102
PACKET_ALERT_FLAG_STREAM_MATCH
#define PACKET_ALERT_FLAG_STREAM_MATCH
Definition: decode.h:289
PACKET_ALERT_FLAG_FRAME
#define PACKET_ALERT_FLAG_FRAME
Definition: decode.h:295
log-pcap.h
PacketAlert_::frame_id
int64_t frame_id
Definition: decode.h:273
JsonAddrInfo_::proto
char proto[JSON_PROTO_LEN]
Definition: output-json.h:46
Signature_::class_msg
char * class_msg
Definition: detect.h:738
PacketAlert_::flags
uint8_t flags
Definition: decode.h:269
ACTION_REJECT_BOTH
#define ACTION_REJECT_BOTH
Definition: action-globals.h:33
File_::flags
uint16_t flags
Definition: util-file.h:147
SCConfNodeLookupChild
SCConfNode * SCConfNodeLookupChild(const SCConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:849
File_
Definition: util-file.h:146
PacketAlert_::sub_state
uint8_t sub_state
Definition: decode.h:270
OutputInitResult_
Definition: output.h:46
app-layer-frames.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:584
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:698
EveEmailAddMetadata
bool EveEmailAddMetadata(const Flow *f, uint64_t tx_id, SCJsonBuilder *js)
Definition: output-json-email-common.c:193
flags
uint8_t flags
Definition: decode-gre.h:0
AppLayerGetFileState
Definition: util-file.h:44
suricata-common.h
LOG_JSON_WEBSOCKET_PAYLOAD_BASE64
#define LOG_JSON_WEBSOCKET_PAYLOAD_BASE64
Definition: output-json-alert.c:84
JsonAddrInfo_::sp
Port sp
Definition: output-json.h:44
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:94
AppLayerGetFileState::fc
FileContainer * fc
Definition: util-file.h:45
pcap_filename
char pcap_filename[PATH_MAX]
Definition: source-pcap-file-helper.c:166
EveJsonSimpleAppLayerLogger::LogTx
EveJsonSimpleTxLogFunc LogTx
Definition: output-eve.h:58
JSON_ADDR_LEN
#define JSON_ADDR_LEN
Definition: output-json.h:37
AlertJsonOutputCtx_
Definition: output-json-alert.c:98
detect-metadata.h
Signature_::action_scope
uint8_t action_scope
Definition: detect.h:685
JsonAlertLogThread_::json_output_ctx
AlertJsonOutputCtx * json_output_ctx
Definition: output-json-alert.c:109
output-json-nfs.h
packet.h
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:36
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:86
LOG_JSON_VERDICT
#define LOG_JSON_VERDICT
Definition: output-json-alert.c:82
File_::next
struct File_ * next
Definition: util-file.h:159
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
OutputPacketLoggerFunctions_::LogFunc
PacketLogger LogFunc
Definition: output.h:87
PacketGetAction
uint8_t PacketGetAction(const Packet *p)
Definition: packet.c:62
Signature_::rev
uint32_t rev
Definition: detect.h:714
AppLayerParserGetSubStateProgressName
const char * AppLayerParserGetSubStateProgressName(const AppProto alproto, const uint8_t sub_state, const uint8_t state, const uint8_t dir_flag)
Definition: app-layer-parser.c:1277
ALPROTO_WEBSOCKET
@ ALPROTO_WEBSOCKET
Definition: app-layer-protos.h:64
TcpSession_::client
TcpStream client
Definition: stream-tcp-private.h:304
PacketContextData::next
struct PacketContextData * next
Definition: decode.h:261
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:230
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
Signature_::prio
int prio
Definition: detect.h:715
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:173
output-json-alert.h
threadvars.h
util-validate.h
Packet_::root
struct Packet_ * root
Definition: decode.h:686
TcpSession_::server
TcpStream server
Definition: stream-tcp-private.h:303
JsonAddrInfo_::src_ip
char src_ip[JSON_ADDR_LEN]
Definition: output-json.h:42
EveAddVerdict
void EveAddVerdict(SCJsonBuilder *jb, const Packet *p, const uint8_t alert_action)
Build verdict object.
Definition: output-json-alert.c:552
PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED
#define PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED
Definition: decode.h:293
HttpXFFCfg_::flags
uint8_t flags
Definition: app-layer-htp-xff.h:42
Signature_::metadata
DetectMetadataHead * metadata
Definition: detect.h:742
DetectFirewallPolicy
Definition: detect.h:917
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
EveHttpLogJSONBodyBase64
void EveHttpLogJSONBodyBase64(SCJsonBuilder *js, Flow *f, uint64_t tx_id)
Definition: output-json-http.c:411
AlertJsonOutputCtx
struct AlertJsonOutputCtx_ AlertJsonOutputCtx
JsonAlertLogThread_::payload_buffer
MemBuffer * payload_buffer
Definition: output-json-alert.c:108
SCFree
#define SCFree(p)
Definition: util-mem.h:61
AppLayerParserGetSubStateName
const char * AppLayerParserGetSubStateName(const AppProto alproto, const uint8_t sub_state)
Definition: app-layer-parser.c:1326
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:646
DetectReference_::key
char * key
Definition: detect-reference.h:32
util-logopenfile.h
Flow_::alstate
void * alstate
Definition: flow.h:486
Signature_::id
uint32_t id
Definition: detect.h:712
SCEveJsonSimpleGetLogger
EveJsonSimpleAppLayerLogger * SCEveJsonSimpleGetLogger(AppProto alproto)
Definition: output.c:923
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:553
LOG_JSON_HTTP_BODY_BASE64
#define LOG_JSON_HTTP_BODY_BASE64
Definition: output-json-alert.c:79
output-json-ike.h
detect-parse.h
FrameJsonLogOneFrame
void FrameJsonLogOneFrame(const uint8_t ipproto, const Frame *frame, Flow *f, const TcpStream *stream, const Packet *p, SCJsonBuilder *jb, MemBuffer *buffer)
log a single frame
Definition: output-json-frame.c:237
util-buffer.h
Signature_
Signature container.
Definition: detect.h:663
LOG_JSON_PACKET
#define LOG_JSON_PACKET
Definition: output-json-alert.c:73
PACKET_ALERT_FLAG_TX
#define PACKET_ALERT_FLAG_TX
Definition: decode.h:291
JsonAddrInfo_::dst_ip
char dst_ip[JSON_ADDR_LEN]
Definition: output-json.h:43
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:78
LOG_JSON_HTTP_BODY
#define LOG_JSON_HTTP_BODY
Definition: output-json-alert.c:78
METADATA_DEFAULTS
#define METADATA_DEFAULTS
Definition: output-json-alert.c:88
ACTION_ACCEPT
#define ACTION_ACCEPT
Definition: action-globals.h:36
EngineModeIsIPS
int EngineModeIsIPS(void)
Definition: suricata.c:247
LOG_JSON_FLOW
#define LOG_JSON_FLOW
Definition: output-json-alert.c:77
MemBufferWriteRaw
uint32_t MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len)
Write a raw buffer to the MemBuffer dst.
Definition: util-buffer.c:115
PacketAlert_
Definition: decode.h:266
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:130
Signature_::detect_table
uint8_t detect_table
Definition: detect.h:697
output-json-smb.h
ALPROTO_SMB
@ ALPROTO_SMB
Definition: app-layer-protos.h:43
likely
#define likely(expr)
Definition: util-optimize.h:32
IPPROTO_SCTP
#define IPPROTO_SCTP
Definition: decode.h:1282
PacketContextData::json_string
char * json_string
Definition: decode.h:260
AppLayerParserSupportsSubStates
bool AppLayerParserSupportsSubStates(const AppProto alproto)
Definition: app-layer-parser.c:1356
HttpXFFGetIPFromTx
int HttpXFFGetIPFromTx(const Flow *f, uint64_t tx_id, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen)
Function to return XFF IP if any in the selected transaction. The caller needs to lock the flow.
Definition: app-layer-htp-xff.c:52
output-json-smtp.h
TcpSession_
Definition: stream-tcp-private.h:290
output-json-http.h
util-misc.h
PKT_HAS_TAG
#define PKT_HAS_TAG
Definition: decode.h:1312
Signature_::msg
char * msg
Definition: detect.h:735
flow.h
DetectEngineSetParseMetadata
void DetectEngineSetParseMetadata(void)
Definition: detect-engine.c:5424
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:457
StreamReassembleLog
int StreamReassembleLog(const TcpSession *ssn, const TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, const uint64_t progress_in, uint64_t *progress_out, const bool eof)
Definition: stream-tcp-reassemble.c:1982
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCConfNode_
Definition: conf.h:37
LOG_JSON_RULE_METADATA
#define LOG_JSON_RULE_METADATA
Definition: output-json-alert.c:80
OutputPacketLoggerFunctions_
Definition: output.h:86
SCConfNode_::val
char * val
Definition: conf.h:39
XFF_DISABLED
#define XFF_DISABLED
Definition: app-layer-htp-xff.h:29
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
LOG_JSON_REFERENCE
#define LOG_JSON_REFERENCE
Definition: output-json-alert.c:86
ALPROTO_NFS
@ ALPROTO_NFS
Definition: app-layer-protos.h:51
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
output.h
JsonAlertLogRegister
void JsonAlertLogRegister(void)
Definition: output-json-alert.c:1175
f
Flow f
Definition: fuzz_dataset.c:32
AlertJsonStreamDataCallbackData
Definition: output-json-alert.c:602