suricata
output-json-dns.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 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  * Implements JSON DNS logging portion of the engine.
24  */
25 
26 #include "suricata-common.h"
27 #include "conf.h"
28 
29 #include "threadvars.h"
30 
31 #include "util-byte.h"
32 #include "util-debug.h"
33 #include "app-layer-parser.h"
34 #include "output.h"
35 #include "decode.h"
36 
37 #include "output-json.h"
38 #include "output-json-dns.h"
39 #include "rust.h"
40 
41 #define LOG_QUERIES BIT_U64(0)
42 #define LOG_ANSWERS BIT_U64(1)
43 
44 #define LOG_A BIT_U64(2)
45 #define LOG_NS BIT_U64(3)
46 #define LOG_MD BIT_U64(4)
47 #define LOG_MF BIT_U64(5)
48 #define LOG_CNAME BIT_U64(6)
49 #define LOG_SOA BIT_U64(7)
50 #define LOG_MB BIT_U64(8)
51 #define LOG_MG BIT_U64(9)
52 #define LOG_MR BIT_U64(10)
53 #define LOG_NULL BIT_U64(11)
54 #define LOG_WKS BIT_U64(12)
55 #define LOG_PTR BIT_U64(13)
56 #define LOG_HINFO BIT_U64(14)
57 #define LOG_MINFO BIT_U64(15)
58 #define LOG_MX BIT_U64(16)
59 #define LOG_TXT BIT_U64(17)
60 #define LOG_RP BIT_U64(18)
61 #define LOG_AFSDB BIT_U64(19)
62 #define LOG_X25 BIT_U64(20)
63 #define LOG_ISDN BIT_U64(21)
64 #define LOG_RT BIT_U64(22)
65 #define LOG_NSAP BIT_U64(23)
66 #define LOG_NSAPPTR BIT_U64(24)
67 #define LOG_SIG BIT_U64(25)
68 #define LOG_KEY BIT_U64(26)
69 #define LOG_PX BIT_U64(27)
70 #define LOG_GPOS BIT_U64(28)
71 #define LOG_AAAA BIT_U64(29)
72 #define LOG_LOC BIT_U64(30)
73 #define LOG_NXT BIT_U64(31)
74 #define LOG_SRV BIT_U64(32)
75 #define LOG_ATMA BIT_U64(33)
76 #define LOG_NAPTR BIT_U64(34)
77 #define LOG_KX BIT_U64(35)
78 #define LOG_CERT BIT_U64(36)
79 #define LOG_A6 BIT_U64(37)
80 #define LOG_DNAME BIT_U64(38)
81 #define LOG_OPT BIT_U64(39)
82 #define LOG_APL BIT_U64(40)
83 #define LOG_DS BIT_U64(41)
84 #define LOG_SSHFP BIT_U64(42)
85 #define LOG_IPSECKEY BIT_U64(43)
86 #define LOG_RRSIG BIT_U64(44)
87 #define LOG_NSEC BIT_U64(45)
88 #define LOG_DNSKEY BIT_U64(46)
89 #define LOG_DHCID BIT_U64(47)
90 #define LOG_NSEC3 BIT_U64(48)
91 #define LOG_NSEC3PARAM BIT_U64(49)
92 #define LOG_TLSA BIT_U64(50)
93 #define LOG_HIP BIT_U64(51)
94 #define LOG_CDS BIT_U64(52)
95 #define LOG_CDNSKEY BIT_U64(53)
96 #define LOG_SPF BIT_U64(54)
97 #define LOG_TKEY BIT_U64(55)
98 #define LOG_TSIG BIT_U64(56)
99 #define LOG_MAILA BIT_U64(57)
100 #define LOG_ANY BIT_U64(58)
101 #define LOG_URI BIT_U64(59)
102 
103 #define LOG_FORMAT_GROUPED BIT_U64(60)
104 #define LOG_FORMAT_DETAILED BIT_U64(61)
105 #define LOG_HTTPS BIT_U64(62)
106 
107 #define LOG_FORMAT_ALL (LOG_FORMAT_GROUPED|LOG_FORMAT_DETAILED)
108 #define LOG_ALL_RRTYPES (~(uint64_t)(LOG_QUERIES|LOG_ANSWERS|LOG_FORMAT_DETAILED|LOG_FORMAT_GROUPED))
109 
110 typedef enum {
171 } DnsRRTypes;
172 
173 static struct {
174  const char *config_rrtype;
175  uint64_t flags;
176 } dns_rrtype_fields[] = {
177  // clang-format off
178  { "a", LOG_A },
179  { "ns", LOG_NS },
180  { "md", LOG_MD },
181  { "mf", LOG_MF },
182  { "cname", LOG_CNAME },
183  { "soa", LOG_SOA },
184  { "mb", LOG_MB },
185  { "mg", LOG_MG },
186  { "mr", LOG_MR },
187  { "null", LOG_NULL },
188  { "wks", LOG_WKS },
189  { "ptr", LOG_PTR },
190  { "hinfo", LOG_HINFO },
191  { "minfo", LOG_MINFO },
192  { "mx", LOG_MX },
193  { "txt", LOG_TXT },
194  { "rp", LOG_RP },
195  { "afsdb", LOG_AFSDB },
196  { "x25", LOG_X25 },
197  { "isdn", LOG_ISDN },
198  { "rt", LOG_RT },
199  { "nsap", LOG_NSAP },
200  { "nsapptr", LOG_NSAPPTR },
201  { "sig", LOG_SIG },
202  { "key", LOG_KEY },
203  { "px", LOG_PX },
204  { "gpos", LOG_GPOS },
205  { "aaaa", LOG_AAAA },
206  { "loc", LOG_LOC },
207  { "nxt", LOG_NXT },
208  { "srv", LOG_SRV },
209  { "atma", LOG_ATMA },
210  { "naptr", LOG_NAPTR },
211  { "kx", LOG_KX },
212  { "cert", LOG_CERT },
213  { "a6", LOG_A6 },
214  { "dname", LOG_DNAME },
215  { "opt", LOG_OPT },
216  { "apl", LOG_APL },
217  { "ds", LOG_DS },
218  { "sshfp", LOG_SSHFP },
219  { "ipseckey", LOG_IPSECKEY },
220  { "rrsig", LOG_RRSIG },
221  { "nsec", LOG_NSEC },
222  { "dnskey", LOG_DNSKEY },
223  { "dhcid", LOG_DHCID },
224  { "nsec3", LOG_NSEC3 },
225  { "nsec3param", LOG_NSEC3PARAM },
226  { "tlsa", LOG_TLSA },
227  { "hip", LOG_HIP },
228  { "cds", LOG_CDS },
229  { "cdnskey", LOG_CDNSKEY },
230  { "https", LOG_HTTPS },
231  { "spf", LOG_SPF },
232  { "tkey", LOG_TKEY },
233  { "tsig", LOG_TSIG },
234  { "maila", LOG_MAILA },
235  { "any", LOG_ANY },
236  { "uri", LOG_URI }
237  // clang-format on
238 };
239 
240 typedef struct LogDnsFileCtx_ {
241  uint64_t flags; /** Store mode */
243  uint8_t version;
245 
246 typedef struct LogDnsLogThread_ {
250 
251 bool AlertJsonDns(void *txptr, SCJsonBuilder *js)
252 {
253  return SCDnsLogJson(
255 }
256 
257 bool AlertJsonDoh2(void *txptr, SCJsonBuilder *js)
258 {
259  SCJsonBuilderMark mark = { 0, 0, 0 };
260 
261  SCJbGetMark(js, &mark);
262  // first log HTTP2 part
263  bool r = SCHttp2LogJson(txptr, js);
264  if (!r) {
265  SCJbRestoreMark(js, &mark);
266  }
267  // then log one DNS tx if any, preferring the answer
268  void *tx_dns = DetectGetInnerTx(txptr, ALPROTO_DOH2, ALPROTO_DOH2, STREAM_TOCLIENT);
269  if (tx_dns == NULL) {
270  tx_dns = DetectGetInnerTx(txptr, ALPROTO_DOH2, ALPROTO_DOH2, STREAM_TOSERVER);
271  }
272  bool r2 = false;
273  if (tx_dns) {
274  SCJbGetMark(js, &mark);
275  r2 = AlertJsonDns(tx_dns, js);
276  if (!r2) {
277  SCJbRestoreMark(js, &mark);
278  }
279  }
280  return r || r2;
281 }
282 
283 static int JsonDoh2Logger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f,
284  void *alstate, void *txptr, uint64_t tx_id)
285 {
286  LogDnsLogThread *td = (LogDnsLogThread *)thread_data;
287  LogDnsFileCtx *dnslog_ctx = td->dnslog_ctx;
288 
289  void *tx_dns = DetectGetInnerTx(txptr, ALPROTO_DOH2, ALPROTO_DOH2, STREAM_TOCLIENT);
290  if (tx_dns == NULL) {
291  tx_dns = DetectGetInnerTx(txptr, ALPROTO_DOH2, ALPROTO_DOH2, STREAM_TOSERVER);
292  }
293 
294  /* DOH2 is always logged in flow direction, as its driven by the scope of an
295  * HTTP transation */
296  SCJsonBuilder *jb =
297  CreateEveHeader(p, LOG_DIR_FLOW, tx_dns ? "dns" : "http", NULL, dnslog_ctx->eve_ctx);
298 
299  if (unlikely(jb == NULL)) {
300  return TM_ECODE_OK;
301  }
302 
303  SCJsonBuilderMark mark = { 0, 0, 0 };
304 
305  SCJbGetMark(jb, &mark);
306  // first log HTTP2 part
307  bool r = SCHttp2LogJson(txptr, jb);
308  if (!r) {
309  SCJbRestoreMark(jb, &mark);
310  }
311 
312  bool r2 = false;
313  if (tx_dns) {
314  // mix of JsonDnsLogger
315  if (SCDnsTxIsRequest(tx_dns)) {
316  if (unlikely(dnslog_ctx->flags & LOG_QUERIES) == 0) {
317  goto out;
318  }
319  } else if (SCDnsTxIsResponse(tx_dns)) {
320  if (unlikely(dnslog_ctx->flags & LOG_ANSWERS) == 0) {
321  goto out;
322  }
323  }
324 
325  if (!SCDnsLogEnabled(tx_dns, td->dnslog_ctx->flags)) {
326  goto out;
327  }
328 
329  SCJbGetMark(jb, &mark);
330  // log DOH2 with DNS config
331  r2 = SCDnsLogJson(tx_dns, td->dnslog_ctx->flags, jb);
332  if (!r2) {
333  SCJbRestoreMark(jb, &mark);
334  }
335  }
336 out:
337  if (r || r2) {
338  OutputJsonBuilderBuffer(tv, p, p->flow, jb, td->ctx);
339  }
340  SCJbFree(jb);
341  return TM_ECODE_OK;
342 }
343 
344 static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
345  const Packet *p, Flow *f, void *alstate, void *txptr, uint64_t tx_id)
346 {
347  SCEnter();
348 
349  LogDnsLogThread *td = (LogDnsLogThread *)thread_data;
350  LogDnsFileCtx *dnslog_ctx = td->dnslog_ctx;
351 
352  if (unlikely(dnslog_ctx->flags & LOG_QUERIES) == 0) {
353  return TM_ECODE_OK;
354  }
355 
356  for (uint16_t i = 0; i < 0xffff; i++) {
357  SCJsonBuilder *jb = CreateEveHeader(p, LOG_DIR_FLOW, "dns", NULL, dnslog_ctx->eve_ctx);
358  if (unlikely(jb == NULL)) {
359  return TM_ECODE_OK;
360  }
361 
362  SCJbOpenObject(jb, "dns");
363  SCJbSetInt(jb, "version", 2);
364  if (!SCDnsLogJsonQuery(txptr, i, td->dnslog_ctx->flags, jb)) {
365  SCJbFree(jb);
366  break;
367  }
368  SCJbClose(jb);
369 
370  OutputJsonBuilderBuffer(tv, p, p->flow, jb, td->ctx);
371  SCJbFree(jb);
372  }
373 
375 }
376 
377 static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
378  const Packet *p, Flow *f, void *alstate, void *txptr, uint64_t tx_id)
379 {
380  SCEnter();
381 
382  LogDnsLogThread *td = (LogDnsLogThread *)thread_data;
383  LogDnsFileCtx *dnslog_ctx = td->dnslog_ctx;
384 
385  if (unlikely(dnslog_ctx->flags & LOG_ANSWERS) == 0) {
386  return TM_ECODE_OK;
387  }
388 
389  if (SCDnsLogAnswerEnabled(txptr, td->dnslog_ctx->flags)) {
390  SCJsonBuilder *jb = CreateEveHeader(p, LOG_DIR_FLOW, "dns", NULL, dnslog_ctx->eve_ctx);
391  if (unlikely(jb == NULL)) {
392  return TM_ECODE_OK;
393  }
394 
395  SCJbOpenObject(jb, "dns");
396  SCJbSetInt(jb, "version", 2);
397  SCDnsLogJsonAnswer(txptr, td->dnslog_ctx->flags, jb);
398  SCJbClose(jb);
399  OutputJsonBuilderBuffer(tv, p, p->flow, jb, td->ctx);
400  SCJbFree(jb);
401  }
402 
404 }
405 
406 static int JsonDnsLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *alstate,
407  void *txptr, uint64_t tx_id)
408 {
409  LogDnsLogThread *td = (LogDnsLogThread *)thread_data;
410  LogDnsFileCtx *dnslog_ctx = td->dnslog_ctx;
411 
412  if (dnslog_ctx->version == DNS_LOG_VERSION_2) {
413  if (SCDnsTxIsRequest(txptr)) {
414  return JsonDnsLoggerToServer(tv, thread_data, p, f, alstate, txptr, tx_id);
415  } else if (SCDnsTxIsResponse(txptr)) {
416  return JsonDnsLoggerToClient(tv, thread_data, p, f, alstate, txptr, tx_id);
417  }
418  } else {
419  if (SCDnsTxIsRequest(txptr)) {
420  if (unlikely(dnslog_ctx->flags & LOG_QUERIES) == 0) {
421  return TM_ECODE_OK;
422  }
423  } else if (SCDnsTxIsResponse(txptr)) {
424  if (unlikely(dnslog_ctx->flags & LOG_ANSWERS) == 0) {
425  return TM_ECODE_OK;
426  }
427  }
428 
429  if (!SCDnsLogEnabled(txptr, td->dnslog_ctx->flags)) {
430  return TM_ECODE_OK;
431  }
432 
433  /* If UDP we can rely on the packet direction. */
435 
436  /* If not UDP we have to query the transaction for direction, which
437  * could be wrong - this is a bit of a hack. */
438  if (PacketIsTCP(p)) {
439  if (SCDnsTxIsRequest(txptr)) {
440  dir = LOG_DIR_FLOW_TOSERVER;
441  } else {
442  dir = LOG_DIR_FLOW_TOCLIENT;
443  }
444  }
445 
446  SCJsonBuilder *jb = CreateEveHeader(p, dir, "dns", NULL, dnslog_ctx->eve_ctx);
447  if (unlikely(jb == NULL)) {
448  return TM_ECODE_OK;
449  }
450 
451  if (SCDnsLogJson(txptr, td->dnslog_ctx->flags, jb)) {
452  OutputJsonBuilderBuffer(tv, p, p->flow, jb, td->ctx);
453  }
454  SCJbFree(jb);
455  }
456  return TM_ECODE_OK;
457 }
458 
459 static TmEcode LogDnsLogThreadInit(ThreadVars *t, const void *initdata, void **data)
460 {
461  LogDnsLogThread *aft = SCCalloc(1, sizeof(LogDnsLogThread));
462  if (unlikely(aft == NULL))
463  return TM_ECODE_FAILED;
464 
465  if(initdata == NULL)
466  {
467  SCLogDebug("Error getting context for EveLogDNS. \"initdata\" argument NULL");
468  goto error_exit;
469  }
470 
471  /* Use the Output Context (file pointer and mutex) */
472  aft->dnslog_ctx = ((OutputCtx *)initdata)->data;
473  aft->ctx = CreateEveThreadCtx(t, aft->dnslog_ctx->eve_ctx);
474  if (!aft->ctx) {
475  goto error_exit;
476  }
477 
478  *data = (void *)aft;
479  return TM_ECODE_OK;
480 
481 error_exit:
482  SCFree(aft);
483  return TM_ECODE_FAILED;
484 }
485 
486 static TmEcode LogDnsLogThreadDeinit(ThreadVars *t, void *data)
487 {
488  LogDnsLogThread *aft = (LogDnsLogThread *)data;
489  if (aft == NULL) {
490  return TM_ECODE_OK;
491  }
492  FreeEveThreadCtx(aft->ctx);
493 
494  /* clear memory */
495  memset(aft, 0, sizeof(LogDnsLogThread));
496 
497  SCFree(aft);
498  return TM_ECODE_OK;
499 }
500 
501 static void LogDnsLogDeInitCtxSub(OutputCtx *output_ctx)
502 {
503  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
504  LogDnsFileCtx *dnslog_ctx = (LogDnsFileCtx *)output_ctx->data;
505  SCFree(dnslog_ctx);
506  SCFree(output_ctx);
507 }
508 
509 static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, SCConfNode *conf,
510  const char *query_key, const char *answer_key, const char *answer_types_key)
511 {
512  const char *query = SCConfNodeLookupChildValue(conf, query_key);
513  if (query != NULL) {
514  if (SCConfValIsTrue(query)) {
515  dnslog_ctx->flags |= LOG_QUERIES;
516  } else {
517  dnslog_ctx->flags &= ~LOG_QUERIES;
518  }
519  } else {
520  dnslog_ctx->flags |= LOG_QUERIES;
521  }
522 
523  const char *response = SCConfNodeLookupChildValue(conf, answer_key);
524  if (response != NULL) {
525  if (SCConfValIsTrue(response)) {
526  dnslog_ctx->flags |= LOG_ANSWERS;
527  } else {
528  dnslog_ctx->flags &= ~LOG_ANSWERS;
529  }
530  } else {
531  dnslog_ctx->flags |= LOG_ANSWERS;
532  }
533 
534  SCConfNode *custom;
535  if ((custom = SCConfNodeLookupChild(conf, answer_types_key)) != NULL) {
536  dnslog_ctx->flags &= ~LOG_ALL_RRTYPES;
537  SCConfNode *field;
538  TAILQ_FOREACH (field, &custom->head, next) {
539  DnsRRTypes f;
540  for (f = DNS_RRTYPE_A; f < DNS_RRTYPE_MAX; f++) {
541  if (strcasecmp(dns_rrtype_fields[f].config_rrtype, field->val) == 0) {
542  dnslog_ctx->flags |= dns_rrtype_fields[f].flags;
543  break;
544  }
545  }
546  }
547  } else {
548  dnslog_ctx->flags |= LOG_ALL_RRTYPES;
549  }
550 }
551 
552 static uint8_t GetDnsLogVersion(SCConfNode *conf)
553 {
554  if (conf == NULL) {
555  return DNS_LOG_VERSION_DEFAULT;
556  }
557 
558  char *version_string = NULL;
559  const SCConfNode *version_node = SCConfNodeLookupChild(conf, "version");
560  if (version_node != NULL) {
561  version_string = version_node->val;
562  }
563 
564  if (version_string == NULL) {
565  version_string = getenv("SURICATA_EVE_DNS_VERSION");
566  }
567 
568  if (version_string == NULL) {
569  return DNS_LOG_VERSION_DEFAULT;
570  }
571 
572  uint8_t version;
573  if (StringParseUint8(&version, 10, 0, version_string) > 0) {
574  return version;
575  }
576  SCLogWarning("Failed to parse EVE DNS log version of \"%s\"", version_string);
577  return DNS_LOG_VERSION_DEFAULT;
578 }
579 
580 static uint8_t JsonDnsCheckVersion(SCConfNode *conf)
581 {
582  const uint8_t default_version = DNS_LOG_VERSION_DEFAULT;
583  const uint8_t version = GetDnsLogVersion(conf);
584  static bool v1_deprecation_warned = false;
585  static bool v2_deprecation_warned = false;
586 
587  switch (version) {
588  case 3:
589  return DNS_LOG_VERSION_3;
590  case 2:
591  if (!v2_deprecation_warned) {
592  SCLogNotice("DNS EVE v2 logging has been deprecated and will be removed in "
593  "Suricata 9.0");
594  v2_deprecation_warned = true;
595  }
596  return DNS_LOG_VERSION_2;
597  case 1:
598  if (!v1_deprecation_warned) {
599  SCLogWarning("DNS EVE v1 logging has been removed, will use v2");
600  v1_deprecation_warned = true;
601  }
602  return default_version;
603  default:
604  SCLogWarning(
605  "Invalid EVE DNS version %d, will use v%d", version, DNS_LOG_VERSION_DEFAULT);
606  return default_version;
607  }
608 
609  return default_version;
610 }
611 
612 static void JsonDnsLogInitFilters(LogDnsFileCtx *dnslog_ctx, SCConfNode *conf)
613 {
614  dnslog_ctx->flags = ~0ULL;
615 
616  if (conf) {
617  JsonDnsLogParseConfig(dnslog_ctx, conf, "requests", "responses", "types");
618  if (dnslog_ctx->flags & LOG_ANSWERS) {
619  SCConfNode *format;
620  if ((format = SCConfNodeLookupChild(conf, "formats")) != NULL) {
621  uint64_t flags = 0;
622  SCConfNode *field;
623  TAILQ_FOREACH (field, &format->head, next) {
624  if (strcasecmp(field->val, "detailed") == 0) {
626  } else if (strcasecmp(field->val, "grouped") == 0) {
628  } else {
629  SCLogWarning("Invalid JSON DNS log format: %s", field->val);
630  }
631  }
632  if (flags) {
633  dnslog_ctx->flags &= ~LOG_FORMAT_ALL;
634  dnslog_ctx->flags |= flags;
635  } else {
636  SCLogWarning("Empty EVE DNS format array, using defaults");
637  }
638  } else {
639  dnslog_ctx->flags |= LOG_FORMAT_ALL;
640  }
641  }
642  }
643 }
644 
645 static OutputInitResult JsonDnsLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
646 {
647  OutputInitResult result = { NULL, false };
648  const char *enabled = SCConfNodeLookupChildValue(conf, "enabled");
649  if (enabled != NULL && !SCConfValIsTrue(enabled)) {
650  result.ok = true;
651  return result;
652  }
653 
654  OutputJsonCtx *ojc = parent_ctx->data;
655 
656  LogDnsFileCtx *dnslog_ctx = SCCalloc(1, sizeof(LogDnsFileCtx));
657  if (unlikely(dnslog_ctx == NULL)) {
658  return result;
659  }
660 
661  dnslog_ctx->eve_ctx = ojc;
662  dnslog_ctx->version = JsonDnsCheckVersion(conf);
663 
664  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
665  if (unlikely(output_ctx == NULL)) {
666  SCFree(dnslog_ctx);
667  return result;
668  }
669 
670  output_ctx->data = dnslog_ctx;
671  output_ctx->DeInit = LogDnsLogDeInitCtxSub;
672 
673  JsonDnsLogInitFilters(dnslog_ctx, conf);
674 
675  SCLogDebug("DNS log sub-module initialized");
676 
679 
680  result.ctx = output_ctx;
681  result.ok = true;
682  return result;
683 }
684 
685 
686 #define MODULE_NAME "JsonDnsLog"
688 {
689  OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", MODULE_NAME, "eve-log.dns",
690  JsonDnsLogInitCtxSub, ALPROTO_DNS, JsonDnsLogger, LogDnsLogThreadInit,
691  LogDnsLogThreadDeinit);
692 }
693 
695 {
696  OutputRegisterTxSubModuleWithProgressSubState(LOGGER_JSON_TX, "eve-log", "JsonDoH2Log::stream",
697  "eve-log.doh2", JsonDnsLogInitCtxSub, ALPROTO_DOH2, HTTP2TxTypeStream, JsonDoh2Logger,
698  HTTP2ProgData, HTTP2ProgData, LogDnsLogThreadInit, LogDnsLogThreadDeinit);
699  OutputRegisterTxSubModuleWithProgressSubState(LOGGER_JSON_TX, "eve-log", "LogDoh2Log::global",
700  "eve-log.doh2", JsonDnsLogInitCtxSub, ALPROTO_DOH2, HTTP2TxTypeGlobal, JsonDoh2Logger,
701  HTTP2ProgGlobalComplete, HTTP2ProgGlobalComplete, LogDnsLogThreadInit,
702  LogDnsLogThreadDeinit);
703 }
SCJsonBuilder
struct SCJsonBuilder SCJsonBuilder
Definition: detect-engine-helper.h:83
DNS_RRTYPE_PX
@ DNS_RRTYPE_PX
Definition: output-json-dns.c:136
util-byte.h
DNS_RRTYPE_AAAA
@ DNS_RRTYPE_AAAA
Definition: output-json-dns.c:138
DNS_RRTYPE_GPOS
@ DNS_RRTYPE_GPOS
Definition: output-json-dns.c:137
SCOutputJsonLogDirection
SCOutputJsonLogDirection
Definition: output-eve-bindgen.h:33
LOG_MR
#define LOG_MR
Definition: output-json-dns.c:52
SCConfValIsTrue
int SCConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:577
DNS_RRTYPE_TKEY
@ DNS_RRTYPE_TKEY
Definition: output-json-dns.c:165
DNS_RRTYPE_ANY
@ DNS_RRTYPE_ANY
Definition: output-json-dns.c:168
JsonDoh2LogRegister
void JsonDoh2LogRegister(void)
Definition: output-json-dns.c:694
LOG_NULL
#define LOG_NULL
Definition: output-json-dns.c:53
LOG_NSEC3PARAM
#define LOG_NSEC3PARAM
Definition: output-json-dns.c:91
DNS_RRTYPE_OPT
@ DNS_RRTYPE_OPT
Definition: output-json-dns.c:148
LOG_NSEC
#define LOG_NSEC
Definition: output-json-dns.c:87
LOG_RP
#define LOG_RP
Definition: output-json-dns.c:60
LOG_GPOS
#define LOG_GPOS
Definition: output-json-dns.c:70
DNS_RRTYPE_NULL
@ DNS_RRTYPE_NULL
Definition: output-json-dns.c:120
ALPROTO_DNS
@ ALPROTO_DNS
Definition: app-layer-protos.h:47
MODULE_NAME
#define MODULE_NAME
Definition: output-json-dns.c:686
DNS_RRTYPE_MX
@ DNS_RRTYPE_MX
Definition: output-json-dns.c:125
DNS_RRTYPE_HIP
@ DNS_RRTYPE_HIP
Definition: output-json-dns.c:160
LOG_NXT
#define LOG_NXT
Definition: output-json-dns.c:73
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DNS_RRTYPE_LOC
@ DNS_RRTYPE_LOC
Definition: output-json-dns.c:139
LOG_TLSA
#define LOG_TLSA
Definition: output-json-dns.c:92
DNS_RRTYPE_NS
@ DNS_RRTYPE_NS
Definition: output-json-dns.c:112
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
DNS_RRTYPE_MAX
@ DNS_RRTYPE_MAX
Definition: output-json-dns.c:170
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
DNS_RRTYPE_X25
@ DNS_RRTYPE_X25
Definition: output-json-dns.c:129
CreateEveHeader
SCJsonBuilder * CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
Definition: output-json.c:816
DnsRRTypes
DnsRRTypes
Definition: output-json-dns.c:110
OutputRegisterTxSubModuleWithProgressSubState
void OutputRegisterTxSubModuleWithProgressSubState(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, const uint8_t sub_state, TxLogger TxLogFunc, uint8_t tc_log_progress, uint8_t ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Definition: output.c:386
LOG_TKEY
#define LOG_TKEY
Definition: output-json-dns.c:97
OutputJsonCtx_
Definition: output-json.h:77
Flow_
Flow data structure.
Definition: flow.h:359
DNS_RRTYPE_TSIG
@ DNS_RRTYPE_TSIG
Definition: output-json-dns.c:166
AlertJsonDns
bool AlertJsonDns(void *txptr, SCJsonBuilder *js)
Definition: output-json-dns.c:251
DNS_RRTYPE_HTTPS
@ DNS_RRTYPE_HTTPS
Definition: output-json-dns.c:163
LOG_LOC
#define LOG_LOC
Definition: output-json-dns.c:72
LOG_TSIG
#define LOG_TSIG
Definition: output-json-dns.c:98
LOG_APL
#define LOG_APL
Definition: output-json-dns.c:82
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:252
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
OutputRegisterTxSubModule
void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Definition: output.c:411
LOG_DNSKEY
#define LOG_DNSKEY
Definition: output-json-dns.c:88
rust.h
DNS_RRTYPE_DHCID
@ DNS_RRTYPE_DHCID
Definition: output-json-dns.c:156
LOG_DNAME
#define LOG_DNAME
Definition: output-json-dns.c:80
LOG_DIR_FLOW_TOSERVER
@ LOG_DIR_FLOW_TOSERVER
Definition: output-eve-bindgen.h:37
LOG_ANSWERS
#define LOG_ANSWERS
Definition: output-json-dns.c:42
LOG_NSEC3
#define LOG_NSEC3
Definition: output-json-dns.c:90
p
Packet * p
Definition: fuzz_dataset.c:30
LOG_DS
#define LOG_DS
Definition: output-json-dns.c:83
OutputJsonBuilderBuffer
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:1018
LOG_MAILA
#define LOG_MAILA
Definition: output-json-dns.c:99
LOG_NS
#define LOG_NS
Definition: output-json-dns.c:45
SCConfNodeLookupChildValue
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:877
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
LOG_CERT
#define LOG_CERT
Definition: output-json-dns.c:78
DNS_RRTYPE_SPF
@ DNS_RRTYPE_SPF
Definition: output-json-dns.c:164
DNS_RRTYPE_WKS
@ DNS_RRTYPE_WKS
Definition: output-json-dns.c:121
LogDnsFileCtx_::flags
uint64_t flags
Definition: output-json-dns.c:241
LOG_MD
#define LOG_MD
Definition: output-json-dns.c:46
LOG_SOA
#define LOG_SOA
Definition: output-json-dns.c:49
LOG_NAPTR
#define LOG_NAPTR
Definition: output-json-dns.c:76
LOG_WKS
#define LOG_WKS
Definition: output-json-dns.c:54
LOG_CDS
#define LOG_CDS
Definition: output-json-dns.c:94
OutputCtx_::data
void * data
Definition: tm-modules.h:91
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
OutputCtx_
Definition: tm-modules.h:88
LOG_URI
#define LOG_URI
Definition: output-json-dns.c:101
LOG_SRV
#define LOG_SRV
Definition: output-json-dns.c:74
OutputJsonThreadCtx_
Definition: output-json.h:85
LOG_HINFO
#define LOG_HINFO
Definition: output-json-dns.c:56
DNS_RRTYPE_URI
@ DNS_RRTYPE_URI
Definition: output-json-dns.c:169
LogDnsFileCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-dns.c:242
StringParseUint8
int StringParseUint8(uint8_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:322
DNS_RRTYPE_HINFO
@ DNS_RRTYPE_HINFO
Definition: output-json-dns.c:123
DNS_RRTYPE_NSEC
@ DNS_RRTYPE_NSEC
Definition: output-json-dns.c:154
LOG_ATMA
#define LOG_ATMA
Definition: output-json-dns.c:75
LOG_KEY
#define LOG_KEY
Definition: output-json-dns.c:68
LOG_ALL_RRTYPES
#define LOG_ALL_RRTYPES
Definition: output-json-dns.c:108
decode.h
util-debug.h
DNS_RRTYPE_MF
@ DNS_RRTYPE_MF
Definition: output-json-dns.c:114
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
LOG_MINFO
#define LOG_MINFO
Definition: output-json-dns.c:57
LOG_SIG
#define LOG_SIG
Definition: output-json-dns.c:67
DNS_RRTYPE_RP
@ DNS_RRTYPE_RP
Definition: output-json-dns.c:127
SCAppLayerParserRegisterLogger
void SCAppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:535
output-json.h
LOG_KX
#define LOG_KX
Definition: output-json-dns.c:77
LOG_A
#define LOG_A
Definition: output-json-dns.c:44
LOG_MF
#define LOG_MF
Definition: output-json-dns.c:47
DNS_RRTYPE_CDNSKEY
@ DNS_RRTYPE_CDNSKEY
Definition: output-json-dns.c:162
LogDnsLogThread_
Definition: output-json-dns.c:246
DNS_RRTYPE_IPSECKEY
@ DNS_RRTYPE_IPSECKEY
Definition: output-json-dns.c:152
DNS_RRTYPE_KEY
@ DNS_RRTYPE_KEY
Definition: output-json-dns.c:135
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
DNS_RRTYPE_NSEC3PARAM
@ DNS_RRTYPE_NSEC3PARAM
Definition: output-json-dns.c:158
LOG_RT
#define LOG_RT
Definition: output-json-dns.c:64
LogDnsLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-dns.c:248
LOG_SSHFP
#define LOG_SSHFP
Definition: output-json-dns.c:84
OutputInitResult_::ok
bool ok
Definition: output.h:48
DNS_RRTYPE_A
@ DNS_RRTYPE_A
Definition: output-json-dns.c:111
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
LOG_DIR_FLOW
@ LOG_DIR_FLOW
Definition: output-eve-bindgen.h:35
DNS_RRTYPE_DNAME
@ DNS_RRTYPE_DNAME
Definition: output-json-dns.c:147
app-layer-parser.h
DNS_RRTYPE_RRSIG
@ DNS_RRTYPE_RRSIG
Definition: output-json-dns.c:153
DNS_RRTYPE_DS
@ DNS_RRTYPE_DS
Definition: output-json-dns.c:150
LOG_RRSIG
#define LOG_RRSIG
Definition: output-json-dns.c:86
LOG_MG
#define LOG_MG
Definition: output-json-dns.c:51
DNS_RRTYPE_MAILA
@ DNS_RRTYPE_MAILA
Definition: output-json-dns.c:167
DNS_RRTYPE_TXT
@ DNS_RRTYPE_TXT
Definition: output-json-dns.c:126
Packet_
Definition: decode.h:516
DNS_RRTYPE_AFSDB
@ DNS_RRTYPE_AFSDB
Definition: output-json-dns.c:128
DNS_RRTYPE_ATMA
@ DNS_RRTYPE_ATMA
Definition: output-json-dns.c:142
DNS_RRTYPE_KX
@ DNS_RRTYPE_KX
Definition: output-json-dns.c:144
DNS_RRTYPE_PTR
@ DNS_RRTYPE_PTR
Definition: output-json-dns.c:122
conf.h
DNS_RRTYPE_NSAP
@ DNS_RRTYPE_NSAP
Definition: output-json-dns.c:132
LOG_ANY
#define LOG_ANY
Definition: output-json-dns.c:100
TmEcode
TmEcode
Definition: tm-threads-common.h:80
ALPROTO_DOH2
@ ALPROTO_DOH2
Definition: app-layer-protos.h:66
LOG_MB
#define LOG_MB
Definition: output-json-dns.c:50
LogDnsFileCtx_
Definition: output-json-dns.c:240
LOG_PTR
#define LOG_PTR
Definition: output-json-dns.c:55
DNS_RRTYPE_ISDN
@ DNS_RRTYPE_ISDN
Definition: output-json-dns.c:130
DNS_RRTYPE_TLSA
@ DNS_RRTYPE_TLSA
Definition: output-json-dns.c:159
DNS_RRTYPE_NSEC3
@ DNS_RRTYPE_NSEC3
Definition: output-json-dns.c:157
LOG_HTTPS
#define LOG_HTTPS
Definition: output-json-dns.c:105
DNS_RRTYPE_A6
@ DNS_RRTYPE_A6
Definition: output-json-dns.c:146
DNS_RRTYPE_CERT
@ DNS_RRTYPE_CERT
Definition: output-json-dns.c:145
LOG_HIP
#define LOG_HIP
Definition: output-json-dns.c:93
SCConfNodeLookupChild
SCConfNode * SCConfNodeLookupChild(const SCConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:849
LOG_NSAP
#define LOG_NSAP
Definition: output-json-dns.c:65
LOG_AAAA
#define LOG_AAAA
Definition: output-json-dns.c:71
LOG_DHCID
#define LOG_DHCID
Definition: output-json-dns.c:89
OutputInitResult_
Definition: output.h:46
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
DNS_RRTYPE_SIG
@ DNS_RRTYPE_SIG
Definition: output-json-dns.c:134
DNS_RRTYPE_NXT
@ DNS_RRTYPE_NXT
Definition: output-json-dns.c:140
LOG_CNAME
#define LOG_CNAME
Definition: output-json-dns.c:48
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:94
version
uint8_t version
Definition: decode-gre.h:1
LogDnsFileCtx
struct LogDnsFileCtx_ LogDnsFileCtx
LOG_QUERIES
#define LOG_QUERIES
Definition: output-json-dns.c:41
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
LOG_FORMAT_GROUPED
#define LOG_FORMAT_GROUPED
Definition: output-json-dns.c:103
LogDnsLogThread
struct LogDnsLogThread_ LogDnsLogThread
threadvars.h
output-json-dns.h
LOG_NSAPPTR
#define LOG_NSAPPTR
Definition: output-json-dns.c:66
LOGGER_JSON_TX
@ LOGGER_JSON_TX
Definition: suricata-common.h:489
DNS_RRTYPE_DNSKEY
@ DNS_RRTYPE_DNSKEY
Definition: output-json-dns.c:155
JsonDnsLogRegister
void JsonDnsLogRegister(void)
Definition: output-json-dns.c:687
DNS_RRTYPE_MG
@ DNS_RRTYPE_MG
Definition: output-json-dns.c:118
LOG_CDNSKEY
#define LOG_CDNSKEY
Definition: output-json-dns.c:95
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DNS_RRTYPE_MR
@ DNS_RRTYPE_MR
Definition: output-json-dns.c:119
LOG_ISDN
#define LOG_ISDN
Definition: output-json-dns.c:63
LOG_OPT
#define LOG_OPT
Definition: output-json-dns.c:81
DNS_RRTYPE_SOA
@ DNS_RRTYPE_SOA
Definition: output-json-dns.c:116
DNS_RRTYPE_RT
@ DNS_RRTYPE_RT
Definition: output-json-dns.c:131
LOG_X25
#define LOG_X25
Definition: output-json-dns.c:62
LOG_MX
#define LOG_MX
Definition: output-json-dns.c:58
DNS_RRTYPE_APL
@ DNS_RRTYPE_APL
Definition: output-json-dns.c:149
DNS_RRTYPE_SSHFP
@ DNS_RRTYPE_SSHFP
Definition: output-json-dns.c:151
LOG_FORMAT_DETAILED
#define LOG_FORMAT_DETAILED
Definition: output-json-dns.c:104
DNS_RRTYPE_NSAPPTR
@ DNS_RRTYPE_NSAPPTR
Definition: output-json-dns.c:133
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-eve-bindgen.h:34
DNS_RRTYPE_MB
@ DNS_RRTYPE_MB
Definition: output-json-dns.c:117
LOG_DIR_FLOW_TOCLIENT
@ LOG_DIR_FLOW_TOCLIENT
Definition: output-eve-bindgen.h:36
DNS_RRTYPE_CDS
@ DNS_RRTYPE_CDS
Definition: output-json-dns.c:161
LOG_FORMAT_ALL
#define LOG_FORMAT_ALL
Definition: output-json-dns.c:107
DetectGetInnerTx
void * DetectGetInnerTx(void *tx_ptr, AppProto alproto, AppProto engine_alproto, uint8_t flow_flags)
Definition: detect.c:1270
LOG_TXT
#define LOG_TXT
Definition: output-json-dns.c:59
flags
uint64_t flags
Definition: output-json-dns.c:175
LOG_IPSECKEY
#define LOG_IPSECKEY
Definition: output-json-dns.c:85
DNS_RRTYPE_MD
@ DNS_RRTYPE_MD
Definition: output-json-dns.c:113
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:250
DNS_RRTYPE_NAPTR
@ DNS_RRTYPE_NAPTR
Definition: output-json-dns.c:143
DNS_RRTYPE_SRV
@ DNS_RRTYPE_SRV
Definition: output-json-dns.c:141
DNS_RRTYPE_MINFO
@ DNS_RRTYPE_MINFO
Definition: output-json-dns.c:124
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
LogDnsLogThread_::dnslog_ctx
LogDnsFileCtx * dnslog_ctx
Definition: output-json-dns.c:247
LOG_A6
#define LOG_A6
Definition: output-json-dns.c:79
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
SCConfNode_
Definition: conf.h:37
AlertJsonDoh2
bool AlertJsonDoh2(void *txptr, SCJsonBuilder *js)
Definition: output-json-dns.c:257
LogDnsFileCtx_::version
uint8_t version
Definition: output-json-dns.c:243
SCConfNode_::val
char * val
Definition: conf.h:39
output.h
DNS_RRTYPE_CNAME
@ DNS_RRTYPE_CNAME
Definition: output-json-dns.c:115
LOG_PX
#define LOG_PX
Definition: output-json-dns.c:69
LOG_SPF
#define LOG_SPF
Definition: output-json-dns.c:96
f
Flow f
Definition: fuzz_dataset.c:32
config_rrtype
const char * config_rrtype
Definition: output-json-dns.c:174
LOG_AFSDB
#define LOG_AFSDB
Definition: output-json-dns.c:61