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 = SCMalloc(sizeof(DetectThresholdData));
143  if (unlikely(df == NULL))
144  goto error;
145 
146  memset(df, 0, sizeof(DetectThresholdData));
147 
148  df->type = TYPE_DETECTION;
149 
150  for (i = 0; i < (ret - 1); i++) {
151  res = pcre2_substring_get_bynumber(match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
152  if (res < 0) {
153  SCLogError("pcre2_substring_get_bynumber failed");
154  goto error;
155  }
156 
157  args[i] = (char *)str_ptr;
158 
159  if (strncasecmp(args[i], "by_dst", strlen("by_dst")) == 0)
160  df->track = TRACK_DST;
161  if (strncasecmp(args[i], "by_src", strlen("by_src")) == 0)
162  df->track = TRACK_SRC;
163  if (strncasecmp(args[i], "count", strlen("count")) == 0)
164  count_pos = i + 1;
165  if (strncasecmp(args[i], "seconds", strlen("seconds")) == 0)
166  seconds_pos = i + 1;
167  }
168 
169  if (args[count_pos] == NULL || args[seconds_pos] == NULL) {
170  goto error;
171  }
172 
173  if (StringParseUint32(&df->count, 10, strlen(args[count_pos]), args[count_pos]) <= 0) {
174  goto error;
175  }
176 
177  if (StringParseUint32(&df->seconds, 10, strlen(args[seconds_pos]), args[seconds_pos]) <= 0) {
178  goto error;
179  }
180 
181  if (df->count == 0 || df->seconds == 0) {
182  SCLogError("found an invalid value");
183  goto error;
184  }
185 
186  for (i = 0; i < 6; i++) {
187  if (args[i] != NULL)
188  pcre2_substring_free((PCRE2_UCHAR *)args[i]);
189  }
190 
191  pcre2_match_data_free(match);
192  return df;
193 
194 error:
195  for (i = 0; i < 6; i++) {
196  if (args[i] != NULL)
197  pcre2_substring_free((PCRE2_UCHAR *)args[i]);
198  }
199  if (df != NULL)
200  SCFree(df);
201  if (match) {
202  pcre2_match_data_free(match);
203  }
204  return NULL;
205 }
206 
207 /**
208  * \internal
209  * \brief this function is used to add the parsed detection_filter into the current signature
210  *
211  * \param de_ctx pointer to the Detection Engine Context
212  * \param s pointer to the Current Signature
213  * \param m pointer to the Current SigMatch
214  * \param rawstr pointer to the user provided detection_filter options
215  *
216  * \retval 0 on Success
217  * \retval -1 on Failure
218  */
219 static int DetectDetectionFilterSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
220 {
221  SCEnter();
222  DetectThresholdData *df = NULL;
223  SigMatch *sm = NULL;
224  SigMatch *tmpm = NULL;
225 
226  /* checks if there's a previous instance of threshold */
228  if (tmpm != NULL) {
229  SCLogError("\"detection_filter\" and \"threshold\" are not allowed in the same rule");
230  SCReturnInt(-1);
231  }
232  /* checks there's no previous instance of detection_filter */
234  if (tmpm != NULL) {
235  SCLogError("At most one \"detection_filter\" is allowed per rule");
236  SCReturnInt(-1);
237  }
238 
239  df = DetectDetectionFilterParse(rawstr);
240  if (df == NULL)
241  goto error;
242 
243  sm = SigMatchAlloc();
244  if (sm == NULL)
245  goto error;
246 
248  sm->ctx = (SigMatchCtx *)df;
249 
251 
252  return 0;
253 
254 error:
255  if (df)
256  SCFree(df);
257  if (sm)
258  SCFree(sm);
259  return -1;
260 }
261 
262 /**
263  * \internal
264  * \brief this function will free memory associated with DetectThresholdData
265  *
266  * \param df_ptr pointer to DetectDetectionFilterData
267  */
268 static void DetectDetectionFilterFree(DetectEngineCtx *de_ctx, void *df_ptr)
269 {
271  if (df)
272  SCFree(df);
273 }
274 
275 /*
276  * ONLY TESTS BELOW THIS COMMENT
277  */
278 #ifdef UNITTESTS
279 #include "detect-engine.h"
280 #include "detect-engine-mpm.h"
281 #include "detect-engine-threshold.h"
282 #include "detect-engine-alert.h"
283 #include "util-time.h"
284 #include "util-hashlist.h"
285 #include "action-globals.h"
286 #include "packet.h"
287 
288 /**
289  * \test DetectDetectionFilterTestParse01 is a test for a valid detection_filter options
290  *
291  */
292 static int DetectDetectionFilterTestParse01(void)
293 {
294  DetectThresholdData *df = DetectDetectionFilterParse("track by_dst,count 10,seconds 60");
295  FAIL_IF_NULL(df);
296  FAIL_IF_NOT(df->track == TRACK_DST);
297  FAIL_IF_NOT(df->count == 10);
298  FAIL_IF_NOT(df->seconds == 60);
299  DetectDetectionFilterFree(NULL, df);
300 
301  PASS;
302 }
303 
304 /**
305  * \test DetectDetectionFilterTestParse02 is a test for a invalid detection_filter options
306  *
307  */
308 static int DetectDetectionFilterTestParse02(void)
309 {
310  DetectThresholdData *df = DetectDetectionFilterParse("track both,count 10,seconds 60");
311  FAIL_IF_NOT_NULL(df);
312 
313  PASS;
314 }
315 
316 /**
317  * \test DetectDetectionfilterTestParse03 is a test for a valid detection_filter options in any
318  * order
319  *
320  */
321 static int DetectDetectionFilterTestParse03(void)
322 {
323  DetectThresholdData *df = DetectDetectionFilterParse("track by_dst, seconds 60, count 10");
324  FAIL_IF_NULL(df);
325  FAIL_IF_NOT(df->track == TRACK_DST);
326  FAIL_IF_NOT(df->count == 10);
327  FAIL_IF_NOT(df->seconds == 60);
328  DetectDetectionFilterFree(NULL, df);
329 
330  PASS;
331 }
332 
333 /**
334  * \test DetectDetectionFilterTestParse04 is a test for an invalid detection_filter options in any
335  * order
336  *
337  */
338 static int DetectDetectionFilterTestParse04(void)
339 {
340  DetectThresholdData *df =
341  DetectDetectionFilterParse("count 10, track by_dst, seconds 60, count 10");
342  FAIL_IF_NOT_NULL(df);
343 
344  PASS;
345 }
346 
347 /**
348  * \test DetectDetectionFilterTestParse05 is a test for a valid detection_filter options in any
349  * order
350  *
351  */
352 static int DetectDetectionFilterTestParse05(void)
353 {
354  DetectThresholdData *df = DetectDetectionFilterParse("count 10, track by_dst, seconds 60");
355  FAIL_IF_NULL(df);
356  FAIL_IF_NOT(df->track == TRACK_DST);
357  FAIL_IF_NOT(df->count == 10);
358  FAIL_IF_NOT(df->seconds == 60);
359  DetectDetectionFilterFree(NULL, df);
360 
361  PASS;
362 }
363 
364 /**
365  * \test DetectDetectionFilterTestParse06 is a test for an invalid value in detection_filter
366  *
367  */
368 static int DetectDetectionFilterTestParse06(void)
369 {
370  DetectThresholdData *df = DetectDetectionFilterParse("count 10, track by_dst, seconds 0");
371  FAIL_IF_NOT_NULL(df);
372 
373  PASS;
374 }
375 
376 /**
377  * \test DetectDetectionFilterTestSig1 is a test for checking the working of detection_filter
378  * keyword by setting up the signature and later testing its working by matching the received packet
379  * against the sig.
380  *
381  */
382 static int DetectDetectionFilterTestSig1(void)
383 {
384  ThreadVars th_v;
385  DetectEngineThreadCtx *det_ctx;
386 
388 
389  memset(&th_v, 0, sizeof(th_v));
390 
391  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
392 
395 
396  de_ctx->flags |= DE_QUIET;
397 
399  "alert tcp any any -> any 80 (msg:\"detection_filter Test\"; detection_filter: "
400  "track by_dst, count 4, seconds 60; sid:1;)");
401  FAIL_IF_NULL(s);
402 
404  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
405 
406  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
407  FAIL_IF(PacketAlertCheck(p, 1));
408  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
409  FAIL_IF(PacketAlertCheck(p, 1));
410  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
411  FAIL_IF(PacketAlertCheck(p, 1));
412  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
413  FAIL_IF(PacketAlertCheck(p, 1));
414  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
416  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
418  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
420  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
422 
423  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
425 
426  UTHFreePackets(&p, 1);
427  HostShutdown();
428 
429  PASS;
430 }
431 
432 /**
433  * \test DetectDetectionFilterTestSig2 is a test for checking the working of detection_filter
434  * keyword by setting up the signature and later testing its working by matching the received packet
435  * against the sig.
436  *
437  */
438 
439 static int DetectDetectionFilterTestSig2(void)
440 {
441  ThreadVars th_v;
442  DetectEngineThreadCtx *det_ctx;
443 
445 
446  memset(&th_v, 0, sizeof(th_v));
447 
448  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
449 
451 
453 
454  de_ctx->flags |= DE_QUIET;
455 
457  "alert tcp any any -> any 80 (msg:\"detection_filter Test 2\"; "
458  "detection_filter: track by_dst, count 4, seconds 60; sid:10;)");
459  FAIL_IF_NULL(s);
460 
462  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
463 
464  p->ts = TimeGet();
465 
466  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
467  FAIL_IF(PacketAlertCheck(p, 10));
468  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
469  FAIL_IF(PacketAlertCheck(p, 10));
470  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
471  FAIL_IF(PacketAlertCheck(p, 10));
472 
474  p->ts = TimeGet();
475 
476  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
477  FAIL_IF(PacketAlertCheck(p, 10));
478  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
479  FAIL_IF(PacketAlertCheck(p, 10));
480  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
481  FAIL_IF(PacketAlertCheck(p, 10));
482  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
483  FAIL_IF(PacketAlertCheck(p, 10));
484 
485  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
487 
488  UTHFreePackets(&p, 1);
489  HostShutdown();
490 
491  PASS;
492 }
493 
494 /**
495  * \test drops
496  */
497 static int DetectDetectionFilterTestSig3(void)
498 {
499  ThreadVars th_v;
500  DetectEngineThreadCtx *det_ctx;
501 
503 
504  memset(&th_v, 0, sizeof(th_v));
505 
506  Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
507 
510 
511  de_ctx->flags |= DE_QUIET;
512 
514  "drop tcp any any -> any 80 (msg:\"detection_filter Test 2\"; "
515  "detection_filter: track by_dst, count 2, seconds 60; sid:10;)");
516  FAIL_IF_NULL(s);
517 
519  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
520 
521  p->ts = TimeGet();
522 
523  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
524  FAIL_IF(PacketAlertCheck(p, 10));
525  FAIL_IF(PacketTestAction(p, ACTION_DROP));
526  p->action = 0;
527 
528  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
529  FAIL_IF(PacketAlertCheck(p, 10));
530  FAIL_IF(PacketTestAction(p, ACTION_DROP));
531  p->action = 0;
532 
533  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
535  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
536  p->action = 0;
537 
539  p->ts = TimeGet();
540 
541  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
542  FAIL_IF(PacketAlertCheck(p, 10));
543  FAIL_IF(PacketTestAction(p, ACTION_DROP));
544  p->action = 0;
545 
546  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
547  FAIL_IF(PacketAlertCheck(p, 10));
548  FAIL_IF(PacketTestAction(p, ACTION_DROP));
549  p->action = 0;
550 
551  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
553  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
554  p->action = 0;
555 
556  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
558  FAIL_IF_NOT(PacketTestAction(p, ACTION_DROP));
559  p->action = 0;
560 
561  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
563 
564  UTHFreePackets(&p, 1);
565  HostShutdown();
566 
567  PASS;
568 }
569 
570 static void DetectDetectionFilterRegisterTests(void)
571 {
572  UtRegisterTest("DetectDetectionFilterTestParse01", DetectDetectionFilterTestParse01);
573  UtRegisterTest("DetectDetectionFilterTestParse02", DetectDetectionFilterTestParse02);
574  UtRegisterTest("DetectDetectionFilterTestParse03", DetectDetectionFilterTestParse03);
575  UtRegisterTest("DetectDetectionFilterTestParse04", DetectDetectionFilterTestParse04);
576  UtRegisterTest("DetectDetectionFilterTestParse05", DetectDetectionFilterTestParse05);
577  UtRegisterTest("DetectDetectionFilterTestParse06", DetectDetectionFilterTestParse06);
578  UtRegisterTest("DetectDetectionFilterTestSig1", DetectDetectionFilterTestSig1);
579  UtRegisterTest("DetectDetectionFilterTestSig2", DetectDetectionFilterTestSig2);
580  UtRegisterTest("DetectDetectionFilterTestSig3", DetectDetectionFilterTestSig3);
581 }
582 #endif /* UNITTESTS */
util-byte.h
host.h
SigTableElmt_::url
const char * url
Definition: detect.h:1287
detect-engine.h
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
SigMatchAppendSMToList
void SigMatchAppendSMToList(Signature *s, SigMatch *new, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:437
SigTableElmt_::desc
const char * desc
Definition: detect.h:1286
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1274
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:1284
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:55
action-globals.h
Packet_::action
uint8_t action
Definition: decode.h:581
DETECT_SM_LIST_THRESHOLD
@ DETECT_SM_LIST_THRESHOLD
Definition: detect.h:124
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1278
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:826
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2592
TRACK_DST
#define TRACK_DST
Definition: detect-detection-filter.c:43
DE_QUIET
#define DE_QUIET
Definition: detect.h:314
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1824
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:2623
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2569
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:1269
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:57
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:1074
Packet_::ts
SCTime_t ts
Definition: decode.h:475
DETECT_THRESHOLD
@ DETECT_THRESHOLD
Definition: detect-engine-register.h:57
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2747
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
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:343
TimeSetIncrementTime
void TimeSetIncrementTime(uint32_t tv_sec)
increment the time in the engine
Definition: util-time.c:180
Packet_
Definition: decode.h:430
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:1252
SigMatchAlloc
SigMatch * SigMatchAlloc(void)
Definition: detect-parse.c:322
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:1973
DetectThresholdData_::track
uint8_t track
Definition: detect-threshold.h:58
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:335
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3308
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:3522
SigMatch_::type
uint16_t type
Definition: detect.h:341
DetectThresholdData_
Definition: detect-threshold.h:54
packet.h
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:129
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:306
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
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:581
SigMatch_
a single match condition for a signature
Definition: detect.h:340
detect-threshold.h
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2553
suricata.h
TRACK_SRC
#define TRACK_SRC
Definition: detect-detection-filter.c:44
HostInitConfig
void HostInitConfig(bool quiet)
initialize the configuration
Definition: host.c:175
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:586
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:828
DetectThresholdData_::seconds
uint32_t seconds
Definition: detect-threshold.h:56
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
SIGMATCH_IPONLY_COMPAT
#define SIGMATCH_IPONLY_COMPAT
Definition: detect.h:1468
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1276
detect-engine-threshold.h
TYPE_DETECTION
#define TYPE_DETECTION
Definition: detect-threshold.h:31
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:468