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  SCJbSetUint(js, "depth", p->recursion_level);
308  uint64_t pcap_cnt = PcapPacketCntGet(p->root);
309  if (pcap_cnt != 0) {
310  SCJbSetUint(js, "pcap_cnt", pcap_cnt);
311  }
312  SCJbSetString(js, "pkt_src", PktSrcToString(pkt_src));
313  SCJbClose(js);
314 }
315 
316 static void AlertAddPayload(AlertJsonOutputCtx *json_output_ctx, SCJsonBuilder *js, const Packet *p)
317 {
318  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_BASE64) {
319  SCJbSetBase64(js, "payload", p->payload, p->payload_len);
320  }
321  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_LENGTH) {
322  SCJbSetUint(js, "payload_length", p->payload_len);
323  }
324 
325  if (json_output_ctx->flags & LOG_JSON_PAYLOAD) {
326  SCJbSetPrintAsciiString(js, "payload_printable", p->payload, p->payload_len);
327  }
328 }
329 
330 static void AlertAddAppLayerStates(const Packet *p, const AppProto alproto, const uint8_t sub_state,
331  void *tx, SCJsonBuilder *jb)
332 {
333  const int ts = AppLayerParserGetStateProgress(p->flow->proto, alproto, tx, STREAM_TOSERVER);
334  const int tc = AppLayerParserGetStateProgress(p->flow->proto, alproto, tx, STREAM_TOCLIENT);
335  if (sub_state == 0) {
336  SCJbSetString(jb, "ts_progress",
337  AppLayerParserGetStateNameById(p->flow->proto, alproto, ts, STREAM_TOSERVER));
338  SCJbSetString(jb, "tc_progress",
339  AppLayerParserGetStateNameById(p->flow->proto, alproto, tc, STREAM_TOCLIENT));
340  } else {
341  const char *sname = AppLayerParserGetSubStateName(alproto, sub_state);
342  if (sname != NULL) {
343  SCJbSetString(jb, "sub_state", sname);
344  }
345  SCJbSetString(jb, "ts_progress",
347  alproto, sub_state, (uint8_t)ts, STREAM_TOSERVER));
348  SCJbSetString(jb, "tc_progress",
350  alproto, sub_state, (uint8_t)tc, STREAM_TOCLIENT));
351  }
352 }
353 
354 static void AlertAddAppLayer(const Packet *p, SCJsonBuilder *jb, const uint64_t tx_id,
355  const uint8_t sub_state, const uint16_t option_flags)
356 {
359  void *state = FlowGetAppState(p->flow);
360  void *tx = NULL;
361  if (state) {
362  tx = AppLayerParserGetTx(p->flow->proto, proto, state, tx_id);
363  }
364  if (tx == NULL)
365  return;
366 
367  AlertAddAppLayerStates(p, proto, sub_state, tx, jb);
368 
369  SCJsonBuilderMark mark = { 0, 0, 0 };
370  if (al && al->LogTx) {
371  SCJbGetMark(jb, &mark);
372  switch (proto) {
373  // first check some protocols need special options for alerts logging
374  case ALPROTO_WEBSOCKET:
375  if (option_flags &
377  const bool pp = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD) != 0;
378  const bool pb64 = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD_BASE64) != 0;
379  if (!SCWebSocketLogDetails(tx, jb, pp, pb64)) {
380  SCJbRestoreMark(jb, &mark);
381  }
382  // nothing more to log or do
383  return;
384  }
385  }
386  if (!al->LogTx(tx, jb)) {
387  SCJbRestoreMark(jb, &mark);
388  }
389  return;
390  }
391 
392  switch (proto) {
393  case ALPROTO_HTTP1:
394  // TODO: Could result in an empty http object being logged.
395  SCJbOpenObject(jb, "http");
396  if (EveHttpAddMetadata(p->flow, tx_id, jb)) {
397  if (option_flags & LOG_JSON_HTTP_BODY) {
398  EveHttpLogJSONBodyPrintable(jb, p->flow, tx_id);
399  }
400  if (option_flags & LOG_JSON_HTTP_BODY_BASE64) {
401  EveHttpLogJSONBodyBase64(jb, p->flow, tx_id);
402  }
403  }
404  SCJbClose(jb);
405  break;
406  case ALPROTO_SMTP:
407  SCJbGetMark(jb, &mark);
408  SCJbOpenObject(jb, "smtp");
409  if (EveSMTPAddMetadata(p->flow, tx_id, jb)) {
410  SCJbClose(jb);
411  } else {
412  SCJbRestoreMark(jb, &mark);
413  }
414  SCJbGetMark(jb, &mark);
415  SCJbOpenObject(jb, "email");
416  if (EveEmailAddMetadata(p->flow, tx_id, jb)) {
417  SCJbClose(jb);
418  } else {
419  SCJbRestoreMark(jb, &mark);
420  }
421  break;
422  case ALPROTO_NFS:
423  /* rpc */
424  SCJbGetMark(jb, &mark);
425  SCJbOpenObject(jb, "rpc");
426  if (EveNFSAddMetadataRPC(p->flow, tx_id, jb)) {
427  SCJbClose(jb);
428  } else {
429  SCJbRestoreMark(jb, &mark);
430  }
431  /* nfs */
432  SCJbGetMark(jb, &mark);
433  SCJbOpenObject(jb, "nfs");
434  if (EveNFSAddMetadata(p->flow, tx_id, jb)) {
435  SCJbClose(jb);
436  } else {
437  SCJbRestoreMark(jb, &mark);
438  }
439  break;
440  case ALPROTO_SMB:
441  SCJbGetMark(jb, &mark);
442  SCJbOpenObject(jb, "smb");
443  if (EveSMBAddMetadata(p->flow, tx_id, jb)) {
444  SCJbClose(jb);
445  } else {
446  SCJbRestoreMark(jb, &mark);
447  }
448  break;
449  case ALPROTO_IKE:
450  SCJbGetMark(jb, &mark);
451  if (!EveIKEAddMetadata(p->flow, tx_id, jb)) {
452  SCJbRestoreMark(jb, &mark);
453  }
454  break;
455  case ALPROTO_DCERPC:
456  SCJbGetMark(jb, &mark);
457  SCJbOpenObject(jb, "dcerpc");
458  if (p->proto == IPPROTO_TCP) {
459  if (!SCDcerpcLogJsonRecordTcp(state, tx, jb)) {
460  SCJbRestoreMark(jb, &mark);
461  }
462  } else {
463  if (!SCDcerpcLogJsonRecordUdp(state, tx, jb)) {
464  SCJbRestoreMark(jb, &mark);
465  }
466  }
467  SCJbClose(jb);
468  break;
469  default:
470  break;
471  }
472 }
473 
474 static void AlertAddFiles(const Packet *p, SCJsonBuilder *jb, const uint64_t tx_id)
475 {
476  const uint8_t direction =
477  (p->flowflags & FLOW_PKT_TOSERVER) ? STREAM_TOSERVER : STREAM_TOCLIENT;
478  FileContainer *ffc = NULL;
479  if (p->flow->alstate != NULL) {
480  void *tx = AppLayerParserGetTx(p->flow->proto, p->flow->alproto, p->flow->alstate, tx_id);
481  if (tx) {
482  AppLayerGetFileState files = AppLayerParserGetTxFiles(p->flow, tx, direction);
483  ffc = files.fc;
484  }
485  }
486  if (ffc != NULL) {
487  File *file = ffc->head;
488  bool isopen = false;
489  while (file) {
490  if (!isopen) {
491  isopen = true;
492  SCJbOpenArray(jb, "files");
493  }
494  SCJbStartObject(jb);
495  EveFileInfo(jb, file, tx_id, file->flags);
496  SCJbClose(jb);
497  file = file->next;
498  }
499  if (isopen) {
500  SCJbClose(jb);
501  }
502  }
503 }
504 
505 static void AlertAddFrame(
506  const Packet *p, const int64_t frame_id, SCJsonBuilder *jb, MemBuffer *buffer)
507 {
508  if (p->flow == NULL || (p->proto == IPPROTO_TCP && p->flow->protoctx == NULL))
509  return;
510 
511  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
512  if (frames_container == NULL)
513  return;
514 
515  Frames *frames = NULL;
516  TcpStream *stream = NULL;
517  if (p->proto == IPPROTO_TCP) {
519  if (PKT_IS_TOSERVER(p)) {
520  stream = &ssn->client;
521  frames = &frames_container->toserver;
522  } else {
523  stream = &ssn->server;
524  frames = &frames_container->toclient;
525  }
526  Frame *frame = FrameGetById(frames, frame_id);
527  if (frame != NULL) {
528  FrameJsonLogOneFrame(IPPROTO_TCP, frame, p->flow, stream, p, jb, buffer);
529  }
530  } else if (p->proto == IPPROTO_UDP) {
531  if (PKT_IS_TOSERVER(p)) {
532  frames = &frames_container->toserver;
533  } else {
534  frames = &frames_container->toclient;
535  }
536  Frame *frame = FrameGetById(frames, frame_id);
537  if (frame != NULL) {
538  FrameJsonLogOneFrame(IPPROTO_UDP, frame, p->flow, NULL, p, jb, buffer);
539  }
540  }
541 }
542 
543 /**
544  * \brief Build verdict object
545  *
546  * \param p Pointer to Packet current being logged
547  * \param alert_action action bitfield from the alert: only used for ACTION_PASS
548  */
549 void EveAddVerdict(SCJsonBuilder *jb, const Packet *p, const uint8_t alert_action)
550 {
551  SCJbOpenObject(jb, "verdict");
552 
553  const uint8_t packet_action = PacketGetAction(p);
554  SCLogDebug("%" PRIu64 ": packet_action %02x alert_action %02x", PcapPacketCntGet(p),
555  packet_action, alert_action);
556  /* add verdict info */
557  if (packet_action & ACTION_REJECT_ANY) {
558  // check rule to define type of reject packet sent
559  if (EngineModeIsIPS()) {
560  JB_SET_STRING(jb, "action", "drop");
561  } else {
562  JB_SET_STRING(jb, "action", "alert");
563  }
564  if (packet_action & ACTION_REJECT) {
565  JB_SET_STRING(jb, "reject_target", "to_client");
566  } else if (packet_action & ACTION_REJECT_DST) {
567  JB_SET_STRING(jb, "reject_target", "to_server");
568  } else if (packet_action & ACTION_REJECT_BOTH) {
569  JB_SET_STRING(jb, "reject_target", "both");
570  }
571  SCJbOpenArray(jb, "reject");
572  switch (p->proto) {
573  case IPPROTO_UDP:
574  case IPPROTO_ICMP:
575  case IPPROTO_ICMPV6:
576  SCJbAppendString(jb, "icmp-prohib");
577  break;
578  case IPPROTO_TCP:
579  SCJbAppendString(jb, "tcp-reset");
580  break;
581  }
582  SCJbClose(jb);
583 
584  } else if ((packet_action & ACTION_DROP) && EngineModeIsIPS()) {
585  JB_SET_STRING(jb, "action", "drop");
586  } else if (packet_action & ACTION_ACCEPT) {
587  JB_SET_STRING(jb, "action", "accept");
588  } else if (alert_action & ACTION_PASS) {
589  JB_SET_STRING(jb, "action", "pass");
590  } else {
591  // TODO make sure we don't have a situation where this wouldn't work
592  JB_SET_STRING(jb, "action", "alert");
593  }
594 
595  /* Close verdict */
596  SCJbClose(jb);
597 }
598 
601  uint64_t last_re;
602 };
603 
604 static int AlertJsonStreamDataCallback(
605  void *cb_data, const uint8_t *input, const uint32_t input_len, const uint64_t input_offset)
606 {
607  struct AlertJsonStreamDataCallbackData *cbd = cb_data;
608  if (input_offset > cbd->last_re) {
610  cbd->payload, "[%" PRIu64 " bytes missing]", input_offset - cbd->last_re);
611  }
612 
613  int done = 0;
614  uint32_t written = MemBufferWriteRaw(cbd->payload, input, input_len);
615  if (written < input_len)
616  done = 1;
617  cbd->last_re = input_offset + input_len;
618  return done;
619 }
620 
621 /** \internal
622  * \brief try to log stream data into payload/payload_printable
623  * \retval true stream data logged
624  * \retval false stream data not logged
625  */
626 static bool AlertJsonStreamData(const AlertJsonOutputCtx *json_output_ctx, JsonAlertLogThread *aft,
627  Flow *f, const Packet *p, SCJsonBuilder *jb)
628 {
629  TcpSession *ssn = f->protoctx;
630  TcpStream *stream = (PKT_IS_TOSERVER(p)) ? &ssn->client : &ssn->server;
631 
632  MemBufferReset(aft->payload_buffer);
634  .last_re = STREAM_BASE_OFFSET(stream) };
635  uint64_t unused = 0;
636  StreamReassembleLog(ssn, stream, AlertJsonStreamDataCallback, &cbd, STREAM_BASE_OFFSET(stream),
637  &unused, false);
638  if (cbd.payload->offset) {
639  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_BASE64) {
640  SCJbSetBase64(jb, "payload", cbd.payload->buffer, cbd.payload->offset);
641  }
642  if (json_output_ctx->flags & LOG_JSON_PAYLOAD_LENGTH) {
643  SCJbSetUint(jb, "payload_length", cbd.payload->offset);
644  }
645 
646  if (json_output_ctx->flags & LOG_JSON_PAYLOAD) {
647  SCJbSetPrintAsciiString(
648  jb, "payload_printable", cbd.payload->buffer, cbd.payload->offset);
649  }
650  return true;
651  }
652  return false;
653 }
654 
655 static void AlertJsonAddFirewall(SCJsonBuilder *jb, const Signature *s)
656 {
657  struct DetectFirewallPolicy pol = { .action = s->action, .action_scope = s->action_scope };
658 
659  SCJbOpenObject(jb, "firewall");
660  const char *hook = NULL;
661  char hook_string[256];
662  switch (s->detect_table) {
664  const uint8_t dir_flag =
665  (s->flags & SIG_FLAG_TOSERVER) ? STREAM_TOSERVER : STREAM_TOCLIENT;
667  /* sub state rules (http2 stream/global): resolve the state in
668  * the sub state table and keep the sub state in the name */
669  const char *state = AppLayerParserGetSubStateProgressName(
670  s->alproto, s->sub_state, s->app_progress_hook, dir_flag);
671  const char *sub_state_name =
673  if (state != NULL && sub_state_name != NULL) {
674  snprintf(hook_string, sizeof(hook_string), "%s:%s:%s",
675  AppProtoToString(s->alproto), sub_state_name, state);
676  hook = hook_string;
677  }
678  }
679  if (hook == NULL) {
680  /* no sub state, or the sub state lookup failed: fall back to
681  * the plain per-protocol state name */
683  IPPROTO_TCP, s->alproto, s->app_progress_hook, dir_flag);
684  if (hook != NULL) {
685  snprintf(hook_string, sizeof(hook_string), "%s:%s",
686  AppProtoToString(s->alproto), hook);
687  hook = hook_string;
688  }
689  }
690  break;
691  }
693  hook = "packet:filter";
694  break;
696  hook = "packet:pre_flow";
697  break;
699  hook = "packet:pre_stream";
700  break;
701  }
702  if (hook) {
703  SCJbSetString(jb, "hook", hook);
704  }
705  char policy_string[64] = "";
706  DetectFirewallPolicyToString(&pol, policy_string, sizeof(policy_string));
707  if (strlen(policy_string) > 0) {
708  SCJbSetString(jb, "policy", policy_string);
709  }
710  SCJbClose(jb);
711 }
712 
713 static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
714 {
715  AlertJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
716 
717  if (p->alerts.cnt == 0 && !(p->flags & PKT_HAS_TAG))
718  return TM_ECODE_OK;
719 
720  const uint8_t final_action = p->alerts.cnt > 0 ? p->alerts.alerts[p->alerts.cnt - 1].action : 0;
721  for (int i = 0; i < p->alerts.cnt; i++) {
722  const PacketAlert *pa = &p->alerts.alerts[i];
723  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
724  continue;
725  }
726 
727  /* First initialize the address info (5-tuple). */
729  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr, &json_output_ctx->eve_ctx->cfg);
730 
731  /* Check for XFF, overwriting address info if needed. */
732  HttpXFFCfg *xff_cfg = json_output_ctx->xff_cfg != NULL ? json_output_ctx->xff_cfg
733  : json_output_ctx->parent_xff_cfg;
734  int have_xff_ip = 0;
735  char xff_buffer[XFF_MAXLEN];
736  xff_buffer[0] = 0;
737  if ((xff_cfg != NULL) && !(xff_cfg->flags & XFF_DISABLED) && p->flow != NULL) {
739  if (pa->flags & PACKET_ALERT_FLAG_TX) {
740  have_xff_ip = HttpXFFGetIPFromTx(p->flow, pa->tx_id, xff_cfg,
741  xff_buffer, XFF_MAXLEN);
742  } else {
743  have_xff_ip = HttpXFFGetIP(p->flow, xff_cfg, xff_buffer,
744  XFF_MAXLEN);
745  }
746  }
747 
748  if (have_xff_ip && xff_cfg->flags & XFF_OVERWRITE) {
749  if (p->flowflags & FLOW_PKT_TOCLIENT) {
750  strlcpy(addr.dst_ip, xff_buffer, JSON_ADDR_LEN);
751  } else {
752  strlcpy(addr.src_ip, xff_buffer, JSON_ADDR_LEN);
753  }
754  /* Clear have_xff_ip so the xff field does not get
755  * logged below. */
756  have_xff_ip = false;
757  }
758  if (have_xff_ip && !(xff_cfg->flags & XFF_EXTRADATA)) {
759  // reset xff_buffer so as not to log it
760  xff_buffer[0] = 0;
761  }
762  }
763 
764  SCJsonBuilder *jb =
765  CreateEveHeader(p, LOG_DIR_PACKET, "alert", &addr, json_output_ctx->eve_ctx);
766  if (unlikely(jb == NULL))
767  return TM_ECODE_OK;
768 
769 
770  /* alert */
771  AlertJsonHeader(p, pa, jb, json_output_ctx->flags, &addr, xff_buffer);
772 
773  if (PacketIsTunnel(p)) {
774  AlertJsonTunnel(p, jb, &json_output_ctx->eve_ctx->cfg);
775  }
776 
777  if (pa->s->flags & SIG_FLAG_FIREWALL) {
778  AlertJsonAddFirewall(jb, pa->s);
779  }
780 
781  if (p->flow != NULL) {
782  if (pa->flags & PACKET_ALERT_FLAG_TX) {
783  if (json_output_ctx->flags & LOG_JSON_APP_LAYER) {
784  AlertAddAppLayer(p, jb, pa->tx_id, pa->sub_state, json_output_ctx->flags);
785  }
786  /* including fileinfo data is configured by the metadata setting */
787  if (json_output_ctx->flags & LOG_JSON_RULE_METADATA) {
788  AlertAddFiles(p, jb, pa->tx_id);
789  }
790  }
791 
792  EveAddAppProto(p->flow, jb);
793 
794  if (p->flowflags & FLOW_PKT_TOSERVER) {
795  SCJbSetString(jb, "direction", "to_server");
796  } else {
797  SCJbSetString(jb, "direction", "to_client");
798  }
799 
800  if (json_output_ctx->flags & LOG_JSON_FLOW) {
801  SCJbOpenObject(jb, "flow");
802  EveAddFlow(p->flow, jb);
803  if (p->flowflags & FLOW_PKT_TOCLIENT) {
804  SCJbSetString(jb, "src_ip", addr.dst_ip);
805  SCJbSetString(jb, "dest_ip", addr.src_ip);
806  if (addr.sp > 0) {
807  SCJbSetUint(jb, "src_port", addr.dp);
808  SCJbSetUint(jb, "dest_port", addr.sp);
809  }
810  } else {
811  SCJbSetString(jb, "src_ip", addr.src_ip);
812  SCJbSetString(jb, "dest_ip", addr.dst_ip);
813  if (addr.sp > 0) {
814  SCJbSetUint(jb, "src_port", addr.sp);
815  SCJbSetUint(jb, "dest_port", addr.dp);
816  }
817  }
818  SCJbClose(jb);
819  }
820  }
821 
822  /* payload */
823  if (json_output_ctx->flags &
825  int stream = (p->proto == IPPROTO_TCP) ?
827  1 : 0) : 0;
828  // should be impossible, as stream implies flow
829  DEBUG_VALIDATE_BUG_ON(stream && p->flow == NULL);
830 
831  /* Is this a stream? If so, pack part of it into the payload field */
832  if (stream && p->flow != NULL) {
833  const bool stream_data_logged =
834  AlertJsonStreamData(json_output_ctx, aft, p->flow, p, jb);
835  if (!stream_data_logged && p->payload_len) {
836  /* Fallback on packet payload */
837  AlertAddPayload(json_output_ctx, jb, p);
838  }
839  } else {
840  /* This is a single packet and not a stream */
841  AlertAddPayload(json_output_ctx, jb, p);
842  }
843 
844  SCJbSetUint(jb, "stream", stream);
845  }
846 
847  if (pa->flags & PACKET_ALERT_FLAG_FRAME) {
848  AlertAddFrame(p, pa->frame_id, jb, aft->payload_buffer);
849  }
850 
851  /* base64-encoded full packet */
852  if (json_output_ctx->flags & LOG_JSON_PACKET) {
853  EvePacket(p, jb, 0);
854  }
855 
857  if (pcap_filename != NULL) {
858  SCJbSetString(jb, "capture_file", pcap_filename);
859  }
860 
861  if (json_output_ctx->flags & LOG_JSON_VERDICT) {
862  EveAddVerdict(jb, p, final_action & ACTION_PASS);
863  }
864 
865  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
866  SCJbFree(jb);
867  }
868 
869  if ((p->flags & PKT_HAS_TAG) && (json_output_ctx->flags &
871  SCJsonBuilder *packetjs =
872  CreateEveHeader(p, LOG_DIR_PACKET, "packet", NULL, json_output_ctx->eve_ctx);
873  if (unlikely(packetjs != NULL)) {
874  EvePacket(p, packetjs, 0);
875  OutputJsonBuilderBuffer(tv, p, p->flow, packetjs, aft->ctx);
876  SCJbFree(packetjs);
877  }
878  }
879 
880  return TM_ECODE_OK;
881 }
882 
883 static int AlertJsonDecoderEvent(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
884 {
885  AlertJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
886 
887  if (p->alerts.cnt == 0)
888  return TM_ECODE_OK;
889 
890  const uint8_t final_action = p->alerts.alerts[p->alerts.cnt - 1].action;
891  for (int i = 0; i < p->alerts.cnt; i++) {
892  const PacketAlert *pa = &p->alerts.alerts[i];
893  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
894  continue;
895  }
896 
897  SCJsonBuilder *jb =
898  CreateEveHeader(p, LOG_DIR_PACKET, "alert", NULL, json_output_ctx->eve_ctx);
899  if (unlikely(jb == NULL))
900  return TM_ECODE_OK;
901 
902  AlertJsonHeader(p, pa, jb, json_output_ctx->flags, NULL, NULL);
903 
904  if (PacketIsTunnel(p)) {
905  AlertJsonTunnel(p, jb, &json_output_ctx->eve_ctx->cfg);
906  }
907 
908  /* base64-encoded full packet */
909  if (json_output_ctx->flags & LOG_JSON_PACKET) {
910  EvePacket(p, jb, 0);
911  }
912 
914  if (pcap_filename != NULL) {
915  SCJbSetString(jb, "capture_file", pcap_filename);
916  }
917 
918  if (json_output_ctx->flags & LOG_JSON_VERDICT) {
919  EveAddVerdict(jb, p, final_action & ACTION_PASS);
920  }
921 
922  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
923  SCJbFree(jb);
924  }
925 
926  return TM_ECODE_OK;
927 }
928 
929 static int JsonAlertLogger(ThreadVars *tv, void *thread_data, const Packet *p)
930 {
931  JsonAlertLogThread *aft = thread_data;
932 
933  if (PacketIsIPv4(p) || PacketIsIPv6(p)) {
934  return AlertJson(tv, aft, p);
935  } else if (p->alerts.cnt > 0) {
936  return AlertJsonDecoderEvent(tv, aft, p);
937  }
938  return 0;
939 }
940 
941 static bool JsonAlertLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
942 {
943  return (p->alerts.cnt || (p->flags & PKT_HAS_TAG));
944 }
945 
946 static TmEcode JsonAlertLogThreadInit(ThreadVars *t, const void *initdata, void **data)
947 {
949  if (unlikely(aft == NULL))
950  return TM_ECODE_FAILED;
951 
952  if (initdata == NULL)
953  {
954  SCLogDebug("Error getting context for EveLogAlert. \"initdata\" argument NULL");
955  goto error_exit;
956  }
957 
958  /** Use the Output Context (file pointer and mutex) */
959  AlertJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
960 
961  aft->payload_buffer = MemBufferCreateNew(json_output_ctx->payload_buffer_size);
962  if (aft->payload_buffer == NULL) {
963  goto error_exit;
964  }
965  aft->ctx = CreateEveThreadCtx(t, json_output_ctx->eve_ctx);
966  if (!aft->ctx) {
967  goto error_exit;
968  }
969 
970  aft->json_output_ctx = json_output_ctx;
971 
972  *data = (void *)aft;
973  return TM_ECODE_OK;
974 
975 error_exit:
976  if (aft->payload_buffer != NULL) {
978  }
979  SCFree(aft);
980  return TM_ECODE_FAILED;
981 }
982 
983 static TmEcode JsonAlertLogThreadDeinit(ThreadVars *t, void *data)
984 {
985  JsonAlertLogThread *aft = (JsonAlertLogThread *)data;
986  if (aft == NULL) {
987  return TM_ECODE_OK;
988  }
989 
991  FreeEveThreadCtx(aft->ctx);
992 
993  /* clear memory */
994  memset(aft, 0, sizeof(JsonAlertLogThread));
995 
996  SCFree(aft);
997  return TM_ECODE_OK;
998 }
999 
1000 static void JsonAlertLogDeInitCtxSub(OutputCtx *output_ctx)
1001 {
1002  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
1003 
1004  AlertJsonOutputCtx *json_output_ctx = (AlertJsonOutputCtx *) output_ctx->data;
1005 
1006  if (json_output_ctx != NULL) {
1007  HttpXFFCfg *xff_cfg = json_output_ctx->xff_cfg;
1008  if (xff_cfg != NULL) {
1009  SCFree(xff_cfg);
1010  }
1011  SCFree(json_output_ctx);
1012  }
1013  SCFree(output_ctx);
1014 }
1015 
1016 static void SetFlag(const SCConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
1017 {
1018  DEBUG_VALIDATE_BUG_ON(conf == NULL);
1019  const char *setting = SCConfNodeLookupChildValue(conf, name);
1020  if (setting != NULL) {
1021  if (SCConfValIsTrue(setting)) {
1022  *out_flags |= flag;
1023  } else {
1024  *out_flags &= ~flag;
1025  }
1026  }
1027 }
1028 
1029 static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, SCConfNode *conf)
1030 {
1031  static bool warn_no_meta = false;
1032  uint32_t payload_buffer_size = JSON_STREAM_BUFFER_SIZE;
1033  uint16_t flags = METADATA_DEFAULTS;
1034 
1035  if (conf != NULL) {
1036  /* Check for metadata to enable/disable. */
1037  SCConfNode *metadata = SCConfNodeLookupChild(conf, "metadata");
1038  if (metadata != NULL) {
1039  if (metadata->val != NULL && SCConfValIsFalse(metadata->val)) {
1041  } else if (SCConfNodeHasChildren(metadata)) {
1042  SCConfNode *rule_metadata = SCConfNodeLookupChild(metadata, "rule");
1043  if (rule_metadata) {
1044  SetFlag(rule_metadata, "raw", LOG_JSON_RULE, &flags);
1045  SetFlag(rule_metadata, "metadata", LOG_JSON_RULE_METADATA,
1046  &flags);
1047  SetFlag(rule_metadata, "reference", LOG_JSON_REFERENCE, &flags);
1048  }
1049  SetFlag(metadata, "flow", LOG_JSON_FLOW, &flags);
1050  SetFlag(metadata, "app-layer", LOG_JSON_APP_LAYER, &flags);
1051  }
1052  }
1053 
1054  /* Non-metadata toggles. */
1055  SetFlag(conf, "payload", LOG_JSON_PAYLOAD_BASE64, &flags);
1056  SetFlag(conf, "packet", LOG_JSON_PACKET, &flags);
1057  SetFlag(conf, "tagged-packets", LOG_JSON_TAGGED_PACKETS, &flags);
1058  SetFlag(conf, "payload-printable", LOG_JSON_PAYLOAD, &flags);
1059  SetFlag(conf, "http-body-printable", LOG_JSON_HTTP_BODY, &flags);
1060  SetFlag(conf, "http-body", LOG_JSON_HTTP_BODY_BASE64, &flags);
1061  SetFlag(conf, "websocket-payload-printable", LOG_JSON_WEBSOCKET_PAYLOAD, &flags);
1062  SetFlag(conf, "websocket-payload", LOG_JSON_WEBSOCKET_PAYLOAD_BASE64, &flags);
1063  SetFlag(conf, "verdict", LOG_JSON_VERDICT, &flags);
1064  SetFlag(conf, "payload-length", LOG_JSON_PAYLOAD_LENGTH, &flags);
1065 
1066  /* Check for obsolete flags and warn that they have no effect. */
1067  static const char *deprecated_flags[] = { "http", "tls", "ssh", "smtp", "dnp3", "app-layer",
1068  "flow", NULL };
1069  for (int i = 0; deprecated_flags[i] != NULL; i++) {
1070  if (SCConfNodeLookupChildValue(conf, deprecated_flags[i]) != NULL) {
1071  SCLogWarning("Found deprecated eve-log.alert flag \"%s\", this flag has no effect",
1072  deprecated_flags[i]);
1073  }
1074  }
1075 
1076  const char *payload_buffer_value = SCConfNodeLookupChildValue(conf, "payload-buffer-size");
1077 
1078  if (payload_buffer_value != NULL) {
1079  uint32_t value;
1080  if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
1081  SCLogError("Error parsing "
1082  "payload-buffer-size - %s. Killing engine",
1083  payload_buffer_value);
1084  exit(EXIT_FAILURE);
1085  } else if (value == 0) {
1086  // you should not ask for payload if you want 0 of it
1087  SCLogError("Error payload-buffer-size should not be 0");
1088  exit(EXIT_FAILURE);
1089  } else {
1090  payload_buffer_size = value;
1091  }
1092  }
1093 
1094  if (!warn_no_meta && flags & JSON_BODY_LOGGING) {
1095  if (((flags & LOG_JSON_APP_LAYER) == 0)) {
1096  SCLogWarning("HTTP body logging has been configured, however, "
1097  "metadata logging has not been enabled. HTTP body logging will be "
1098  "disabled.");
1100  warn_no_meta = true;
1101  }
1102  }
1103  }
1104 
1105  if (flags & LOG_JSON_RULE_METADATA) {
1107  }
1108 
1109  json_output_ctx->payload_buffer_size = payload_buffer_size;
1110  json_output_ctx->flags |= flags;
1111 }
1112 
1113 static HttpXFFCfg *JsonAlertLogGetXffCfg(SCConfNode *conf)
1114 {
1115  HttpXFFCfg *xff_cfg = NULL;
1116  if (conf != NULL && SCConfNodeLookupChild(conf, "xff") != NULL) {
1117  xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
1118  if (likely(xff_cfg != NULL)) {
1119  HttpXFFGetCfg(conf, xff_cfg);
1120  }
1121  }
1122  return xff_cfg;
1123 }
1124 
1125 /**
1126  * \brief Create a new LogFileCtx for "fast" output style.
1127  * \param conf The configuration node for this output.
1128  * \return A LogFileCtx pointer on success, NULL on failure.
1129  */
1130 static OutputInitResult JsonAlertLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
1131 {
1132  OutputInitResult result = { NULL, false };
1133  OutputJsonCtx *ajt = parent_ctx->data;
1134  AlertJsonOutputCtx *json_output_ctx = NULL;
1135 
1136  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
1137  if (unlikely(output_ctx == NULL))
1138  return result;
1139 
1140  json_output_ctx = SCCalloc(1, sizeof(AlertJsonOutputCtx));
1141  if (unlikely(json_output_ctx == NULL)) {
1142  goto error;
1143  }
1144 
1145  json_output_ctx->file_ctx = ajt->file_ctx;
1146  json_output_ctx->eve_ctx = ajt;
1147 
1148  JsonAlertLogSetupMetadata(json_output_ctx, conf);
1149  json_output_ctx->xff_cfg = JsonAlertLogGetXffCfg(conf);
1150  if (json_output_ctx->xff_cfg == NULL) {
1151  json_output_ctx->parent_xff_cfg = ajt->xff_cfg;
1152  }
1153 
1154  output_ctx->data = json_output_ctx;
1155  output_ctx->DeInit = JsonAlertLogDeInitCtxSub;
1156 
1157  result.ctx = output_ctx;
1158  result.ok = true;
1159  return result;
1160 
1161 error:
1162  if (json_output_ctx != NULL) {
1163  SCFree(json_output_ctx);
1164  }
1165  if (output_ctx != NULL) {
1166  SCFree(output_ctx);
1167  }
1168 
1169  return result;
1170 }
1171 
1173 {
1174  OutputPacketLoggerFunctions output_logger_functions = {
1175  .LogFunc = JsonAlertLogger,
1176  .ConditionFunc = JsonAlertLogCondition,
1177  .ThreadInitFunc = JsonAlertLogThreadInit,
1178  .ThreadDeinitFunc = JsonAlertLogThreadDeinit,
1179  .ThreadExitPrintStatsFunc = NULL,
1180  };
1181 
1182  OutputRegisterPacketSubModule(LOGGER_JSON_ALERT, "eve-log", MODULE_NAME, "eve-log.alert",
1183  JsonAlertLogInitCtxSub, &output_logger_functions);
1184 }
SCJsonBuilder
struct SCJsonBuilder SCJsonBuilder
Definition: detect-engine-helper.h:83
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:50
PACKET_ALERT_FLAG_TX_GUESSED
#define PACKET_ALERT_FLAG_TX_GUESSED
Definition: decode.h:280
Packet_::proto
uint8_t proto
Definition: decode.h:538
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:254
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:773
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:570
XFF_EXTRADATA
#define XFF_EXTRADATA
Definition: app-layer-htp-xff.h:31
EveAddFlow
void EveAddFlow(Flow *f, SCJsonBuilder *js)
Definition: output-json-flow.c:201
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:270
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:729
AppLayerFramesGetContainer
FramesContainer * AppLayerFramesGetContainer(const Flow *f)
Definition: app-layer-parser.c:209
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1193
LOG_JSON_RULE
#define LOG_JSON_RULE
Definition: output-json-alert.c:81
Signature_::alproto
AppProto alproto
Definition: detect.h:697
DETECT_TABLE_PACKET_PRE_STREAM
@ DETECT_TABLE_PACKET_PRE_STREAM
Definition: detect.h:567
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:381
EveAddAppProto
void EveAddAppProto(Flow *f, SCJsonBuilder *js)
Definition: output-json-flow.c:181
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:87
AlertJsonStreamDataCallbackData::last_re
uint64_t last_re
Definition: output-json-alert.c:601
Packet_::payload
uint8_t * payload
Definition: decode.h:620
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:289
SIG_FLAG_DEST_IS_TARGET
#define SIG_FLAG_DEST_IS_TARGET
Definition: detect.h:288
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:562
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:359
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
LogFileCtx_
Definition: util-logopenfile.h:77
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:293
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
AlertJsonStreamDataCallbackData::payload
MemBuffer * payload
Definition: output-json-alert.c:600
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:1018
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:547
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:438
DetectFirewallPolicy::action
uint8_t action
Definition: detect.h:947
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:621
SCConfNodeHasChildren
bool SCConfNodeHasChildren(const SCConfNode *node)
Check if a node has any children.
Definition: conf.c:833
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:637
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:255
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:251
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:249
OutputJsonThreadCtx_
Definition: output-json.h:85
Signature_::gid
uint32_t gid
Definition: detect.h:742
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:274
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:257
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:239
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:51
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:769
FileContainer_::head
File * head
Definition: util-file.h:38
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PacketContextData
Definition: decode.h:242
DETECT_TABLE_PACKET_PRE_FLOW
@ DETECT_TABLE_PACKET_PRE_FLOW
Definition: detect.h:566
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:894
DETECT_TABLE_PACKET_FILTER
@ DETECT_TABLE_PACKET_FILTER
Definition: detect.h:568
DetectFirewallPolicyToString
void DetectFirewallPolicyToString(const struct DetectFirewallPolicy *p, char *out, size_t out_size)
Definition: detect-parse.c:4203
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:733
Signature_::action
uint8_t action
Definition: detect.h:707
SCEveJsonSimpleGetLogger
EveJsonSimpleAppLayerLogger * SCEveJsonSimpleGetLogger(AppProto alproto)
Definition: output.c:923
Signature_::flags
uint32_t flags
Definition: detect.h:693
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:516
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:290
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:286
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-bindgen.h:42
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:272
PACKET_ALERT_FLAG_FRAME
#define PACKET_ALERT_FLAG_FRAME
Definition: decode.h:278
log-pcap.h
PacketAlert_::frame_id
int64_t frame_id
Definition: decode.h:256
JsonAddrInfo_::proto
char proto[JSON_PROTO_LEN]
Definition: output-json.h:46
Signature_::class_msg
char * class_msg
Definition: detect.h:767
PacketAlert_::flags
uint8_t flags
Definition: decode.h:252
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:253
OutputInitResult_
Definition: output.h:46
app-layer-frames.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:678
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-bindgen.h:43
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:714
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:61
Signature_::rev
uint32_t rev
Definition: detect.h:743
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:297
PacketContextData::next
struct PacketContextData * next
Definition: decode.h:244
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:744
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:666
TcpSession_::server
TcpStream server
Definition: stream-tcp-private.h:296
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:549
PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED
#define PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED
Definition: decode.h:276
HttpXFFCfg_::flags
uint8_t flags
Definition: app-layer-htp-xff.h:42
Signature_::metadata
DetectMetadataHead * metadata
Definition: detect.h:771
DetectFirewallPolicy
Definition: detect.h:946
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:626
DetectReference_::key
char * key
Definition: detect-reference.h:32
util-logopenfile.h
Flow_::alstate
void * alstate
Definition: flow.h:484
Signature_::id
uint32_t id
Definition: detect.h:741
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:541
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:692
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:274
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:249
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:130
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-eve-bindgen.h:34
Signature_::detect_table
uint8_t detect_table
Definition: detect.h:726
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:1273
PacketContextData::json_string
char * json_string
Definition: decode.h:243
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:283
output-json-http.h
util-misc.h
PKT_HAS_TAG
#define PKT_HAS_TAG
Definition: decode.h:1303
Signature_::msg
char * msg
Definition: detect.h:764
flow.h
DetectEngineSetParseMetadata
void DetectEngineSetParseMetadata(void)
Definition: detect-engine.c:5283
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:455
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:1977
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:1172
f
Flow f
Definition: fuzz_dataset.c:32
AlertJsonStreamDataCallbackData
Definition: output-json-alert.c:599