suricata
detect-urilen.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 Gurvinder Singh <gurvindersighdahiya@gmail.com>
22  *
23  * Implements the urilen keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "app-layer.h"
28 #include "app-layer-protos.h"
29 #include "app-layer-htp.h"
30 #include "util-unittest.h"
31 #include "util-unittest-helper.h"
32 
33 #include "detect.h"
34 #include "detect-parse.h"
35 #include "detect-engine.h"
36 #include "detect-engine-state.h"
37 #include "detect-engine-build.h"
38 #include "detect-content.h"
39 #include "detect-engine-uint.h"
40 
41 #include "detect-urilen.h"
42 #include "util-debug.h"
43 #include "util-byte.h"
44 #include "flow-util.h"
45 #include "stream-tcp.h"
46 
47 
48 /*prototypes*/
49 static int DetectUrilenSetup (DetectEngineCtx *, Signature *, const char *);
50 static void DetectUrilenFree (DetectEngineCtx *, void *);
51 #ifdef UNITTESTS
52 static void DetectUrilenRegisterTests (void);
53 #endif
54 static int g_http_uri_buffer_id = 0;
55 static int g_http_raw_uri_buffer_id = 0;
56 
57 /**
58  * \brief Registration function for urilen: keyword
59  */
60 
62 {
63  sigmatch_table[DETECT_URILEN].name = "urilen";
64  sigmatch_table[DETECT_URILEN].desc = "match on the length of the HTTP uri";
65  sigmatch_table[DETECT_URILEN].url = "/rules/http-keywords.html#urilen";
67  sigmatch_table[DETECT_URILEN].Setup = DetectUrilenSetup;
68  sigmatch_table[DETECT_URILEN].Free = DetectUrilenFree;
69 #ifdef UNITTESTS
70  sigmatch_table[DETECT_URILEN].RegisterTests = DetectUrilenRegisterTests;
71 #endif
73 
74  g_http_uri_buffer_id = DetectBufferTypeRegister("http_uri");
75  g_http_raw_uri_buffer_id = DetectBufferTypeRegister("http_raw_uri");
76 }
77 
78 /**
79  * \brief This function is used to parse urilen options passed via urilen: keyword
80  *
81  * \param urilenstr Pointer to the user provided urilen options
82  *
83  * \retval urilend pointer to DetectUrilenData on success
84  * \retval NULL on failure
85  */
86 
87 static DetectUrilenData *DetectUrilenParse (const char *urilenstr)
88 {
89  return SCDetectUrilenParse(urilenstr);
90 }
91 
92 /**
93  * \brief this function is used to parse urilen data into the current signature
94  *
95  * \param de_ctx pointer to the Detection Engine Context
96  * \param s pointer to the Current Signature
97  * \param urilenstr pointer to the user provided urilen options
98  *
99  * \retval 0 on Success
100  * \retval -1 on Failure
101  */
102 static int DetectUrilenSetup (DetectEngineCtx *de_ctx, Signature *s, const char *urilenstr)
103 {
104  SCEnter();
105  DetectUrilenData *urilend = NULL;
106 
108  return -1;
109 
110  urilend = DetectUrilenParse(urilenstr);
111  if (urilend == NULL)
112  goto error;
113 
114  if (urilend->raw_buffer) {
116  g_http_raw_uri_buffer_id) == NULL) {
117  goto error;
118  }
119  } else {
121  g_http_uri_buffer_id) == NULL) {
122  goto error;
123  }
124  }
125 
126  SCReturnInt(0);
127 
128 error:
129  DetectUrilenFree(de_ctx, urilend);
130  SCReturnInt(-1);
131 }
132 
133 /**
134  * \brief this function will free memory associated with DetectUrilenData
135  *
136  * \param ptr pointer to DetectUrilenData
137  */
138 static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
139 {
140  if (ptr == NULL)
141  return;
142 
143  DetectUrilenData *urilend = (DetectUrilenData *)ptr;
144  SCDetectUrilenFree(urilend);
145 }
146 
147 /** \brief set prefilter dsize pair
148  * \param s signature to get dsize value from
149  */
151 {
152  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
153  if (s->init_data->buffers[x].id != (uint32_t)list)
154  continue;
155 
156  uint16_t high = UINT16_MAX;
157  bool found = false;
158 
159  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
160  if (sm->type != DETECT_URILEN)
161  continue;
162 
163  DetectUrilenData *dd = (DetectUrilenData *)sm->ctx;
164 
165  switch (dd->du16.mode) {
166  case DETECT_UINT_LT:
167  if (dd->du16.arg1 < UINT16_MAX) {
168  high = dd->du16.arg1 + 1;
169  }
170  break;
171  case DETECT_UINT_LTE:
172  // fallthrough
173  case DETECT_UINT_EQ:
174  high = dd->du16.arg1;
175  break;
176  case DETECT_UINT_RA:
177  if (dd->du16.arg2 < UINT16_MAX) {
178  high = dd->du16.arg2 + 1;
179  }
180  break;
181  case DETECT_UINT_NE:
182  // fallthrough
183  case DETECT_UINT_GTE:
184  // fallthrough
185  case DETECT_UINT_GT:
186  high = UINT16_MAX;
187  break;
188  }
189  found = true;
190  }
191 
192  // skip 65535 to avoid mismatch on uri > 64k
193  if (!found || high == UINT16_MAX)
194  return;
195 
196  SCLogDebug("high %u", high);
197 
198  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
199  if (sm->type != DETECT_CONTENT) {
200  continue;
201  }
202  DetectContentData *cd = (DetectContentData *)sm->ctx;
203  if (cd == NULL) {
204  continue;
205  }
206 
207  if (cd->depth == 0 || cd->depth > high) {
208  cd->depth = high;
210  SCLogDebug("updated %u, content %u to have depth %u "
211  "because of urilen.",
212  s->id, cd->id, cd->depth);
213  }
214  }
215  }
216 }
217 
219  const Signature *s, const char **sigerror, const DetectBufferType *dbt)
220 {
221  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
222  if (s->init_data->buffers[x].id != (uint32_t)dbt->id)
223  continue;
224  for (const SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
225  if (sm->type != DETECT_CONTENT) {
226  continue;
227  }
228  DetectContentData *cd = (DetectContentData *)sm->ctx;
229  if (cd == NULL) {
230  continue;
231  }
232 
233  if (cd->depth && cd->depth < cd->content_len) {
234  *sigerror = "depth or urilen smaller than content len";
235  SCLogError("depth or urilen %u smaller "
236  "than content len %u",
237  cd->depth, cd->content_len);
238  return false;
239  }
240  }
241  }
242  return true;
243 }
244 
245 #ifdef UNITTESTS
246 
247 #include "stream.h"
248 #include "stream-tcp-private.h"
249 #include "stream-tcp-reassemble.h"
250 #include "detect-engine-mpm.h"
251 #include "app-layer-parser.h"
252 #include "detect-engine-alert.h"
253 
254 /** \test Test the Urilen keyword setup */
255 static int DetectUrilenParseTest01(void)
256 {
257  DetectUrilenData *urilend = DetectUrilenParse("10");
258  FAIL_IF_NULL(urilend);
259  FAIL_IF(urilend->du16.arg1 != 10);
260  FAIL_IF(urilend->du16.mode != DETECT_UINT_EQ);
261  FAIL_IF(urilend->raw_buffer);
262 
263  DetectUrilenFree(NULL, urilend);
264  PASS;
265 }
266 
267 /** \test Test the Urilen keyword setup */
268 static int DetectUrilenParseTest02(void)
269 {
270  DetectUrilenData *urilend = DetectUrilenParse(" < 10 ");
271  FAIL_IF_NULL(urilend);
272  FAIL_IF(urilend->du16.arg1 != 10);
273  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
274  FAIL_IF(urilend->raw_buffer);
275 
276  DetectUrilenFree(NULL, urilend);
277  PASS;
278 }
279 
280 /** \test Test the Urilen keyword setup */
281 static int DetectUrilenParseTest03(void)
282 {
283  DetectUrilenData *urilend = DetectUrilenParse(" > 10 ");
284  FAIL_IF_NULL(urilend);
285  FAIL_IF(urilend->du16.arg1 != 10);
286  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
287  FAIL_IF(urilend->raw_buffer);
288 
289  DetectUrilenFree(NULL, urilend);
290  PASS;
291 }
292 
293 /** \test Test the Urilen keyword setup */
294 static int DetectUrilenParseTest04(void)
295 {
296  DetectUrilenData *urilend = DetectUrilenParse(" 5 <> 10 ");
297  FAIL_IF_NULL(urilend);
298  FAIL_IF(urilend->du16.arg1 != 5);
299  FAIL_IF(urilend->du16.arg2 != 10);
300  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
301  FAIL_IF(urilend->raw_buffer);
302 
303  DetectUrilenFree(NULL, urilend);
304  PASS;
305 }
306 
307 /** \test Test the Urilen keyword setup */
308 static int DetectUrilenParseTest05(void)
309 {
310  DetectUrilenData *urilend = DetectUrilenParse("5<>10,norm");
311  FAIL_IF_NULL(urilend);
312  FAIL_IF(urilend->du16.arg1 != 5);
313  FAIL_IF(urilend->du16.arg2 != 10);
314  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
315  FAIL_IF(urilend->raw_buffer);
316 
317  DetectUrilenFree(NULL, urilend);
318  PASS;
319 }
320 
321 /** \test Test the Urilen keyword setup */
322 static int DetectUrilenParseTest06(void)
323 {
324  DetectUrilenData *urilend = DetectUrilenParse("5<>10,raw");
325  FAIL_IF_NULL(urilend);
326  FAIL_IF(urilend->du16.arg1 != 5);
327  FAIL_IF(urilend->du16.arg2 != 10);
328  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
329  FAIL_IF(!urilend->raw_buffer);
330 
331  DetectUrilenFree(NULL, urilend);
332  PASS;
333 }
334 
335 /** \test Test the Urilen keyword setup */
336 static int DetectUrilenParseTest07(void)
337 {
338  DetectUrilenData *urilend = DetectUrilenParse(">10, norm ");
339  FAIL_IF_NULL(urilend);
340  FAIL_IF(urilend->du16.arg1 != 10);
341  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
342  FAIL_IF(urilend->raw_buffer);
343 
344  DetectUrilenFree(NULL, urilend);
345  PASS;
346 }
347 
348 /** \test Test the Urilen keyword setup */
349 static int DetectUrilenParseTest08(void)
350 {
351  DetectUrilenData *urilend = DetectUrilenParse("<10, norm ");
352  FAIL_IF_NULL(urilend);
353  FAIL_IF(urilend->du16.arg1 != 10);
354  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
355  FAIL_IF(urilend->raw_buffer);
356 
357  DetectUrilenFree(NULL, urilend);
358  PASS;
359 }
360 
361 /** \test Test the Urilen keyword setup */
362 static int DetectUrilenParseTest09(void)
363 {
364  DetectUrilenData *urilend = DetectUrilenParse(">10, raw ");
365  FAIL_IF_NULL(urilend);
366  FAIL_IF(urilend->du16.arg1 != 10);
367  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
368  FAIL_IF(!urilend->raw_buffer);
369 
370  DetectUrilenFree(NULL, urilend);
371  PASS;
372 }
373 
374 /** \test Test the Urilen keyword setup */
375 static int DetectUrilenParseTest10(void)
376 {
377  DetectUrilenData *urilend = DetectUrilenParse("<10, raw ");
378  FAIL_IF_NULL(urilend);
379  FAIL_IF(urilend->du16.arg1 != 10);
380  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
381  FAIL_IF(!urilend->raw_buffer);
382 
383  DetectUrilenFree(NULL, urilend);
384  PASS;
385 }
386 
387 /**
388  * \brief this function is used to initialize the detection engine context and
389  * setup the signature with passed values.
390  *
391  */
392 
393 static int DetectUrilenInitTest(DetectEngineCtx **de_ctx, Signature **sig,
394  DetectUrilenData **urilend, const char *str)
395 {
396  char fullstr[1024];
397  int result = 0;
398 
399  *de_ctx = NULL;
400  *sig = NULL;
401 
402  if (snprintf(fullstr, 1024, "alert ip any any -> any any (msg:\"Urilen "
403  "test\"; urilen:%s; sid:1;)", str) >= 1024) {
404  goto end;
405  }
406 
408  if (*de_ctx == NULL) {
409  goto end;
410  }
411 
412  (*de_ctx)->flags |= DE_QUIET;
413 
414  (*de_ctx)->sig_list = SigInit(*de_ctx, fullstr);
415  if ((*de_ctx)->sig_list == NULL) {
416  goto end;
417  }
418 
419  *sig = (*de_ctx)->sig_list;
420 
421  *urilend = DetectUrilenParse(str);
422 
423  result = 1;
424 
425 end:
426  return result;
427 }
428 
429 /**
430  * \test DetectUrilenSetpTest01 is a test for setting up an valid urilen values
431  * with valid "<>" operator and include spaces arround the given values.
432  * In the test the values are setup with initializing the detection engine
433  * context and setting up the signature itself.
434  */
435 
436 static int DetectUrilenSetpTest01(void)
437 {
438  DetectUrilenData *urilend = NULL;
439  Signature *sig = NULL;
440  DetectEngineCtx *de_ctx = NULL;
441 
442  uint8_t res = DetectUrilenInitTest(&de_ctx, &sig, &urilend, "1 <> 3");
443  FAIL_IF(res == 0);
444  FAIL_IF_NULL(urilend);
445  FAIL_IF_NOT(urilend->du16.arg1 == 1);
446  FAIL_IF_NOT(urilend->du16.arg2 == 3);
447  FAIL_IF_NOT(urilend->du16.mode == DETECT_UINT_RA);
448 
449  DetectUrilenFree(NULL, urilend);
451  PASS;
452 }
453 
454 /** \test Check a signature with given urilen */
455 static int DetectUrilenSigTest01(void)
456 {
457  Flow f;
458  uint8_t httpbuf1[] = "POST /suricata HTTP/1.0\r\n"
459  "Host: foo.bar.tld\r\n"
460  "\r\n";
461  uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
462  TcpSession ssn;
463  ThreadVars th_v;
464  DetectEngineThreadCtx *det_ctx = NULL;
466 
467  memset(&th_v, 0, sizeof(th_v));
468  StatsThreadInit(&th_v.stats);
469  memset(&f, 0, sizeof(f));
470  memset(&ssn, 0, sizeof(ssn));
471 
472  Packet *p = UTHBuildPacket(NULL, 0, IPPROTO_TCP);
473 
474  FLOW_INITIALIZE(&f);
475  f.protoctx = (void *)&ssn;
476  f.proto = IPPROTO_TCP;
477  f.flags |= FLOW_IPV4;
478 
479  p->flow = &f;
484 
485  StreamTcpInitConfig(true);
486 
489  de_ctx->flags |= DE_QUIET;
490 
491  Signature *s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
492  "(msg:\"Testing urilen\"; "
493  "urilen: <5; sid:1;)");
494  FAIL_IF_NULL(s);
495  s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
496  "(msg:\"Testing http_method\"; "
497  "urilen: >5; sid:2;)");
498  FAIL_IF_NULL(s);
499 
501  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
502 
503  int r = AppLayerParserParse(
504  NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1);
505  FAIL_IF(r != 0);
506 
507  HtpState *htp_state = f.alstate;
508  FAIL_IF_NULL(htp_state);
509 
510  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
511 
512  FAIL_IF(PacketAlertCheck(p, 1));
513  FAIL_IF(!PacketAlertCheck(p, 2));
514 
515  UTHFreePackets(&p, 1);
516  FLOW_DESTROY(&f);
517 
519  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
521  StreamTcpFreeConfig(true);
522  StatsThreadCleanup(&th_v.stats);
523  PASS;
524 }
525 
526 /**
527  * \brief this function registers unit tests for DetectUrilen
528  */
529 void DetectUrilenRegisterTests(void)
530 {
531  UtRegisterTest("DetectUrilenParseTest01", DetectUrilenParseTest01);
532  UtRegisterTest("DetectUrilenParseTest02", DetectUrilenParseTest02);
533  UtRegisterTest("DetectUrilenParseTest03", DetectUrilenParseTest03);
534  UtRegisterTest("DetectUrilenParseTest04", DetectUrilenParseTest04);
535  UtRegisterTest("DetectUrilenParseTest05", DetectUrilenParseTest05);
536  UtRegisterTest("DetectUrilenParseTest06", DetectUrilenParseTest06);
537  UtRegisterTest("DetectUrilenParseTest07", DetectUrilenParseTest07);
538  UtRegisterTest("DetectUrilenParseTest08", DetectUrilenParseTest08);
539  UtRegisterTest("DetectUrilenParseTest09", DetectUrilenParseTest09);
540  UtRegisterTest("DetectUrilenParseTest10", DetectUrilenParseTest10);
541  UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01);
542  UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01);
543 }
544 #endif /* UNITTESTS */
util-byte.h
detect-engine-uint.h
SigTableElmt_::url
const char * url
Definition: detect.h:1471
SignatureInitDataBuffer_::head
SigMatch * head
Definition: detect.h:535
detect-content.h
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:1470
Flow_::flags
uint64_t flags
Definition: flow.h:396
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:79
PKT_HAS_FLOW
#define PKT_HAS_FLOW
Definition: decode.h:1293
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1455
flow-util.h
SigTableElmt_::name
const char * name
Definition: detect.h:1468
stream-tcp.h
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
DETECT_UINT_LT
#define DETECT_UINT_LT
Definition: detect-engine-uint.h:37
DETECT_CONTENT
@ DETECT_CONTENT
Definition: detect-engine-register.h:71
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1459
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
DETECT_UINT_NE
#define DETECT_UINT_NE
Definition: detect-engine-uint.h:36
Flow_::proto
uint8_t proto
Definition: flow.h:369
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:143
Packet_::flags
uint32_t flags
Definition: decode.h:551
Flow_
Flow data structure.
Definition: flow.h:347
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:937
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2652
DETECT_UINT_EQ
#define DETECT_UINT_EQ
Definition: detect-engine-uint.h:35
AppLayerParserThreadCtxFree
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
Definition: app-layer-parser.c:324
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:224
DE_QUIET
#define DE_QUIET
Definition: detect.h:330
stream-tcp-reassemble.h
UTHBuildPacket
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
Definition: util-unittest-helper.c:365
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:2434
DetectBufferType_
Definition: detect.h:449
DetectContentData_
Definition: detect-content.h:93
SCDetectSignatureSetAppProto
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2234
SIGMATCH_SUPPORT_FIREWALL
#define SIGMATCH_SUPPORT_FIREWALL
Definition: detect.h:1691
DETECT_UINT_GT
#define DETECT_UINT_GT
Definition: detect-engine-uint.h:32
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:3478
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:536
Flow_::protoctx
void * protoctx
Definition: flow.h:426
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1450
FLOW_IPV4
#define FLOW_IPV4
Definition: flow.h:99
DetectUrilenApplyToContent
void DetectUrilenApplyToContent(Signature *s, int list)
set prefilter dsize pair
Definition: detect-urilen.c:150
util-unittest.h
HtpState_
Definition: app-layer-htp.h:182
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
StreamTcpInitConfig
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
Definition: stream-tcp.c:498
FLOW_INITIALIZE
#define FLOW_INITIALIZE(f)
Definition: flow-util.h:38
app-layer-htp.h
util-debug.h
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:19
DetectEngineThreadCtx_
Definition: detect.h:1252
alp_tctx
AppLayerParserThreadCtx * alp_tctx
Definition: fuzz_applayerparserparse.c:24
DETECT_CONTENT_DEPTH
#define DETECT_CONTENT_DEPTH
Definition: detect-content.h:33
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:387
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
Definition: detect-engine.c:3386
SigMatch_::next
struct SigMatch_ * next
Definition: detect.h:360
SigInit
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
Definition: detect-parse.c:3136
DetectContentData_::id
PatIntId id
Definition: detect-content.h:105
app-layer-parser.h
DetectContentData_::depth
uint16_t depth
Definition: detect-content.h:106
stream.h
Packet_
Definition: decode.h:505
detect-engine-build.h
DETECT_UINT_GTE
#define DETECT_UINT_GTE
Definition: detect-engine-uint.h:33
stream-tcp-private.h
detect-engine-alert.h
DetectContentData_::flags
uint32_t flags
Definition: detect-content.h:104
DETECT_URILEN
@ DETECT_URILEN
Definition: detect-engine-register.h:96
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:751
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1430
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2274
StatsThreadInit
void StatsThreadInit(StatsThreadContext *stats)
Definition: counters.c:1331
AppLayerParserThreadCtxAlloc
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
Definition: app-layer-parser.c:297
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:351
DetectBufferType_::id
int id
Definition: detect.h:452
DetectUrilenValidateContent
bool DetectUrilenValidateContent(const Signature *s, const char **sigerror, const DetectBufferType *dbt)
Definition: detect-urilen.c:218
Packet_::flow
struct Flow_ * flow
Definition: decode.h:553
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:1214
StreamTcpFreeConfig
void StreamTcpFreeConfig(bool quiet)
Definition: stream-tcp.c:869
AppLayerParserParse
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
Definition: app-layer-parser.c:1315
suricata-common.h
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:36
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Definition: detect-engine.c:3625
DetectUrilenRegister
void DetectUrilenRegister(void)
Registration function for urilen: keyword.
Definition: detect-urilen.c:61
SignatureInitData_::buffers
SignatureInitDataBuffer * buffers
Definition: detect.h:651
DETECT_UINT_LTE
#define DETECT_UINT_LTE
Definition: detect-engine-uint.h:38
str
#define str(s)
Definition: suricata-common.h:308
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
Flow_::alstate
void * alstate
Definition: flow.h:472
Signature_::id
uint32_t id
Definition: detect.h:717
detect-parse.h
SignatureInitDataBuffer_::id
uint32_t id
Definition: detect.h:526
Signature_
Signature container.
Definition: detect.h:672
SigMatch_
a single match condition for a signature
Definition: detect.h:356
ALPROTO_HTTP
@ ALPROTO_HTTP
Definition: app-layer-protos.h:76
FLOW_PKT_ESTABLISHED
#define FLOW_PKT_ESTABLISHED
Definition: flow.h:226
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2613
app-layer-protos.h
detect-urilen.h
DetectContentData_::content_len
uint16_t content_len
Definition: detect-content.h:95
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:939
AppLayerParserThreadCtx_
Definition: app-layer-parser.c:60
TcpSession_
Definition: stream-tcp-private.h:283
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:443
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:121
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
SignatureInitData_::buffer_index
uint32_t buffer_index
Definition: detect.h:652
StatsThreadCleanup
void StatsThreadCleanup(StatsThreadContext *stats)
Definition: counters.c:1427
FLOW_DESTROY
#define FLOW_DESTROY(f)
Definition: flow-util.h:119
DETECT_UINT_RA
#define DETECT_UINT_RA
Definition: detect-engine-uint.h:34
PKT_STREAM_EST
#define PKT_STREAM_EST
Definition: decode.h:1289
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1457
app-layer.h
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:456