suricata
output-json-http.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Tom DeCanio <td@npulsetech.com>
22  *
23  * Implements HTTP JSON logging portion of the engine.
24  */
25 
26 #include "suricata-common.h"
27 #include "detect.h"
28 #include "pkt-var.h"
29 #include "conf.h"
30 
31 #include "threads.h"
32 #include "threadvars.h"
33 #include "tm-threads.h"
34 
35 #include "util-print.h"
36 #include "util-unittest.h"
37 
38 #include "util-debug.h"
39 
40 #include "output.h"
41 #include "app-layer-htp.h"
42 #include "app-layer-htp-file.h"
43 #include "app-layer-htp-xff.h"
44 #include "app-layer.h"
45 #include "app-layer-parser.h"
46 #include "util-privs.h"
47 #include "util-buffer.h"
48 #include "util-proto-name.h"
49 #include "util-logopenfile.h"
50 #include "util-time.h"
51 #include "output-json.h"
52 #include "output-json-alert.h"
53 #include "output-json-http.h"
54 #include "util-byte.h"
55 
56 typedef struct LogHttpFileCtx_ {
57  uint32_t flags; /** Store mode */
58  uint64_t fields;/** Store fields */
63 
64 typedef struct JsonHttpLogThread_ {
66  uint32_t uri_cnt;
69 
70 #define MAX_SIZE_HEADER_NAME 256
71 #define MAX_SIZE_HEADER_VALUE 2048
72 
73 #define LOG_HTTP_DEFAULT 0
74 #define LOG_HTTP_EXTENDED 1
75 #define LOG_HTTP_REQUEST 2 /* request field */
76 #define LOG_HTTP_ARRAY 4 /* require array handling */
77 #define LOG_HTTP_REQ_HEADERS 8
78 #define LOG_HTTP_RES_HEADERS 16
79 
80 typedef enum {
136 
137 struct {
138  const char *config_field;
139  const char *htp_field;
140  uint32_t flags;
141 } http_fields[] = {
142  { "accept", "accept", LOG_HTTP_REQUEST },
143  { "accept_charset", "accept-charset", LOG_HTTP_REQUEST },
144  { "accept_encoding", "accept-encoding", LOG_HTTP_REQUEST },
145  { "accept_language", "accept-language", LOG_HTTP_REQUEST },
146  { "accept_datetime", "accept-datetime", LOG_HTTP_REQUEST },
147  { "authorization", "authorization", LOG_HTTP_REQUEST },
148  { "cache_control", "cache-control", LOG_HTTP_REQUEST },
149  { "cookie", "cookie", LOG_HTTP_REQUEST|LOG_HTTP_ARRAY },
150  { "from", "from", LOG_HTTP_REQUEST },
151  { "max_forwards", "max-forwards", LOG_HTTP_REQUEST },
152  { "origin", "origin", LOG_HTTP_REQUEST },
153  { "pragma", "pragma", LOG_HTTP_REQUEST },
154  { "proxy_authorization", "proxy-authorization", LOG_HTTP_REQUEST },
155  { "range", "range", LOG_HTTP_REQUEST },
156  { "te", "te", LOG_HTTP_REQUEST },
157  { "via", "via", LOG_HTTP_REQUEST },
158  { "x_requested_with", "x-requested-with", LOG_HTTP_REQUEST },
159  { "dnt", "dnt", LOG_HTTP_REQUEST },
160  { "x_forwarded_proto", "x-forwarded-proto", LOG_HTTP_REQUEST },
161  { "x_authenticated_user", "x-authenticated-user", LOG_HTTP_REQUEST },
162  { "x_flash_version", "x-flash-version", LOG_HTTP_REQUEST },
163  { "accept_range", "accept-range", 0 },
164  { "age", "age", 0 },
165  { "allow", "allow", 0 },
166  { "connection", "connection", 0 },
167  { "content_encoding", "content-encoding", 0 },
168  { "content_language", "content-language", 0 },
169  { "content_length", "content-length", 0 },
170  { "content_location", "content-location", 0 },
171  { "content_md5", "content-md5", 0 },
172  { "content_range", "content-range", 0 },
173  { "content_type", "content-type", 0 },
174  { "date", "date", 0 },
175  { "etag", "etags", 0 },
176  { "expires", "expires" , 0 },
177  { "last_modified", "last-modified", 0 },
178  { "link", "link", 0 },
179  { "location", "location", 0 },
180  { "proxy_authenticate", "proxy-authenticate", 0 },
181  { "referrer", "referrer", LOG_HTTP_EXTENDED },
182  { "refresh", "refresh", 0 },
183  { "retry_after", "retry-after", 0 },
184  { "server", "server", 0 },
185  { "set_cookie", "set-cookie", 0 },
186  { "trailer", "trailer", 0 },
187  { "transfer_encoding", "transfer-encoding", 0 },
188  { "upgrade", "upgrade", 0 },
189  { "vary", "vary", 0 },
190  { "warning", "warning", 0 },
191  { "www_authenticate", "www-authenticate", 0 },
192  { "true_client_ip", "true-client-ip", LOG_HTTP_REQUEST },
193  { "org_src_ip", "org-src-ip", LOG_HTTP_REQUEST },
194  { "x_bluecoat_via", "x-bluecoat-via", LOG_HTTP_REQUEST },
195 };
196 
197 static void EveHttpLogJSONBasic(JsonBuilder *js, htp_tx_t *tx)
198 {
199  /* hostname */
200  if (tx->request_hostname != NULL) {
201  jb_set_string_from_bytes(
202  js, "hostname", bstr_ptr(tx->request_hostname), bstr_len(tx->request_hostname));
203  }
204 
205  /* port */
206  /* NOTE: this field will be set ONLY if the port is present in the
207  * hostname. It may be present in the header "Host" or in the URL.
208  * There is no connection (from the suricata point of view) between this
209  * port and the TCP destination port of the flow.
210  */
211  if (tx->request_port_number >= 0) {
212  jb_set_uint(js, "http_port", tx->request_port_number);
213  }
214 
215  /* uri */
216  if (tx->request_uri != NULL) {
217  jb_set_string_from_bytes(js, "url", bstr_ptr(tx->request_uri), bstr_len(tx->request_uri));
218  }
219 
220  if (tx->request_headers != NULL) {
221  /* user agent */
222  htp_header_t *h_user_agent = htp_table_get_c(tx->request_headers, "user-agent");
223  if (h_user_agent != NULL) {
224  jb_set_string_from_bytes(js, "http_user_agent", bstr_ptr(h_user_agent->value),
225  bstr_len(h_user_agent->value));
226  }
227 
228  /* x-forwarded-for */
229  htp_header_t *h_x_forwarded_for = htp_table_get_c(tx->request_headers, "x-forwarded-for");
230  if (h_x_forwarded_for != NULL) {
231  jb_set_string_from_bytes(js, "xff", bstr_ptr(h_x_forwarded_for->value),
232  bstr_len(h_x_forwarded_for->value));
233  }
234  }
235 
236  /* content-type */
237  if (tx->response_headers != NULL) {
238  htp_header_t *h_content_type = htp_table_get_c(tx->response_headers, "content-type");
239  if (h_content_type != NULL) {
240  const size_t size = bstr_len(h_content_type->value) * 2 + 1;
241  char string[size];
242  BytesToStringBuffer(bstr_ptr(h_content_type->value), bstr_len(h_content_type->value), string, size);
243  char *p = strchr(string, ';');
244  if (p != NULL)
245  *p = '\0';
246  jb_set_string(js, "http_content_type", string);
247  }
248  htp_header_t *h_content_range = htp_table_get_c(tx->response_headers, "content-range");
249  if (h_content_range != NULL) {
250  jb_open_object(js, "content_range");
251  jb_set_string_from_bytes(
252  js, "raw", bstr_ptr(h_content_range->value), bstr_len(h_content_range->value));
253  HTTPContentRange crparsed;
254  if (HTPParseContentRange(h_content_range->value, &crparsed) == 0) {
255  if (crparsed.start >= 0)
256  jb_set_uint(js, "start", crparsed.start);
257  if (crparsed.end >= 0)
258  jb_set_uint(js, "end", crparsed.end);
259  if (crparsed.size >= 0)
260  jb_set_uint(js, "size", crparsed.size);
261  }
262  jb_close(js);
263  }
264  }
265 }
266 
267 static void EveHttpLogJSONCustom(LogHttpFileCtx *http_ctx, JsonBuilder *js, htp_tx_t *tx)
268 {
269  char *c;
270  HttpField f;
271 
272  for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
273  {
274  if ((http_ctx->fields & (1ULL<<f)) != 0)
275  {
276  /* prevent logging a field twice if extended logging is
277  enabled */
278  if (((http_ctx->flags & LOG_HTTP_EXTENDED) == 0) ||
279  ((http_ctx->flags & LOG_HTTP_EXTENDED) !=
280  (http_fields[f].flags & LOG_HTTP_EXTENDED)))
281  {
282  htp_header_t *h_field = NULL;
283  if ((http_fields[f].flags & LOG_HTTP_REQUEST) != 0)
284  {
285  if (tx->request_headers != NULL) {
286  h_field = htp_table_get_c(tx->request_headers,
287  http_fields[f].htp_field);
288  }
289  } else {
290  if (tx->response_headers != NULL) {
291  h_field = htp_table_get_c(tx->response_headers,
292  http_fields[f].htp_field);
293  }
294  }
295  if (h_field != NULL) {
296  c = bstr_util_strdup_to_c(h_field->value);
297  if (c != NULL) {
298  jb_set_string(js, http_fields[f].config_field, c);
299  SCFree(c);
300  }
301  }
302  }
303  }
304  }
305 }
306 
307 static void EveHttpLogJSONExtended(JsonBuilder *js, htp_tx_t *tx)
308 {
309  /* referer */
310  htp_header_t *h_referer = NULL;
311  if (tx->request_headers != NULL) {
312  h_referer = htp_table_get_c(tx->request_headers, "referer");
313  }
314  if (h_referer != NULL) {
315  jb_set_string_from_bytes(
316  js, "http_refer", bstr_ptr(h_referer->value), bstr_len(h_referer->value));
317  }
318 
319  /* method */
320  if (tx->request_method != NULL) {
321  jb_set_string_from_bytes(
322  js, "http_method", bstr_ptr(tx->request_method), bstr_len(tx->request_method));
323  }
324 
325  /* protocol */
326  if (tx->request_protocol != NULL) {
327  jb_set_string_from_bytes(
328  js, "protocol", bstr_ptr(tx->request_protocol), bstr_len(tx->request_protocol));
329  }
330 
331  /* response status */
332  if (tx->response_status != NULL) {
333  const size_t status_size = bstr_len(tx->response_status) * 2 + 1;
334  char status_string[status_size];
335  BytesToStringBuffer(bstr_ptr(tx->response_status), bstr_len(tx->response_status),
336  status_string, status_size);
337  unsigned int val = strtoul(status_string, NULL, 10);
338  jb_set_uint(js, "status", val);
339 
340  htp_header_t *h_location = htp_table_get_c(tx->response_headers, "location");
341  if (h_location != NULL) {
342  jb_set_string_from_bytes(
343  js, "redirect", bstr_ptr(h_location->value), bstr_len(h_location->value));
344  }
345  }
346 
347  /* length */
348  jb_set_uint(js, "length", tx->response_message_len);
349 }
350 
351 static void EveHttpLogJSONHeaders(JsonBuilder *js, uint32_t direction, htp_tx_t *tx)
352 {
353  htp_table_t * headers = direction & LOG_HTTP_REQ_HEADERS ?
354  tx->request_headers : tx->response_headers;
355  char name[MAX_SIZE_HEADER_NAME] = {0};
356  char value[MAX_SIZE_HEADER_VALUE] = {0};
357  size_t n = htp_table_size(headers);
358  jb_open_array(js, direction & LOG_HTTP_REQ_HEADERS ? "request_headers" : "response_headers");
359  for (size_t i = 0; i < n; i++) {
360  htp_header_t * h = htp_table_get_index(headers, i, NULL);
361  if (h == NULL) {
362  continue;
363  }
364  jb_start_object(js);
365  size_t size_name = bstr_len(h->name) < MAX_SIZE_HEADER_NAME - 1 ?
366  bstr_len(h->name) : MAX_SIZE_HEADER_NAME - 1;
367  memcpy(name, bstr_ptr(h->name), size_name);
368  name[size_name] = '\0';
369  jb_set_string(js, "name", name);
370  size_t size_value = bstr_len(h->value) < MAX_SIZE_HEADER_VALUE - 1 ?
371  bstr_len(h->value) : MAX_SIZE_HEADER_VALUE - 1;
372  memcpy(value, bstr_ptr(h->value), size_value);
373  value[size_value] = '\0';
374  jb_set_string(js, "value", value);
375  jb_close(js);
376  }
377  // Close array.
378  jb_close(js);
379 }
380 
381 static void BodyPrintableBuffer(JsonBuilder *js, HtpBody *body, const char *key)
382 {
383  if (body->sb != NULL && body->sb->buf != NULL) {
384  uint32_t offset = 0;
385  const uint8_t *body_data;
386  uint32_t body_data_len;
387  uint64_t body_offset;
388 
389  if (StreamingBufferGetData(body->sb, &body_data,
390  &body_data_len, &body_offset) == 0) {
391  return;
392  }
393 
394  uint8_t printable_buf[body_data_len + 1];
395  PrintStringsToBuffer(printable_buf, &offset,
396  sizeof(printable_buf),
397  body_data, body_data_len);
398  if (offset > 0) {
399  jb_set_string(js, key, (char *)printable_buf);
400  }
401  }
402 }
403 
404 void EveHttpLogJSONBodyPrintable(JsonBuilder *js, Flow *f, uint64_t tx_id)
405 {
406  HtpState *htp_state = (HtpState *)FlowGetAppState(f);
407  if (htp_state) {
408  htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP1, htp_state, tx_id);
409  if (tx) {
410  HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx);
411  if (htud != NULL) {
412  BodyPrintableBuffer(js, &htud->request_body, "http_request_body_printable");
413  BodyPrintableBuffer(js, &htud->response_body, "http_response_body_printable");
414  }
415  }
416  }
417 }
418 
419 static void BodyBase64Buffer(JsonBuilder *js, HtpBody *body, const char *key)
420 {
421  if (body->sb != NULL && body->sb->buf != NULL) {
422  const uint8_t *body_data;
423  uint32_t body_data_len;
424  uint64_t body_offset;
425 
426  if (StreamingBufferGetData(body->sb, &body_data,
427  &body_data_len, &body_offset) == 0) {
428  return;
429  }
430 
431  jb_set_base64(js, key, body_data, body_data_len);
432  }
433 }
434 
435 void EveHttpLogJSONBodyBase64(JsonBuilder *js, Flow *f, uint64_t tx_id)
436 {
437  HtpState *htp_state = (HtpState *)FlowGetAppState(f);
438  if (htp_state) {
439  htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP1, htp_state, tx_id);
440  if (tx) {
441  HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx);
442  if (htud != NULL) {
443  BodyBase64Buffer(js, &htud->request_body, "http_request_body");
444  BodyBase64Buffer(js, &htud->response_body, "http_response_body");
445  }
446  }
447  }
448 }
449 
450 /* JSON format logging */
451 static void EveHttpLogJSON(JsonHttpLogThread *aft, JsonBuilder *js, htp_tx_t *tx, uint64_t tx_id)
452 {
453  LogHttpFileCtx *http_ctx = aft->httplog_ctx;
454  jb_open_object(js, "http");
455 
456  EveHttpLogJSONBasic(js, tx);
457  /* log custom fields if configured */
458  if (http_ctx->fields != 0)
459  EveHttpLogJSONCustom(http_ctx, js, tx);
460  if (http_ctx->flags & LOG_HTTP_EXTENDED)
461  EveHttpLogJSONExtended(js, tx);
462  if (http_ctx->flags & LOG_HTTP_REQ_HEADERS)
463  EveHttpLogJSONHeaders(js, LOG_HTTP_REQ_HEADERS, tx);
464  if (http_ctx->flags & LOG_HTTP_RES_HEADERS)
465  EveHttpLogJSONHeaders(js, LOG_HTTP_RES_HEADERS, tx);
466 
467  jb_close(js);
468 }
469 
470 static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *alstate, void *txptr, uint64_t tx_id)
471 {
472  SCEnter();
473 
474  htp_tx_t *tx = txptr;
475  JsonHttpLogThread *jhl = (JsonHttpLogThread *)thread_data;
476 
477  JsonBuilder *js = CreateEveHeaderWithTxId(
478  p, LOG_DIR_FLOW, "http", NULL, tx_id, jhl->httplog_ctx->eve_ctx);
479  if (unlikely(js == NULL))
480  return TM_ECODE_OK;
481 
482  SCLogDebug("got a HTTP request and now logging !!");
483 
484  EveHttpLogJSON(jhl, js, tx, tx_id);
485  HttpXFFCfg *xff_cfg = jhl->httplog_ctx->xff_cfg != NULL ?
487 
488  /* xff header */
489  if ((xff_cfg != NULL) && !(xff_cfg->flags & XFF_DISABLED) && p->flow != NULL) {
490  int have_xff_ip = 0;
491  char buffer[XFF_MAXLEN];
492 
493  have_xff_ip = HttpXFFGetIPFromTx(p->flow, tx_id, xff_cfg, buffer, XFF_MAXLEN);
494 
495  if (have_xff_ip) {
496  if (xff_cfg->flags & XFF_EXTRADATA) {
497  jb_set_string(js, "xff", buffer);
498  }
499  else if (xff_cfg->flags & XFF_OVERWRITE) {
500  if (p->flowflags & FLOW_PKT_TOCLIENT) {
501  jb_set_string(js, "dest_ip", buffer);
502  } else {
503  jb_set_string(js, "src_ip", buffer);
504  }
505  }
506  }
507  }
508 
509  OutputJsonBuilderBuffer(js, jhl->ctx);
510  jb_free(js);
511 
513 }
514 
515 bool EveHttpAddMetadata(const Flow *f, uint64_t tx_id, JsonBuilder *js)
516 {
517  HtpState *htp_state = (HtpState *)FlowGetAppState(f);
518  if (htp_state) {
519  htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP1, htp_state, tx_id);
520 
521  if (tx) {
522  EveHttpLogJSONBasic(js, tx);
523  EveHttpLogJSONExtended(js, tx);
524  return true;
525  }
526  }
527 
528  return false;
529 }
530 
531 static void OutputHttpLogDeinitSub(OutputCtx *output_ctx)
532 {
533  LogHttpFileCtx *http_ctx = output_ctx->data;
534  if (http_ctx->xff_cfg) {
535  SCFree(http_ctx->xff_cfg);
536  }
537  SCFree(http_ctx);
538  SCFree(output_ctx);
539 }
540 
541 static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
542 {
543  OutputInitResult result = { NULL, false };
544  OutputJsonCtx *ojc = parent_ctx->data;
545 
546  LogHttpFileCtx *http_ctx = SCCalloc(1, sizeof(LogHttpFileCtx));
547  if (unlikely(http_ctx == NULL))
548  return result;
549  memset(http_ctx, 0x00, sizeof(*http_ctx));
550 
551  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
552  if (unlikely(output_ctx == NULL)) {
553  SCFree(http_ctx);
554  return result;
555  }
556 
557  http_ctx->flags = LOG_HTTP_DEFAULT;
558  http_ctx->eve_ctx = ojc;
559 
560  if (conf) {
561  const char *extended = ConfNodeLookupChildValue(conf, "extended");
562 
563  if (extended != NULL) {
564  if (ConfValIsTrue(extended)) {
565  http_ctx->flags = LOG_HTTP_EXTENDED;
566  }
567  }
568 
569  ConfNode *custom;
570  if ((custom = ConfNodeLookupChild(conf, "custom")) != NULL) {
571  ConfNode *field;
572  TAILQ_FOREACH(field, &custom->head, next)
573  {
574  if (field != NULL)
575  {
576  HttpField f;
577  for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
578  {
579  if ((strcmp(http_fields[f].config_field,
580  field->val) == 0) ||
581  (strcasecmp(http_fields[f].htp_field,
582  field->val) == 0))
583  {
584  http_ctx->fields |= (1ULL<<f);
585  break;
586  }
587  }
588  }
589  }
590  }
591  const char *all_headers = ConfNodeLookupChildValue(
592  conf, "dump-all-headers");
593  if (all_headers != NULL) {
594  if (strncmp(all_headers, "both", 4) == 0) {
595  http_ctx->flags |= LOG_HTTP_REQ_HEADERS;
596  http_ctx->flags |= LOG_HTTP_RES_HEADERS;
597  } else if (strncmp(all_headers, "request", 7) == 0) {
598  http_ctx->flags |= LOG_HTTP_REQ_HEADERS;
599  } else if (strncmp(all_headers, "response", 8) == 0) {
600  http_ctx->flags |= LOG_HTTP_RES_HEADERS;
601  }
602  }
603  }
604 
605  if (conf != NULL && ConfNodeLookupChild(conf, "xff") != NULL) {
606  http_ctx->xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
607  if (http_ctx->xff_cfg != NULL) {
608  HttpXFFGetCfg(conf, http_ctx->xff_cfg);
609  }
610  } else if (ojc->xff_cfg) {
611  http_ctx->parent_xff_cfg = ojc->xff_cfg;
612  }
613 
614  output_ctx->data = http_ctx;
615  output_ctx->DeInit = OutputHttpLogDeinitSub;
616 
617  /* enable the logger for the app layer */
619 
620  result.ctx = output_ctx;
621  result.ok = true;
622  return result;
623 }
624 
625 static TmEcode JsonHttpLogThreadInit(ThreadVars *t, const void *initdata, void **data)
626 {
627  JsonHttpLogThread *aft = SCCalloc(1, sizeof(JsonHttpLogThread));
628  if (unlikely(aft == NULL))
629  return TM_ECODE_FAILED;
630 
631  if(initdata == NULL)
632  {
633  SCLogDebug("Error getting context for EveLogHTTP. \"initdata\" argument NULL");
634  goto error_exit;
635  }
636 
637  /* Use the Output Context (file pointer and mutex) */
638  aft->httplog_ctx = ((OutputCtx *)initdata)->data; //TODO
639 
640  aft->ctx = CreateEveThreadCtx(t, aft->httplog_ctx->eve_ctx);
641  if (!aft->ctx) {
642  goto error_exit;
643  }
644 
645  *data = (void *)aft;
646  return TM_ECODE_OK;
647 
648 error_exit:
649  SCFree(aft);
650  return TM_ECODE_FAILED;
651 }
652 
653 static TmEcode JsonHttpLogThreadDeinit(ThreadVars *t, void *data)
654 {
655  JsonHttpLogThread *aft = (JsonHttpLogThread *)data;
656  if (aft == NULL) {
657  return TM_ECODE_OK;
658  }
659 
660  FreeEveThreadCtx(aft->ctx);
661 
662  /* clear memory */
663  memset(aft, 0, sizeof(JsonHttpLogThread));
664 
665  SCFree(aft);
666  return TM_ECODE_OK;
667 }
668 
670 {
671  /* register as child of eve-log */
672  OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", "JsonHttpLog", "eve-log.http",
673  OutputHttpLogInitSub, ALPROTO_HTTP1, JsonHttpLogger, JsonHttpLogThreadInit,
674  JsonHttpLogThreadDeinit, NULL);
675 }
XFF_MAXLEN
#define XFF_MAXLEN
Definition: app-layer-htp-xff.h:39
util-byte.h
tm-threads.h
HTTP_FIELD_SIZE
@ HTTP_FIELD_SIZE
Definition: output-json-http.c:134
HTTP_FIELD_CONTENT_LOCATION
@ HTTP_FIELD_CONTENT_LOCATION
Definition: output-json-http.c:109
JsonHttpLogThread_
Definition: output-json-http.c:64
EveHttpLogJSONBodyPrintable
void EveHttpLogJSONBodyPrintable(JsonBuilder *js, Flow *f, uint64_t tx_id)
Definition: output-json-http.c:404
OutputJsonCtx_::xff_cfg
HttpXFFCfg * xff_cfg
Definition: output-json.h:85
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
XFF_EXTRADATA
#define XFF_EXTRADATA
Definition: app-layer-htp-xff.h:31
MAX_SIZE_HEADER_NAME
#define MAX_SIZE_HEADER_NAME
Definition: output-json-http.c:70
ConfNode_::val
char * val
Definition: conf.h:34
HtpBody_::sb
StreamingBuffer * sb
Definition: app-layer-htp.h:189
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
HTTP_FIELD_ALLOW
@ HTTP_FIELD_ALLOW
Definition: output-json-http.c:104
HTTP_FIELD_ACCEPT_RANGES
@ HTTP_FIELD_ACCEPT_RANGES
Definition: output-json-http.c:102
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:296
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
HTTP_FIELD_X_FLASH_VERSION
@ HTTP_FIELD_X_FLASH_VERSION
Definition: output-json-http.c:101
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
HTTP_FIELD_REFERRER
@ HTTP_FIELD_REFERRER
Definition: output-json-http.c:120
StreamingBuffer_::buf
uint8_t * buf
Definition: util-streaming-buffer.h:97
MAX_SIZE_HEADER_VALUE
#define MAX_SIZE_HEADER_VALUE
Definition: output-json-http.c:71
threads.h
OutputJsonCtx_
Definition: output-json.h:81
Flow_
Flow data structure.
Definition: flow.h:356
LogHttpFileCtx
struct LogHttpFileCtx_ LogHttpFileCtx
OutputJsonBuilderBuffer
int OutputJsonBuilderBuffer(JsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:934
LOG_HTTP_ARRAY
#define LOG_HTTP_ARRAY
Definition: output-json-http.c:76
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:252
HTTP_FIELD_EXPIRES
@ HTTP_FIELD_EXPIRES
Definition: output-json-http.c:115
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
http_fields
struct @131 http_fields[]
HtpTxUserData_::request_body
HtpBody request_body
Definition: app-layer-htp.h:223
HTTP_FIELD_FROM
@ HTTP_FIELD_FROM
Definition: output-json-http.c:89
HTTP_FIELD_CONTENT_ENCODING
@ HTTP_FIELD_CONTENT_ENCODING
Definition: output-json-http.c:106
HTTP_FIELD_WWW_AUTHENTICATE
@ HTTP_FIELD_WWW_AUTHENTICATE
Definition: output-json-http.c:130
StreamingBufferGetData
int StreamingBufferGetData(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t *stream_offset)
Definition: util-streaming-buffer.c:857
HTTP_FIELD_WARNING
@ HTTP_FIELD_WARNING
Definition: output-json-http.c:129
HTTP_FIELD_COOKIE
@ HTTP_FIELD_COOKIE
Definition: output-json-http.c:88
HTTP_FIELD_CONTENT_LENGTH
@ HTTP_FIELD_CONTENT_LENGTH
Definition: output-json-http.c:108
util-privs.h
LogHttpFileCtx_::xff_cfg
HttpXFFCfg * xff_cfg
Definition: output-json-http.c:59
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:459
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:85
HTTP_FIELD_ETAG
@ HTTP_FIELD_ETAG
Definition: output-json-http.c:114
HTTP_FIELD_X_BLUECOAT_VIA
@ HTTP_FIELD_X_BLUECOAT_VIA
Definition: output-json-http.c:133
util-unittest.h
HTTP_FIELD_AGE
@ HTTP_FIELD_AGE
Definition: output-json-http.c:103
HTPParseContentRange
int HTPParseContentRange(bstr *rawvalue, HTTPContentRange *range)
Definition: app-layer-htp-file.c:90
EveHttpAddMetadata
bool EveHttpAddMetadata(const Flow *f, uint64_t tx_id, JsonBuilder *js)
Definition: output-json-http.c:515
HtpState_
Definition: app-layer-htp.h:245
JsonHttpLogThread_::httplog_ctx
LogHttpFileCtx * httplog_ctx
Definition: output-json-http.c:65
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:522
FlowGetAppState
void * FlowGetAppState(const Flow *f)
Definition: flow.c:1148
HTTP_FIELD_CACHE_CONTROL
@ HTTP_FIELD_CACHE_CONTROL
Definition: output-json-http.c:87
OutputCtx_::data
void * data
Definition: tm-modules.h:81
config_field
const char * config_field
Definition: output-json-http.c:138
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
PrintStringsToBuffer
void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len)
Definition: util-print.c:230
JsonHttpLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-http.c:67
OutputCtx_
Definition: tm-modules.h:78
app-layer-htp-xff.h
JsonHttpLogThread_::uri_cnt
uint32_t uri_cnt
Definition: output-json-http.c:66
app-layer-htp-file.h
OutputJsonThreadCtx_
Definition: output-json.h:89
HTTP_FIELD_RETRY_AFTER
@ HTTP_FIELD_RETRY_AFTER
Definition: output-json-http.c:122
HTTP_FIELD_UPGRADE
@ HTTP_FIELD_UPGRADE
Definition: output-json-http.c:127
HTTP_FIELD_CONTENT_RANGE
@ HTTP_FIELD_CONTENT_RANGE
Definition: output-json-http.c:111
HTTP_FIELD_ACCEPT
@ HTTP_FIELD_ACCEPT
Definition: output-json-http.c:81
HTTP_FIELD_PRAGMA
@ HTTP_FIELD_PRAGMA
Definition: output-json-http.c:92
HTTP_FIELD_ACCEPT_LANGUAGE
@ HTTP_FIELD_ACCEPT_LANGUAGE
Definition: output-json-http.c:84
HTTP_FIELD_LOCATION
@ HTTP_FIELD_LOCATION
Definition: output-json-http.c:118
HTTP_FIELD_DATE
@ HTTP_FIELD_DATE
Definition: output-json-http.c:113
app-layer-htp.h
LOG_HTTP_DEFAULT
#define LOG_HTTP_DEFAULT
Definition: output-json-http.c:73
HTTP_FIELD_ORIGIN
@ HTTP_FIELD_ORIGIN
Definition: output-json-http.c:91
util-debug.h
htp_field
const char * htp_field
Definition: output-json-http.c:139
HTTP_FIELD_ORG_SRC_IP
@ HTTP_FIELD_ORG_SRC_IP
Definition: output-json-http.c:132
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
HTTP_FIELD_LAST_MODIFIED
@ HTTP_FIELD_LAST_MODIFIED
Definition: output-json-http.c:116
HTTP_FIELD_AUTHORIZATION
@ HTTP_FIELD_AUTHORIZATION
Definition: output-json-http.c:86
output-json.h
LOG_HTTP_REQUEST
#define LOG_HTTP_REQUEST
Definition: output-json-http.c:75
AppLayerParserRegisterLogger
void AppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:477
util-print.h
HTTP_FIELD_RANGE
@ HTTP_FIELD_RANGE
Definition: output-json-http.c:94
SCEnter
#define SCEnter(...)
Definition: util-debug.h:298
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
pkt-var.h
HttpField
HttpField
Definition: output-json-http.c:80
HTTP_FIELD_LINK
@ HTTP_FIELD_LINK
Definition: output-json-http.c:117
util-time.h
OutputInitResult_::ok
bool ok
Definition: output.h:48
HTTP_FIELD_ACCEPT_ENCODING
@ HTTP_FIELD_ACCEPT_ENCODING
Definition: output-json-http.c:83
EveHttpLogJSONBodyBase64
void EveHttpLogJSONBodyBase64(JsonBuilder *js, Flow *f, uint64_t tx_id)
Definition: output-json-http.c:435
app-layer-parser.h
HTTP_FIELD_SERVER
@ HTTP_FIELD_SERVER
Definition: output-json-http.c:123
CreateEveHeaderWithTxId
JsonBuilder * CreateEveHeaderWithTxId(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, uint64_t tx_id, OutputJsonCtx *eve_ctx)
Definition: output-json.c:879
HTTP_FIELD_CONNECTION
@ HTTP_FIELD_CONNECTION
Definition: output-json-http.c:105
HTTP_FIELD_TE
@ HTTP_FIELD_TE
Definition: output-json-http.c:95
HTTP_FIELD_SET_COOKIE
@ HTTP_FIELD_SET_COOKIE
Definition: output-json-http.c:124
Packet_
Definition: decode.h:428
conf.h
HTTP_FIELD_TRAILER
@ HTTP_FIELD_TRAILER
Definition: output-json-http.c:125
XFF_OVERWRITE
#define XFF_OVERWRITE
Definition: app-layer-htp-xff.h:33
TmEcode
TmEcode
Definition: tm-threads-common.h:83
HttpXFFCfg_
Definition: app-layer-htp-xff.h:41
util-proto-name.h
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:227
HtpTxUserData_::response_body
HtpBody response_body
Definition: app-layer-htp.h:224
AppLayerParserGetTx
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
Definition: app-layer-parser.c:1146
HTTP_FIELD_CONTENT_MD5
@ HTTP_FIELD_CONTENT_MD5
Definition: output-json-http.c:110
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:771
HTTP_FIELD_DNT
@ HTTP_FIELD_DNT
Definition: output-json-http.c:98
OutputInitResult_
Definition: output.h:46
Packet_::flow
struct Flow_ * flow
Definition: decode.h:465
HtpBody_
Definition: app-layer-htp.h:185
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:84
LOG_HTTP_REQ_HEADERS
#define LOG_HTTP_REQ_HEADERS
Definition: output-json-http.c:77
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:30
HTTP_FIELD_PROXY_AUTHORIZATION
@ HTTP_FIELD_PROXY_AUTHORIZATION
Definition: output-json-http.c:93
JsonHttpLogThread
struct JsonHttpLogThread_ JsonHttpLogThread
HTTP_FIELD_VARY
@ HTTP_FIELD_VARY
Definition: output-json-http.c:128
HtpTxUserData_
Definition: app-layer-htp.h:208
OutputRegisterTxSubModule
void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:411
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
HTTP_FIELD_TRUE_CLIENT_IP
@ HTTP_FIELD_TRUE_CLIENT_IP
Definition: output-json-http.c:131
output-json-alert.h
threadvars.h
LOG_DIR_FLOW
@ LOG_DIR_FLOW
Definition: output-json.h:40
HTTP_FIELD_CONTENT_LANGUAGE
@ HTTP_FIELD_CONTENT_LANGUAGE
Definition: output-json-http.c:107
LOGGER_JSON_TX
@ LOGGER_JSON_TX
Definition: suricata-common.h:456
HttpXFFCfg_::flags
uint8_t flags
Definition: app-layer-htp-xff.h:42
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
LogHttpFileCtx_::fields
uint64_t fields
Definition: output-json-http.c:58
HTTP_FIELD_X_FORWARDED_PROTO
@ HTTP_FIELD_X_FORWARDED_PROTO
Definition: output-json-http.c:99
util-buffer.h
BytesToStringBuffer
void BytesToStringBuffer(const uint8_t *bytes, size_t nbytes, char *outstr, size_t outlen)
Turn byte array into string.
Definition: util-byte.c:85
HTTP_FIELD_MAX_FORWARDS
@ HTTP_FIELD_MAX_FORWARDS
Definition: output-json-http.c:90
LOG_HTTP_EXTENDED
#define LOG_HTTP_EXTENDED
Definition: output-json-http.c:74
HTTP_FIELD_TRANSFER_ENCODING
@ HTTP_FIELD_TRANSFER_ENCODING
Definition: output-json-http.c:126
JsonHttpLogRegister
void JsonHttpLogRegister(void)
Definition: output-json-http.c:669
HTTP_FIELD_ACCEPT_DATETIME
@ HTTP_FIELD_ACCEPT_DATETIME
Definition: output-json-http.c:85
HTTP_FIELD_VIA
@ HTTP_FIELD_VIA
Definition: output-json-http.c:96
HttpXFFGetCfg
void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result)
Function to return XFF configuration from a configuration node.
Definition: app-layer-htp-xff.c:205
LogHttpFileCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-http.c:61
HTTP_FIELD_ACCEPT_CHARSET
@ HTTP_FIELD_ACCEPT_CHARSET
Definition: output-json-http.c:82
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:116
HTTP_FIELD_REFRESH
@ HTTP_FIELD_REFRESH
Definition: output-json-http.c:121
HTTP_FIELD_PROXY_AUTHENTICATE
@ HTTP_FIELD_PROXY_AUTHENTICATE
Definition: output-json-http.c:119
HTTP_FIELD_CONTENT_TYPE
@ HTTP_FIELD_CONTENT_TYPE
Definition: output-json-http.c:112
output-json-http.h
LogHttpFileCtx_::flags
uint32_t flags
Definition: log-httplog.c:86
HTTP_FIELD_X_AUTHENTICATED_USER
@ HTTP_FIELD_X_AUTHENTICATED_USER
Definition: output-json-http.c:100
flags
uint32_t flags
Definition: output-json-http.c:140
LogHttpFileCtx_
Definition: log-httplog.c:84
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:302
XFF_DISABLED
#define XFF_DISABLED
Definition: app-layer-htp-xff.h:29
HTTP_FIELD_X_REQUESTED_WITH
@ HTTP_FIELD_X_REQUESTED_WITH
Definition: output-json-http.c:97
LOG_HTTP_RES_HEADERS
#define LOG_HTTP_RES_HEADERS
Definition: output-json-http.c:78
output.h
app-layer.h
LogHttpFileCtx_::parent_xff_cfg
HttpXFFCfg * parent_xff_cfg
Definition: output-json-http.c:60
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:799