suricata
detect-detection-filter.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2020 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 Gerardo Iglesias <iglesiasg@gmail.com>
22  *
23  * Implements the detection_filter keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "suricata.h"
28 #include "decode.h"
29 #include "detect.h"
30 
31 #include "host.h"
32 
34 #include "detect-threshold.h"
35 #include "detect-parse.h"
36 
37 #include "util-byte.h"
38 #include "util-unittest.h"
39 #include "util-unittest-helper.h"
40 #include "util-debug.h"
41 #include "detect-engine-build.h"
42 
43 #define TRACK_DST 1
44 #define TRACK_SRC 2
45 
46 /**
47  *\brief Regex for parsing our detection_filter options
48  */
49 #define PARSE_REGEX \
50  "^\\s*(track|count|seconds)\\s+(by_src|by_dst|\\d+)\\s*,\\s*(track|count|seconds)\\s+(by_src|" \
51  "by_dst|\\d+)\\s*,\\s*(track|count|seconds)\\s+(by_src|by_dst|\\d+)\\s*$"
52 
53 static DetectParseRegex parse_regex;
54 
55 static int DetectDetectionFilterMatch(
56  DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *);
57 static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, const char *);
58 #ifdef UNITTESTS
59 static void DetectDetectionFilterRegisterTests(void);
60 #endif
61 static void DetectDetectionFilterFree(DetectEngineCtx *, void *);
62 
63 /**
64  * \brief Registration function for detection_filter: keyword
65  */
67 {
68  sigmatch_table[DETECT_DETECTION_FILTER].name = "detection_filter";
70  "alert on every match after a threshold has been reached";
71  sigmatch_table[DETECT_DETECTION_FILTER].url = "/rules/thresholding.html#detection-filter";
72  sigmatch_table[DETECT_DETECTION_FILTER].Match = DetectDetectionFilterMatch;
73  sigmatch_table[DETECT_DETECTION_FILTER].Setup = DetectDetectionFilterSetup;
74  sigmatch_table[DETECT_DETECTION_FILTER].Free = DetectDetectionFilterFree;
75 #ifdef UNITTESTS
76  sigmatch_table[DETECT_DETECTION_FILTER].RegisterTests = DetectDetectionFilterRegisterTests;
77 #endif
78  /* this is compatible to ip-only signatures */
80 
81  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
82 }
83 
84 static int DetectDetectionFilterMatch(
85  DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx)
86 {
87  return 1;
88 }
89 
90 /**
91  * \internal
92  * \brief This function is used to parse detection_filter options passed via detection_filter:
93  * keyword
94  *
95  * \param rawstr Pointer to the user provided detection_filter options
96  *
97  * \retval df pointer to DetectThresholdData on success
98  * \retval NULL on failure
99  */
100 static DetectThresholdData *DetectDetectionFilterParse(const char *rawstr)
101 {
102  DetectThresholdData *df = NULL;
103  int res = 0;
104  size_t pcre2_len;
105  const char *str_ptr = NULL;
106  char *args[6] = { NULL, NULL, NULL, NULL, NULL, NULL };
107  char *copy_str = NULL, *df_opt = NULL;
108  int seconds_found = 0, count_found = 0, track_found = 0;
109  int seconds_pos = 0, count_pos = 0;
110  size_t pos = 0;
111  int i = 0;
112  char *saveptr = NULL;
113  pcre2_match_data *match = NULL;
114 
115  copy_str = SCStrdup(rawstr);
116  if (unlikely(copy_str == NULL)) {
117  goto error;
118  }
119 
120  for (pos = 0, df_opt = strtok_r(copy_str, ",", &saveptr);
121  pos < strlen(copy_str) && df_opt != NULL;
122  pos++, df_opt = strtok_r(NULL, ",", &saveptr)) {
123  if (strstr(df_opt, "count"))
124  count_found++;
125  if (strstr(df_opt, "second"))
126  seconds_found++;
127  if (strstr(df_opt, "track"))
128  track_found++;
129  }
130  SCFree(copy_str);
131  copy_str = NULL;
132 
133  if (count_found != 1 || seconds_found != 1 || track_found != 1)
134  goto error;
135 
136  int ret = DetectParsePcreExec(&parse_regex, &match, rawstr, 0, 0);
137  if (ret < 5) {
138  SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
139  goto error;
140  }
141 
142  df = SCCalloc(1, sizeof(DetectThresholdData));
143  if (unlikely(df == NULL))
144  goto error;
145 
146  df->type = TYPE_DETECTION;
147 
148  for (i = 0; i < (ret - 1); i++) {
149  res = pcre2_substring_get_bynumber(match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
150  if (res < 0) {
151  SCLogError("pcre2_substring_get_bynumber failed");
152  goto error;
153  }
154 
155  args[i] = (char *)str_ptr;
156 
157  if (strncasecmp(args[i], "by_dst", strlen("by_dst")) == 0)
158  df->track = TRACK_DST;
159  if (strncasecmp(args[i], "by_src", strlen("by_src")) == 0)
160  df->track = TRACK_SRC;
161  if (strncasecmp(args[i], "count", strlen("count")) == 0)
162  count_pos = i + 1;
163  if (strncasecmp(args[i], "seconds", strlen("seconds")) == 0)
164  seconds_pos = i + 1;
165  }
166 
167  if (args[count_pos] == NULL || args[seconds_pos] == NULL) {
168  goto error;
169  }
170 
171  if (StringParseUint32(&df->count, 10, strlen(args[count_pos]), args[count_pos]) <= 0) {
172  goto error;
173  }
174 
175  if (StringParseUint32(&df->seconds, 10, strlen(args[seconds_pos]), args[seconds_pos]) <= 0) {
176  goto error;
177  }
178 
179  if (df->count == 0 || df->seconds == 0) {
180  SCLogError("found an invalid value");
181  goto error;
182  }
183 
184  for (i = 0; i < 6; i++) {
185  if (args[i] != NULL)
186  pcre2_substring_free((PCRE2_UCHAR *)args[i]);
187  }
188 
189  pcre2_match_data_free(match);
190  return df;
191 
192 error:
193  for (i = 0; i < 6; i++) {
194  if (args[i] != NULL)
195  pcre2_substring_free((PCRE2_UCHAR *)args[i]);
196  }
197  if (df != NULL)
198  SCFree(df);
199  if (match) {
200  pcre2_match_data_free(match);
201  }
202  return NULL;
203 }
204 
205 /**
206  * \internal
207  * \brief this function is used to add the parsed detection_filter into the current signature
208  *
209  * \param de_ctx pointer to the Detection Engine Context
210  * \param s pointer to the Current Signature
211  * \param m pointer to the Current SigMatch
212  * \param rawstr pointer to the user provided detection_filter options
213  *
214  * \retval 0 on Success
215  * \retval -1 on Failure
216  */
217 static int DetectDetectionFilterSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
218 {
219  SCEnter();
220  DetectThresholdData *df = NULL;
221  SigMatch *tmpm = NULL;
222 
223  /* checks if there's a previous instance of threshold */
225  if (tmpm != NULL) {
226  SCLogError("\"detection_filter\" and \"threshold\" are not allowed in the same rule");
227  SCReturnInt(-1);
228  }
229  /* checks there's no previous instance of detection_filter */
231  if (tmpm != NULL) {
232  SCLogError("At most one \"detection_filter\" is allowed per rule");
233  SCReturnInt(-1);
234  }
235 
236  df = DetectDetectionFilterParse(rawstr);
237  if (df == NULL)
238  goto error;
239 
241  DETECT_SM_LIST_THRESHOLD) == NULL) {
242  goto error;
243  }
244 
245  return 0;
246 
247 error:
248  if (df)
249  SCFree(df);
250  return -1;
251 }
252 
253 /**
254  * \internal
255  * \brief this function will free memory associated with DetectThresholdData
256  *
257  * \param df_ptr pointer to DetectDetectionFilterData
258  */
259 static void DetectDetectionFilterFree(DetectEngineCtx *de_ctx, void *df_ptr)
260 {
262  if (df)
263  SCFree(df);
264 }
265 
266 /*
267  * ONLY TESTS BELOW THIS COMMENT
268  */
269 #ifdef UNITTESTS
270 #include "detect-engine.h"
271 #include "detect-engine-mpm.h"
272 #include "detect-engine-threshold.h"
273 #include "detect-engine-alert.h"
274 #include "util-time.h"
275 #include "util-hashlist.h"
276 #include "action-globals.h"
277 #include "packet.h"
278 
279 /**
280  * \test DetectDetectionFilterTestParse01 is a test for a valid detection_filter options
281  *
282  */
283 static int DetectDetectionFilterTestParse01(void)
284 {
285  DetectThresholdData *df = DetectDetectionFilterParse("track by_dst,count 10,seconds 60");
286  FAIL_IF_NULL(df);
287  FAIL_IF_NOT(df->track == TRACK_DST);
288  FAIL_IF_NOT(df->count == 10);
289  FAIL_IF_NOT(df->seconds == 60);
290  DetectDetectionFilterFree(NULL, df);
291 
292  PASS;
293 }
294 
295 /**
296  * \test DetectDetectionFilterTestParse02 is a test for a invalid detection_filter options
297  *
298  */
299 static int DetectDetectionFilterTestParse02(void)
300 {
301  DetectThresholdData *df = DetectDetectionFilterParse("track both,count 10,seconds 60");
302  FAIL_IF_NOT_NULL(df);
303 
304  PASS;
305 }
306 
307 /**
308  * \test DetectDetectionfilterTestParse03 is a test for a valid detection_filter options in any
309  * order
310  *
311  */
312 static int DetectDetectionFilterTestParse03(void)
313 {
314  DetectThresholdData *df = DetectDetectionFilterParse("track by_dst, seconds 60, count 10");
315  FAIL_IF_NULL(df);
316  FAIL_IF_NOT(df->track == TRACK_DST);
317  FAIL_IF_NOT(df->count == 10);
318  FAIL_IF_NOT(df->seconds == 60);
319  DetectDetectionFilterFree(NULL, df);
320 
321  PASS;
322 }
323 
324 /**
325  * \test DetectDetectionFilterTestParse04 is a test for an invalid detection_filter options in any
326  * order
327  *
328  */
329 static int DetectDetectionFilterTestParse04(void)
330 {
331  DetectThresholdData *df =
332  DetectDetectionFilterParse("count 10, track by_dst, seconds 60, count 10");
333  FAIL_IF_NOT_NULL(df);
334 
335  PASS;
336 }
337 
338 /**
339  * \test DetectDetectionFilterTestParse05 is a test for a valid detection_filter options in any
340  * order
341  *
342  */
343 static int DetectDetectionFilterTestParse05(void)
344 {
345  DetectThresholdData *df = DetectDetectionFilterParse("count 10, track by_dst, seconds 60");
346  FAIL_IF_NULL(df);
347  FAIL_IF_NOT(df->track == TRACK_DST);
348  FAIL_IF_NOT(df->count == 10);
349  FAIL_IF_NOT(df->seconds == 60);
350  DetectDetectionFilterFree(NULL, df);
351 
352  PASS;
353 }
354 
355 /**
356  * \test DetectDetectionFilterTestParse06 is a test for an invalid value in detection_filter
357  *
358  */
359 static int DetectDetectionFilterTestParse06(void)
360 {
361  DetectThresholdData *df = DetectDetectionFilterParse("count 10, track by_dst, seconds 0");
362  FAIL_IF_NOT_NULL(df);
363 
364  PASS;
365 }
366 
367 /**
368  * \test DetectDetectionFilterTestSig1 is a test for checking the working of detection_filter
369  * keyword by setting up the signature and later testing its working by matching the received packet
370  * against the sig.
371  *
372  */
373 static int DetectDetectionFilterTestSig1(void)
374 {
375  ThreadVars th_v;
376  DetectEngineThreadCtx *det_ctx;
377 
379 
380  memset(&th_v, 0, sizeof(th_v));
381 
382  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
383 
386 
387  de_ctx->flags |= DE_QUIET;
388 
390  "alert tcp any any -> any 80 (msg:\"detection_filter Test\"; detection_filter: "
391  "track by_dst, count 4, seconds 60; sid:1;)");
392  FAIL_IF_NULL(s);
393 
395  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
396 
397  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
398  FAIL_IF(PacketAlertCheck(p, 1));
399  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
400  FAIL_IF(PacketAlertCheck(p, 1));
401  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
402  FAIL_IF(PacketAlertCheck(p, 1));
403  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
404  FAIL_IF(PacketAlertCheck(p, 1));
405  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
407  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
409  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
411  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
413 
414  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
416 
417  UTHFreePackets(&p, 1);
418  HostShutdown();
419 
420  PASS;
421 }
422 
423 /**
424  * \test DetectDetectionFilterTestSig2 is a test for checking the working of detection_filter
425  * keyword by setting up the signature and later testing its working by matching the received packet
426  * against the sig.
427  *
428  */
429 
430 static int DetectDetectionFilterTestSig2(void)
431 {
432  ThreadVars th_v;
433  DetectEngineThreadCtx *det_ctx;
434 
436 
437  memset(&th_v, 0, sizeof(th_v));
438 
439  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
440 
442 
444 
445  de_ctx->flags |= DE_QUIET;
446 
448  "alert tcp any any -> any 80 (msg:\"detection_filter Test 2\"; "
449  "detection_filter: track by_dst, count 4, seconds 60; sid:10;)");
450  FAIL_IF_NULL(s);
451 
453  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
454 
455  p->ts = TimeGet();
456 
457  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
458  FAIL_IF(PacketAlertCheck(p, 10));
459  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
460  FAIL_IF(PacketAlertCheck(p, 10));
461  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
462  FAIL_IF(PacketAlertCheck(p, 10));
463 
465  p->ts = TimeGet();
466 
467  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
468  FAIL_IF(PacketAlertCheck(p, 10));
469  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
470  FAIL_IF(PacketAlertCheck(p, 10));
471  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
472  FAIL_IF(PacketAlertCheck(p, 10));
473  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
474  FAIL_IF(PacketAlertCheck(p, 10));
475 
476  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
478 
479  UTHFreePackets(&p, 1);
480  HostShutdown();
481 
482  PASS;
483 }
484 
485 /**
486  * \test drops
487  */
488 static int DetectDetectionFilterTestSig3(void)
489 {
490  ThreadVars th_v;
491  DetectEngineThreadCtx *det_ctx;
492 
494 
495  memset(&th_v, 0, sizeof(th_v));
496 
497  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
498 
501 
502  de_ctx->flags |= DE_QUIET;
503 
505  "drop tcp any any -> any 80 (msg:\"detection_filter Test 2\"; "
506  "detection_filter: track by_dst, count 2, seconds 60; sid:10;)");
507  FAIL_IF_NULL(s);
508 
510  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
511 
512  p->ts = TimeGet();
513 
514  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
515  FAIL_IF(PacketAlertCheck(p, 10));
516  FAIL_IF(PacketTestAction(p, ACTION_DROP));
517  p->action = 0;
518 
519  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
520  FAIL_IF(PacketAlertCheck(p, 10));
521  FAIL_IF(PacketTestAction(p, ACTION_DROP));
522  p->action = 0;
523 
524  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
526  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
527  p->action = 0;
528 
530  p->ts = TimeGet();
531 
532  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
533  FAIL_IF(PacketAlertCheck(p, 10));
534  FAIL_IF(PacketTestAction(p, ACTION_DROP));
535  p->action = 0;
536 
537  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
538  FAIL_IF(PacketAlertCheck(p, 10));
539  FAIL_IF(PacketTestAction(p, ACTION_DROP));
540  p->action = 0;
541 
542  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
544  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
545  p->action = 0;
546 
547  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
549  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
550  p->action = 0;
551 
552  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
554 
555  UTHFreePackets(&p, 1);
556  HostShutdown();
557 
558  PASS;
559 }
560 
561 static void DetectDetectionFilterRegisterTests(void)
562 {
563  UtRegisterTest("DetectDetectionFilterTestParse01", DetectDetectionFilterTestParse01);
564  UtRegisterTest("DetectDetectionFilterTestParse02", DetectDetectionFilterTestParse02);
565  UtRegisterTest("DetectDetectionFilterTestParse03", DetectDetectionFilterTestParse03);
566  UtRegisterTest("DetectDetectionFilterTestParse04", DetectDetectionFilterTestParse04);
567  UtRegisterTest("DetectDetectionFilterTestParse05", DetectDetectionFilterTestParse05);
568  UtRegisterTest("DetectDetectionFilterTestParse06", DetectDetectionFilterTestParse06);
569  UtRegisterTest("DetectDetectionFilterTestSig1", DetectDetectionFilterTestSig1);
570  UtRegisterTest("DetectDetectionFilterTestSig2", DetectDetectionFilterTestSig2);
571  UtRegisterTest("DetectDetectionFilterTestSig3", DetectDetectionFilterTestSig3);
572 }
573 #endif /* UNITTESTS */
util-byte.h
host.h
SigTableElmt_::url
const char * url
Definition: detect.h:1299
detect-engine.h
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
SigTableElmt_::desc
const char * desc
Definition: detect.h:1298
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1286
util-hashlist.h
PARSE_REGEX
#define PARSE_REGEX
Regex for parsing our detection_filter options.
Definition: detect-detection-filter.c:49
DetectParseRegex
Definition: detect-parse.h:62
SigTableElmt_::name
const char * name
Definition: detect.h:1296
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:103
PacketAlertCheck
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
Definition: detect-engine-alert.c:141
DetectThresholdData_::count
uint32_t count
Definition: detect-threshold.h:54
action-globals.h
Packet_::action
uint8_t action
Definition: decode.h:590
DETECT_SM_LIST_THRESHOLD
@ DETECT_SM_LIST_THRESHOLD
Definition: detect.h:130
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1290
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:839
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2533
TRACK_DST
#define TRACK_DST
Definition: detect-detection-filter.c:43
DE_QUIET
#define DE_QUIET
Definition: detect.h:324
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1897
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:2674
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2620
UTHBuildPacketReal
Packet * UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len, uint8_t ipproto, const char *src, const char *dst, uint16_t sport, uint16_t dport)
UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sou...
Definition: util-unittest-helper.c:244
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1281
util-unittest.h
util-unittest-helper.h
FAIL_IF_NOT
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
Definition: util-unittest.h:82
DetectThresholdData_::type
uint8_t type
Definition: detect-threshold.h:56
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
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
detect-detection-filter.h
DetectEngineThreadCtx_
Definition: detect.h:1095
Packet_::ts
SCTime_t ts
Definition: decode.h:485
DETECT_THRESHOLD
@ DETECT_THRESHOLD
Definition: detect-engine-register.h:57
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2800
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
StringParseUint32
int StringParseUint32(uint32_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:313
util-time.h
TimeSetIncrementTime
void TimeSetIncrementTime(uint32_t tv_sec)
increment the time in the engine
Definition: util-time.c:180
Packet_
Definition: decode.h:437
detect-engine-build.h
TimeGet
SCTime_t TimeGet(void)
Definition: util-time.c:152
detect-engine-alert.h
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1264
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2149
DetectThresholdData_::track
uint8_t track
Definition: detect-threshold.h:57
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:345
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3244
FAIL_IF
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Definition: util-unittest.h:71
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
Definition: detect-engine.c:3454
DetectThresholdData_
Definition: detect-threshold.h:53
packet.h
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:127
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
HOST_QUIET
#define HOST_QUIET
Definition: host.h:93
HostShutdown
void HostShutdown(void)
shutdown the flow engine
Definition: host.c:299
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
DETECT_DETECTION_FILTER
@ DETECT_DETECTION_FILTER
Definition: detect-engine-register.h:100
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
detect-parse.h
DetectDetectionFilterRegister
void DetectDetectionFilterRegister(void)
Registration function for detection_filter: keyword.
Definition: detect-detection-filter.c:66
Signature_
Signature container.
Definition: detect.h:596
SigMatch_
a single match condition for a signature
Definition: detect.h:350
detect-threshold.h
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2494
suricata.h
TRACK_SRC
#define TRACK_SRC
Definition: detect-detection-filter.c:44
HostInitConfig
void HostInitConfig(bool quiet)
initialize the configuration
Definition: host.c:168
DetectGetLastSMFromLists
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
Definition: detect-parse.c:619
SigMatchAppendSMToList
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:447
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:841
DetectThresholdData_::seconds
uint32_t seconds
Definition: detect-threshold.h:55
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
SIGMATCH_IPONLY_COMPAT
#define SIGMATCH_IPONLY_COMPAT
Definition: detect.h:1478
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1288
detect-engine-threshold.h
TYPE_DETECTION
#define TYPE_DETECTION
Definition: detect-threshold.h:30
UTHFreePackets
void UTHFreePackets(Packet **p, int numpkts)
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.
Definition: util-unittest-helper.c:431