suricata
detect-filestore.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 Victor Julien <victor@inliniac.net>
22  *
23  * Implements the filestore keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "threads.h"
28 #include "decode.h"
29 
30 #include "detect.h"
31 #include "detect-parse.h"
32 
33 #include "detect-engine.h"
34 #include "detect-engine-mpm.h"
35 #include "detect-engine-state.h"
36 
37 #include "feature.h"
38 
39 #include "flow.h"
40 #include "flow-var.h"
41 #include "flow-util.h"
42 
43 #include "util-debug.h"
44 #include "util-spm-bm.h"
45 #include "util-unittest-helper.h"
46 
47 #include "app-layer.h"
48 #include "app-layer-parser.h"
49 #include "app-layer-htp.h"
50 
51 #include "stream-tcp.h"
52 
53 #include "detect-filestore.h"
54 
55 #include "util-validate.h"
56 
57 /**
58  * \brief Regex for parsing our flow options
59  */
60 #define PARSE_REGEX "^\\s*([A-z_]+)\\s*(?:,\\s*([A-z_]+))?\\s*(?:,\\s*([A-z_]+))?\\s*$"
61 
62 static DetectParseRegex parse_regex;
63 
64 static int DetectFilestoreMatch (DetectEngineThreadCtx *,
65  Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *);
66 static int DetectFilestorePostMatch(DetectEngineThreadCtx *det_ctx,
67  Packet *p, const Signature *s, const SigMatchCtx *ctx);
68 static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, const char *);
69 static void DetectFilestoreFree(DetectEngineCtx *, void *);
70 #ifdef UNITTESTS
71 static void DetectFilestoreRegisterTests(void);
72 #endif
73 static int g_file_match_list_id = 0;
74 
75 /**
76  * \brief Registration function for keyword: filestore
77  */
79 {
80  sigmatch_table[DETECT_FILESTORE].name = "filestore";
81  sigmatch_table[DETECT_FILESTORE].desc = "stores files to disk if the rule matched";
82  sigmatch_table[DETECT_FILESTORE].url = "/rules/file-keywords.html#filestore";
83  sigmatch_table[DETECT_FILESTORE].FileMatch = DetectFilestoreMatch;
84  sigmatch_table[DETECT_FILESTORE].Setup = DetectFilestoreSetup;
85  sigmatch_table[DETECT_FILESTORE].Free = DetectFilestoreFree;
86 #ifdef UNITTESTS
87  sigmatch_table[DETECT_FILESTORE].RegisterTests = DetectFilestoreRegisterTests;
88 #endif
90 
91  sigmatch_table[DETECT_FILESTORE_POSTMATCH].name = "__filestore__postmatch__";
92  sigmatch_table[DETECT_FILESTORE_POSTMATCH].Match = DetectFilestorePostMatch;
93  sigmatch_table[DETECT_FILESTORE_POSTMATCH].Free = DetectFilestoreFree;
94 
95  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
96 
97  g_file_match_list_id = DetectBufferTypeRegister("files");
98 }
99 
100 /**
101  * \brief apply the post match filestore with options
102  */
103 static int FilestorePostMatchWithOptions(Packet *p, Flow *f, const DetectFilestoreData *filestore,
104  FileContainer *fc, uint32_t file_id, uint64_t tx_id)
105 {
106  if (filestore == NULL) {
107  SCReturnInt(0);
108  }
109 
110  int this_file = 0;
111  int this_tx = 0;
112  int this_flow = 0;
113  int rule_dir = 0;
114  int toserver_dir = 0;
115  int toclient_dir = 0;
116 
117  switch (filestore->direction) {
119  rule_dir = 1;
120  // will use both sides if scope is not default
121  // fallthrough
122  case FILESTORE_DIR_BOTH:
123  toserver_dir = 1;
124  toclient_dir = 1;
125  break;
127  toserver_dir = 1;
128  break;
130  toclient_dir = 1;
131  break;
132  }
133 
134  switch (filestore->scope) {
136  if (rule_dir) {
137  this_file = 1;
138  } else if ((p->flowflags & FLOW_PKT_TOCLIENT) && toclient_dir) {
139  this_file = 1;
140  } else if ((p->flowflags & FLOW_PKT_TOSERVER) && toserver_dir) {
141  this_file = 1;
142  }
143  break;
144  case FILESTORE_SCOPE_TX:
145  this_tx = 1;
146  break;
147  case FILESTORE_SCOPE_SSN:
148  this_flow = 1;
149  break;
150  }
151 
152  if (this_file) {
153  FileStoreFileById(fc, file_id);
154  } else if (this_tx) {
155  /* set in AppLayerTxData. Parsers and logger will propagate it to the
156  * individual files, both new and current. */
157  void *txv = AppLayerParserGetTx(f->proto, f->alproto, f->alstate, tx_id);
158  DEBUG_VALIDATE_BUG_ON(txv == NULL);
159  if (txv != NULL) {
161  if (toclient_dir) {
162  txd->file_flags |= FLOWFILE_STORE_TC;
163  }
164  if (toserver_dir) {
165  txd->file_flags |= FLOWFILE_STORE_TS;
166  }
167  }
168  } else if (this_flow) {
169  /* set in flow and AppLayerStateData */
171  if (toclient_dir) {
172  f->file_flags |= FLOWFILE_STORE_TC;
173  if (sd != NULL) {
174  sd->file_flags |= FLOWFILE_STORE_TC;
175  }
176  }
177  if (toserver_dir) {
178  f->file_flags |= FLOWFILE_STORE_TS;
179  if (sd != NULL) {
180  sd->file_flags |= FLOWFILE_STORE_TS;
181  }
182  }
183  } else {
184  FileStoreFileById(fc, file_id);
185  }
186 
187  SCReturnInt(0);
188 }
189 
190 /**
191  * \brief post-match function for filestore
192  *
193  * \param t thread local vars
194  * \param det_ctx pattern matcher thread local data
195  * \param p packet
196  *
197  * The match function for filestore records store candidates in the det_ctx.
198  * When we are sure all parts of the signature matched, we run this function
199  * to finalize the filestore.
200  */
201 static int DetectFilestorePostMatch(DetectEngineThreadCtx *det_ctx,
202  Packet *p, const Signature *s, const SigMatchCtx *ctx)
203 {
204  SCEnter();
205 
206  if (det_ctx->filestore_cnt == 0) {
207  SCReturnInt(0);
208  }
209 
210  if ((s->filestore_ctx == NULL && !(s->flags & SIG_FLAG_FILESTORE)) || p->flow == NULL) {
211 #ifndef DEBUG
212  SCReturnInt(0);
213 #else
214  BUG_ON(1);
215 #endif
216  }
217 
218  if (p->flow->proto == IPPROTO_TCP && p->flow->protoctx != NULL) {
219  /* set filestore depth for stream reassembling */
222  }
223 
224  SCLogDebug("s->filestore_ctx %p", s->filestore_ctx);
225 
226  const uint8_t flags = STREAM_FLAGS_FOR_PACKET(p);
227  for (uint16_t u = 0; u < det_ctx->filestore_cnt; u++) {
228  void *alstate = FlowGetAppState(p->flow);
230  p->flow->proto, p->flow->alproto, alstate, det_ctx->filestore[u].tx_id, flags);
231 
232  void *txv = AppLayerParserGetTx(
233  p->flow->proto, p->flow->alproto, alstate, det_ctx->filestore[u].tx_id);
234  DEBUG_VALIDATE_BUG_ON(txv == NULL);
235  if (txv) {
237  FileContainer *ffc_tx = files.fc;
238  DEBUG_VALIDATE_BUG_ON(ffc_tx == NULL);
239  if (ffc_tx) {
240  SCLogDebug("u %u txv %p ffc_tx %p file_id %u", u, txv, ffc_tx,
241  det_ctx->filestore[u].file_id);
242 
243  /* filestore for single files only */
244  if (s->filestore_ctx == NULL) {
245  FileStoreFileById(ffc_tx, det_ctx->filestore[u].file_id);
246  } else {
247  FilestorePostMatchWithOptions(p, p->flow, s->filestore_ctx, ffc_tx,
248  det_ctx->filestore[u].file_id, det_ctx->filestore[u].tx_id);
249  }
250  }
251  }
252  }
253  SCReturnInt(0);
254 }
255 
256 /**
257  * \brief match the specified filestore
258  *
259  * \param t thread local vars
260  * \param det_ctx pattern matcher thread local data
261  * \param f *LOCKED* flow
262  * \param flags direction flags
263  * \param file file being inspected
264  * \param s signature being inspected
265  * \param m sigmatch that we will cast into DetectFilestoreData
266  *
267  * \retval 0 no match
268  * \retval 1 match
269  *
270  * \todo when we start supporting more protocols, the logic in this function
271  * needs to be put behind a api.
272  */
273 static int DetectFilestoreMatch (DetectEngineThreadCtx *det_ctx, Flow *f,
274  uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
275 {
276  uint32_t file_id = 0;
277 
278  SCEnter();
279 
280  if (!RunmodeIsUnittests()) {
281  extern bool g_filedata_logger_enabled;
283  SCLogDebug("not storing file match: no filedata logger enabled");
284  SCReturnInt(1);
285  }
286  }
287  if (det_ctx->filestore_cnt >= DETECT_FILESTORE_MAX) {
288  SCReturnInt(1);
289  }
290 
291  /* file can be NULL when a rule with filestore scope > file
292  * matches. */
293  if (file != NULL) {
294  file_id = file->file_track_id;
295  if (file->sid != NULL && s->id > 0) {
296  if (file->sid_cnt >= file->sid_max) {
297  void *p = SCRealloc(file->sid, sizeof(uint32_t) * (file->sid_max + 8));
298  if (p == NULL) {
299  SCFree(file->sid);
300  file->sid = NULL;
301  file->sid_cnt = 0;
302  file->sid_max = 0;
303  goto continue_after_realloc_fail;
304  } else {
305  file->sid = p;
306  file->sid_max += 8;
307  }
308  }
309  file->sid[file->sid_cnt] = s->id;
310  file->sid_cnt++;
311  }
312  }
313 
314 continue_after_realloc_fail:
315 
316  det_ctx->filestore[det_ctx->filestore_cnt].file_id = file_id;
317  det_ctx->filestore[det_ctx->filestore_cnt].tx_id = det_ctx->tx_id;
318 
319  SCLogDebug("%u, file %u, tx %"PRIu64, det_ctx->filestore_cnt,
320  det_ctx->filestore[det_ctx->filestore_cnt].file_id,
321  det_ctx->filestore[det_ctx->filestore_cnt].tx_id);
322 
323  det_ctx->filestore_cnt++;
324  SCReturnInt(1);
325 }
326 
327 /**
328  * \brief this function is used to parse filestore options
329  * \brief into the current signature
330  *
331  * \param de_ctx pointer to the Detection Engine Context
332  * \param s pointer to the Current Signature
333  * \param str pointer to the user provided "filestore" option
334  *
335  * \retval 0 on Success
336  * \retval -1 on Failure
337  */
338 static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
339 {
340  SCEnter();
341 
342  static bool warn_not_configured = false;
343  static uint32_t de_version = 0;
344 
345  if (de_ctx->filestore_cnt == UINT16_MAX) {
346  SCLogError("Cannot have more than 65535 filestore signatures");
347  return -1;
348  }
349 
350  /* Check on first-time loads (includes following a reload) */
351  if (!warn_not_configured || (de_ctx->version != de_version)) {
352  if (de_version != de_ctx->version) {
353  SCLogDebug("reload-detected; re-checking feature presence; DE version now %"PRIu32,
354  de_ctx->version);
355  }
357  SCLogWarning("One or more rule(s) depends on the "
358  "file-store output log which is not enabled. "
359  "Enable the output \"file-store\".");
360  }
361  warn_not_configured = true;
362  de_version = de_ctx->version;
363  }
364 
365  DetectFilestoreData *fd = NULL;
366  char *args[3] = {NULL,NULL,NULL};
367  int res = 0;
368  size_t pcre2len;
369  pcre2_match_data *match = NULL;
370 
371  /* filestore and bypass keywords can't work together */
372  if (s->flags & SIG_FLAG_BYPASS) {
373  SCLogError("filestore can't work with bypass keyword");
374  return -1;
375  }
376 
377  if (str != NULL && strlen(str) > 0) {
378  char str_0[32];
379  char str_1[32];
380  char str_2[32];
381  SCLogDebug("str %s", str);
382 
383  int ret = DetectParsePcreExec(&parse_regex, &match, str, 0, 0);
384  if (ret < 1 || ret > 4) {
385  SCLogError("parse error, ret %" PRId32 ", string %s", ret, str);
386  goto error;
387  }
388 
389  if (ret > 1) {
390  pcre2len = sizeof(str_0);
391  res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)str_0, &pcre2len);
392  if (res < 0) {
393  SCLogError("pcre2_substring_copy_bynumber failed");
394  goto error;
395  }
396  args[0] = (char *)str_0;
397 
398  if (ret > 2) {
399  pcre2len = sizeof(str_1);
400  res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)str_1, &pcre2len);
401  if (res < 0) {
402  SCLogError("pcre2_substring_copy_bynumber failed");
403  goto error;
404  }
405  args[1] = (char *)str_1;
406  }
407  if (ret > 3) {
408  pcre2len = sizeof(str_2);
409  res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)str_2, &pcre2len);
410  if (res < 0) {
411  SCLogError("pcre2_substring_copy_bynumber failed");
412  goto error;
413  }
414  args[2] = (char *)str_2;
415  }
416  }
417 
418  fd = SCCalloc(1, sizeof(DetectFilestoreData));
419  if (unlikely(fd == NULL))
420  goto error;
421 
422  if (args[0] != NULL) {
423  SCLogDebug("first arg %s", args[0]);
424 
425  if (strcasecmp(args[0], "request") == 0 ||
426  strcasecmp(args[0], "to_server") == 0)
427  {
430  }
431  else if (strcasecmp(args[0], "response") == 0 ||
432  strcasecmp(args[0], "to_client") == 0)
433  {
436  }
437  else if (strcasecmp(args[0], "both") == 0)
438  {
441  }
442  } else {
444  }
445 
446  if (args[1] != NULL) {
447  SCLogDebug("second arg %s", args[1]);
448 
449  if (strcasecmp(args[1], "file") == 0)
450  {
452  } else if (strcasecmp(args[1], "tx") == 0)
453  {
455  } else if (strcasecmp(args[1], "ssn") == 0 ||
456  strcasecmp(args[1], "flow") == 0)
457  {
459  }
460  } else {
461  if (fd->scope == 0)
463  }
464  }
465 
466  if (s->alproto == ALPROTO_HTTP1 || s->alproto == ALPROTO_HTTP) {
468  }
469 
471  de_ctx, s, DETECT_FILESTORE, (SigMatchCtx *)fd, g_file_match_list_id) == NULL) {
472  DetectFilestoreFree(de_ctx, fd);
473  goto error;
474  }
475  s->filestore_ctx = fd;
476 
479  goto error;
480  }
481 
484 
485  if (match)
486  pcre2_match_data_free(match);
487 
488  return 0;
489 
490 error:
491  if (match) {
492  pcre2_match_data_free(match);
493  }
494  return -1;
495 }
496 
497 static void DetectFilestoreFree(DetectEngineCtx *de_ctx, void *ptr)
498 {
499  if (ptr != NULL) {
500  SCFree(ptr);
501  }
502 }
503 
504 #ifdef UNITTESTS
505 /*
506  * The purpose of this test is to confirm that
507  * filestore and bypass keywords can't
508  * can't work together
509  */
510 static int DetectFilestoreTest01(void)
511 {
513  FAIL_IF(de_ctx == NULL);
514 
515  de_ctx->flags |= DE_QUIET;
516 
517  Signature *s = DetectEngineAppendSig(de_ctx, "alert http any any -> any any "
518  "(bypass; filestore; "
519  "content:\"message\"; http_host; "
520  "sid:1;)");
521  FAIL_IF_NOT_NULL(s);
522 
524 
525  PASS;
526 }
527 
528 void DetectFilestoreRegisterTests(void)
529 {
530  UtRegisterTest("DetectFilestoreTest01", DetectFilestoreTest01);
531 }
532 #endif /* UNITTESTS */
SigTableElmt_::url
const char * url
Definition: detect.h:1545
FileContainer_
Definition: util-file.h:37
AppLayerHtpNeedFileInspection
void AppLayerHtpNeedFileInspection(void)
Sets a flag that informs the HTP app layer that some module in the engine needs the http request file...
Definition: app-layer-htp.c:569
detect-engine.h
SigTableElmt_::desc
const char * desc
Definition: detect.h:1544
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:78
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1529
flow-util.h
Signature_::filestore_ctx
const struct DetectFilestoreData_ * filestore_ctx
Definition: detect.h:762
AppLayerParserSetStreamDepthFlag
void AppLayerParserSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void *state, uint64_t tx_id, uint8_t flags)
Definition: app-layer-parser.c:1814
DetectParseRegex
Definition: detect-parse.h:94
g_filedata_logger_enabled
bool g_filedata_logger_enabled
Definition: output-filedata.c:37
DetectFilestoreData_::scope
int16_t scope
Definition: detect-filestore.h:38
SigTableElmt_::name
const char * name
Definition: detect.h:1542
DetectEngineThreadCtx_::filestore
struct DetectEngineThreadCtx_::@103 filestore[DETECT_FILESTORE_MAX]
stream-tcp.h
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:101
FILESTORE_DIR_DEFAULT
#define FILESTORE_DIR_DEFAULT
Definition: detect-filestore.h:27
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1533
Signature_::alproto
AppProto alproto
Definition: detect.h:697
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
Flow_::proto
uint8_t proto
Definition: flow.h:381
DetectEngineThreadCtx_::tx_id
uint64_t tx_id
Definition: detect.h:1392
ssn
TcpSession ssn
Definition: fuzz_dataset.c:31
threads.h
AppLayerStateData
Definition: app-layer-parser.h:155
Flow_
Flow data structure.
Definition: flow.h:359
SigTableElmt_::FileMatch
int(* FileMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, File *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1512
DETECT_FILESTORE
@ DETECT_FILESTORE
Definition: detect-engine-register.h:227
ctx
struct Thresholds ctx
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:995
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2912
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:236
DE_QUIET
#define DE_QUIET
Definition: detect.h:334
p
Packet * p
Definition: fuzz_dataset.c:30
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:4025
m
SCMutex m
Definition: flow-hash.h:6
AppLayerParserGetStateData
AppLayerStateData * AppLayerParserGetStateData(uint8_t ipproto, AppProto alproto, void *state)
Definition: app-layer-parser.c:1427
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:3971
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:547
Flow_::protoctx
void * protoctx
Definition: flow.h:438
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1524
DetectEngineCtx_::version
uint32_t version
Definition: detect.h:1080
util-unittest-helper.h
AppLayerParserGetTxFiles
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
Definition: app-layer-parser.c:963
FILESTORE_SCOPE_TX
#define FILESTORE_SCOPE_TX
Definition: detect-filestore.h:33
DETECT_SM_LIST_POSTMATCH
@ DETECT_SM_LIST_POSTMATCH
Definition: detect.h:128
app-layer-htp.h
File_::file_track_id
uint32_t file_track_id
Definition: util-file.h:151
feature.h
decode.h
FAIL_IF_NOT_NULL
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
Definition: util-unittest.h:96
util-debug.h
DETECT_FILESTORE_MAX
#define DETECT_FILESTORE_MAX
Definition: detect.h:1259
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
AppLayerTxData
Definition: app-layer-parser.h:172
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:22
DetectEngineThreadCtx_
Definition: detect.h:1316
FILESTORE_SCOPE_SSN
#define FILESTORE_SCOPE_SSN
Definition: detect-filestore.h:34
SIG_FLAG_BYPASS
#define SIG_FLAG_BYPASS
Definition: detect.h:279
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:4151
File_::sid_max
uint32_t sid_max
Definition: util-file.h:177
STREAM_FLAGS_FOR_PACKET
#define STREAM_FLAGS_FOR_PACKET(p)
Definition: stream.h:30
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
detect-engine-mpm.h
SCSigMatchAppendSMToList
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:424
detect.h
FileStoreFileById
void FileStoreFileById(FileContainer *fc, uint32_t file_id)
flag a file with id "file_id" to be stored.
Definition: util-file.c:1145
DetectEngineCtx_::filestore_cnt
uint16_t filestore_cnt
Definition: detect.h:1208
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
app-layer-parser.h
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:322
FileReassemblyDepth
uint32_t FileReassemblyDepth(void)
Definition: util-file.c:133
Signature_::flags
uint32_t flags
Definition: detect.h:693
Packet_
Definition: decode.h:516
DetectEngineThreadCtx_::filestore_cnt
uint16_t filestore_cnt
Definition: detect.h:1358
FILESTORE_DIR_TOCLIENT
#define FILESTORE_DIR_TOCLIENT
Definition: detect-filestore.h:29
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
detect-filestore.h
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1504
File_::sid
uint32_t * sid
Definition: util-file.h:175
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:237
File_::sid_cnt
uint32_t sid_cnt
Definition: util-file.h:176
RunmodeIsUnittests
int RunmodeIsUnittests(void)
Definition: suricata.c:293
AppLayerParserGetTx
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
Definition: app-layer-parser.c:1219
SCRealloc
#define SCRealloc(ptr, sz)
Definition: util-mem.h:50
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:355
FILESTORE_DIR_BOTH
#define FILESTORE_DIR_BOTH
Definition: detect-filestore.h:30
FILESTORE_DIR_TOSERVER
#define FILESTORE_DIR_TOSERVER
Definition: detect-filestore.h:28
DetectFilestoreRegister
void DetectFilestoreRegister(void)
Registration function for keyword: filestore.
Definition: detect-filestore.c:78
File_
Definition: util-file.h:146
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
FEATURE_OUTPUT_FILESTORE
#define FEATURE_OUTPUT_FILESTORE
Definition: feature.h:28
FAIL_IF
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Definition: util-unittest.h:71
DetectBufferTypeRegister
int DetectBufferTypeRegister(const char *name)
Definition: detect-engine.c:1388
flags
uint8_t flags
Definition: decode-gre.h:0
AppLayerGetFileState
Definition: util-file.h:44
suricata-common.h
AppLayerGetFileState::fc
FileContainer * fc
Definition: util-file.h:45
SIGMATCH_OPTIONAL_OPT
#define SIGMATCH_OPTIONAL_OPT
Definition: detect-engine-register.h:315
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:36
AppLayerParserGetTxData
AppLayerTxData * AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
Definition: app-layer-parser.c:1420
util-spm-bm.h
util-validate.h
DetectFilestoreData_
Definition: detect-filestore.h:36
str
#define str(s)
Definition: suricata-common.h:313
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
PARSE_REGEX
#define PARSE_REGEX
Regex for parsing our flow options.
Definition: detect-filestore.c:60
SCFree
#define SCFree(p)
Definition: util-mem.h:61
TcpSessionSetReassemblyDepth
void TcpSessionSetReassemblyDepth(TcpSession *ssn, uint32_t size)
Definition: stream-tcp.c:7305
Flow_::alstate
void * alstate
Definition: flow.h:484
Signature_::id
uint32_t id
Definition: detect.h:741
DetectFilestoreData_::direction
int16_t direction
Definition: detect-filestore.h:37
detect-parse.h
Signature_
Signature container.
Definition: detect.h:692
SCRequiresFeature
bool SCRequiresFeature(const char *feature_name)
Definition: feature.c:121
ALPROTO_HTTP
@ ALPROTO_HTTP
Definition: app-layer-protos.h:77
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2873
FILESTORE_SCOPE_DEFAULT
#define FILESTORE_SCOPE_DEFAULT
Definition: detect-filestore.h:32
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:997
TcpSession_
Definition: stream-tcp-private.h:283
AppLayerTxData::file_flags
uint16_t file_flags
Definition: app-layer-parser.h:192
flow.h
Flow_::file_flags
uint16_t file_flags
Definition: flow.h:410
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:455
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
flow-var.h
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
SIG_FLAG_FILESTORE
#define SIG_FLAG_FILESTORE
Definition: detect.h:272
AppLayerStateData::file_flags
uint16_t file_flags
Definition: app-layer-parser.h:156
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1531
DetectEngineThreadCtx_::file_id
uint32_t file_id
Definition: detect.h:1440
app-layer.h
DETECT_FILESTORE_POSTMATCH
@ DETECT_FILESTORE_POSTMATCH
Definition: detect-engine-register.h:228
f
Flow f
Definition: fuzz_dataset.c:32