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 {
64  sigmatch_table[DETECT_AL_URILEN].desc = "match on the length of the HTTP uri";
65  sigmatch_table[DETECT_AL_URILEN].url = "/rules/http-keywords.html#urilen";
67  sigmatch_table[DETECT_AL_URILEN].Setup = DetectUrilenSetup;
68  sigmatch_table[DETECT_AL_URILEN].Free = DetectUrilenFree;
69 #ifdef UNITTESTS
70  sigmatch_table[DETECT_AL_URILEN].RegisterTests = DetectUrilenRegisterTests;
71 #endif
72 
73  g_http_uri_buffer_id = DetectBufferTypeRegister("http_uri");
74  g_http_raw_uri_buffer_id = DetectBufferTypeRegister("http_raw_uri");
75 }
76 
77 /**
78  * \brief This function is used to parse urilen options passed via urilen: keyword
79  *
80  * \param urilenstr Pointer to the user provided urilen options
81  *
82  * \retval urilend pointer to DetectUrilenData on success
83  * \retval NULL on failure
84  */
85 
86 static DetectUrilenData *DetectUrilenParse (const char *urilenstr)
87 {
88  return rs_detect_urilen_parse(urilenstr);
89 }
90 
91 /**
92  * \brief this function is used to parse urilen data into the current signature
93  *
94  * \param de_ctx pointer to the Detection Engine Context
95  * \param s pointer to the Current Signature
96  * \param urilenstr pointer to the user provided urilen options
97  *
98  * \retval 0 on Success
99  * \retval -1 on Failure
100  */
101 static int DetectUrilenSetup (DetectEngineCtx *de_ctx, Signature *s, const char *urilenstr)
102 {
103  SCEnter();
104  DetectUrilenData *urilend = NULL;
105  SigMatch *sm = NULL;
106 
108  return -1;
109 
110  urilend = DetectUrilenParse(urilenstr);
111  if (urilend == NULL)
112  goto error;
113  sm = SigMatchAlloc();
114  if (sm == NULL)
115  goto error;
116  sm->type = DETECT_AL_URILEN;
117  sm->ctx = (void *)urilend;
118 
119  if (urilend->raw_buffer)
120  SigMatchAppendSMToList(s, sm, g_http_raw_uri_buffer_id);
121  else
122  SigMatchAppendSMToList(s, sm, g_http_uri_buffer_id);
123 
124  SCReturnInt(0);
125 
126 error:
127  DetectUrilenFree(de_ctx, urilend);
128  SCReturnInt(-1);
129 }
130 
131 /**
132  * \brief this function will free memory associated with DetectUrilenData
133  *
134  * \param ptr pointer to DetectUrilenData
135  */
136 static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
137 {
138  if (ptr == NULL)
139  return;
140 
141  DetectUrilenData *urilend = (DetectUrilenData *)ptr;
142  rs_detect_urilen_free(urilend);
143 }
144 
145 /** \brief set prefilter dsize pair
146  * \param s signature to get dsize value from
147  */
149 {
150  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
151  if (s->init_data->buffers[x].id != (uint32_t)list)
152  continue;
153 
154  uint16_t high = UINT16_MAX;
155  bool found = false;
156 
157  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
158  if (sm->type != DETECT_AL_URILEN)
159  continue;
160 
161  DetectUrilenData *dd = (DetectUrilenData *)sm->ctx;
162 
163  switch (dd->du16.mode) {
164  case DETECT_UINT_LT:
165  if (dd->du16.arg1 < UINT16_MAX) {
166  high = dd->du16.arg1 + 1;
167  }
168  break;
169  case DETECT_UINT_LTE:
170  // fallthrough
171  case DETECT_UINT_EQ:
172  high = dd->du16.arg1;
173  break;
174  case DETECT_UINT_RA:
175  if (dd->du16.arg2 < UINT16_MAX) {
176  high = dd->du16.arg2 + 1;
177  }
178  break;
179  case DETECT_UINT_NE:
180  // fallthrough
181  case DETECT_UINT_GTE:
182  // fallthrough
183  case DETECT_UINT_GT:
184  high = UINT16_MAX;
185  break;
186  }
187  found = true;
188  }
189 
190  // skip 65535 to avoid mismatch on uri > 64k
191  if (!found || high == UINT16_MAX)
192  return;
193 
194  SCLogDebug("high %u", high);
195 
196  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
197  if (sm->type != DETECT_CONTENT) {
198  continue;
199  }
201  if (cd == NULL) {
202  continue;
203  }
204 
205  if (cd->depth == 0 || cd->depth > high) {
206  cd->depth = high;
208  SCLogDebug("updated %u, content %u to have depth %u "
209  "because of urilen.",
210  s->id, cd->id, cd->depth);
211  }
212  }
213  }
214 }
215 
216 bool DetectUrilenValidateContent(const Signature *s, int list, const char **sigerror)
217 {
218  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
219  if (s->init_data->buffers[x].id != (uint32_t)list)
220  continue;
221  for (const SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
222  if (sm->type != DETECT_CONTENT) {
223  continue;
224  }
226  if (cd == NULL) {
227  continue;
228  }
229 
230  if (cd->depth && cd->depth < cd->content_len) {
231  *sigerror = "depth or urilen smaller than content len";
232  SCLogError("depth or urilen %u smaller "
233  "than content len %u",
234  cd->depth, cd->content_len);
235  return false;
236  }
237  }
238  }
239  return true;
240 }
241 
242 #ifdef UNITTESTS
243 
244 #include "stream.h"
245 #include "stream-tcp-private.h"
246 #include "stream-tcp-reassemble.h"
247 #include "detect-engine-mpm.h"
248 #include "app-layer-parser.h"
249 #include "detect-engine-alert.h"
250 
251 /** \test Test the Urilen keyword setup */
252 static int DetectUrilenParseTest01(void)
253 {
254  int ret = 0;
255  DetectUrilenData *urilend = NULL;
256 
257  urilend = DetectUrilenParse("10");
258  if (urilend != NULL) {
259  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_EQ &&
260  !urilend->raw_buffer)
261  ret = 1;
262 
263  DetectUrilenFree(NULL, urilend);
264  }
265  return ret;
266 }
267 
268 /** \test Test the Urilen keyword setup */
269 static int DetectUrilenParseTest02(void)
270 {
271  int ret = 0;
272  DetectUrilenData *urilend = NULL;
273 
274  urilend = DetectUrilenParse(" < 10 ");
275  if (urilend != NULL) {
276  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_LT &&
277  !urilend->raw_buffer)
278  ret = 1;
279 
280  DetectUrilenFree(NULL, urilend);
281  }
282  return ret;
283 }
284 
285 /** \test Test the Urilen keyword setup */
286 static int DetectUrilenParseTest03(void)
287 {
288  int ret = 0;
289  DetectUrilenData *urilend = NULL;
290 
291  urilend = DetectUrilenParse(" > 10 ");
292  if (urilend != NULL) {
293  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_GT &&
294  !urilend->raw_buffer)
295  ret = 1;
296 
297  DetectUrilenFree(NULL, urilend);
298  }
299  return ret;
300 }
301 
302 /** \test Test the Urilen keyword setup */
303 static int DetectUrilenParseTest04(void)
304 {
305  int ret = 0;
306  DetectUrilenData *urilend = NULL;
307 
308  urilend = DetectUrilenParse(" 5 <> 10 ");
309  if (urilend != NULL) {
310  if (urilend->du16.arg1 == 5 && urilend->du16.arg2 == 10 &&
311  urilend->du16.mode == DETECT_UINT_RA && !urilend->raw_buffer)
312  ret = 1;
313 
314  DetectUrilenFree(NULL, urilend);
315  }
316  return ret;
317 }
318 
319 /** \test Test the Urilen keyword setup */
320 static int DetectUrilenParseTest05(void)
321 {
322  int ret = 0;
323  DetectUrilenData *urilend = NULL;
324 
325  urilend = DetectUrilenParse("5<>10,norm");
326  if (urilend != NULL) {
327  if (urilend->du16.arg1 == 5 && urilend->du16.arg2 == 10 &&
328  urilend->du16.mode == DETECT_UINT_RA && !urilend->raw_buffer)
329  ret = 1;
330 
331  DetectUrilenFree(NULL, urilend);
332  }
333  return ret;
334 }
335 
336 /** \test Test the Urilen keyword setup */
337 static int DetectUrilenParseTest06(void)
338 {
339  int ret = 0;
340  DetectUrilenData *urilend = NULL;
341 
342  urilend = DetectUrilenParse("5<>10,raw");
343  if (urilend != NULL) {
344  if (urilend->du16.arg1 == 5 && urilend->du16.arg2 == 10 &&
345  urilend->du16.mode == DETECT_UINT_RA && urilend->raw_buffer)
346  ret = 1;
347 
348  DetectUrilenFree(NULL, urilend);
349  }
350  return ret;
351 }
352 
353 /** \test Test the Urilen keyword setup */
354 static int DetectUrilenParseTest07(void)
355 {
356  int ret = 0;
357  DetectUrilenData *urilend = NULL;
358 
359  urilend = DetectUrilenParse(">10, norm ");
360  if (urilend != NULL) {
361  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_GT &&
362  !urilend->raw_buffer)
363  ret = 1;
364 
365  DetectUrilenFree(NULL, urilend);
366  }
367  return ret;
368 }
369 
370 /** \test Test the Urilen keyword setup */
371 static int DetectUrilenParseTest08(void)
372 {
373  int ret = 0;
374  DetectUrilenData *urilend = NULL;
375 
376  urilend = DetectUrilenParse("<10, norm ");
377  if (urilend != NULL) {
378  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_LT &&
379  !urilend->raw_buffer)
380  ret = 1;
381 
382  DetectUrilenFree(NULL, urilend);
383  }
384  return ret;
385 }
386 
387 /** \test Test the Urilen keyword setup */
388 static int DetectUrilenParseTest09(void)
389 {
390  int ret = 0;
391  DetectUrilenData *urilend = NULL;
392 
393  urilend = DetectUrilenParse(">10, raw ");
394  if (urilend != NULL) {
395  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_GT && urilend->raw_buffer)
396  ret = 1;
397 
398  DetectUrilenFree(NULL, urilend);
399  }
400  return ret;
401 }
402 
403 /** \test Test the Urilen keyword setup */
404 static int DetectUrilenParseTest10(void)
405 {
406  int ret = 0;
407  DetectUrilenData *urilend = NULL;
408 
409  urilend = DetectUrilenParse("<10, raw ");
410  if (urilend != NULL) {
411  if (urilend->du16.arg1 == 10 && urilend->du16.mode == DETECT_UINT_LT && urilend->raw_buffer)
412  ret = 1;
413 
414  DetectUrilenFree(NULL, urilend);
415  }
416  return ret;
417 }
418 
419 /**
420  * \brief this function is used to initialize the detection engine context and
421  * setup the signature with passed values.
422  *
423  */
424 
425 static int DetectUrilenInitTest(DetectEngineCtx **de_ctx, Signature **sig,
426  DetectUrilenData **urilend, const char *str)
427 {
428  char fullstr[1024];
429  int result = 0;
430 
431  *de_ctx = NULL;
432  *sig = NULL;
433 
434  if (snprintf(fullstr, 1024, "alert ip any any -> any any (msg:\"Urilen "
435  "test\"; urilen:%s; sid:1;)", str) >= 1024) {
436  goto end;
437  }
438 
440  if (*de_ctx == NULL) {
441  goto end;
442  }
443 
444  (*de_ctx)->flags |= DE_QUIET;
445 
446  (*de_ctx)->sig_list = SigInit(*de_ctx, fullstr);
447  if ((*de_ctx)->sig_list == NULL) {
448  goto end;
449  }
450 
451  *sig = (*de_ctx)->sig_list;
452 
453  *urilend = DetectUrilenParse(str);
454 
455  result = 1;
456 
457 end:
458  return result;
459 }
460 
461 /**
462  * \test DetectUrilenSetpTest01 is a test for setting up an valid urilen values
463  * with valid "<>" operator and include spaces arround the given values.
464  * In the test the values are setup with initializing the detection engine
465  * context and setting up the signature itself.
466  */
467 
468 static int DetectUrilenSetpTest01(void)
469 {
470 
471  DetectUrilenData *urilend = NULL;
472  uint8_t res = 0;
473  Signature *sig = NULL;
474  DetectEngineCtx *de_ctx = NULL;
475 
476  res = DetectUrilenInitTest(&de_ctx, &sig, &urilend, "1 <> 2 ");
477  if (res == 0) {
478  goto end;
479  }
480 
481  if(urilend == NULL)
482  goto cleanup;
483 
484  if (urilend != NULL) {
485  if (urilend->du16.arg1 == 1 && urilend->du16.arg2 == 2 &&
486  urilend->du16.mode == DETECT_UINT_RA)
487  res = 1;
488  }
489 
490 cleanup:
491  if (urilend)
492  DetectUrilenFree(NULL, urilend);
496 end:
497  return res;
498 }
499 
500 /** \test Check a signature with given urilen */
501 static int DetectUrilenSigTest01(void)
502 {
503  int result = 0;
504  Flow f;
505  uint8_t httpbuf1[] = "POST /suricata HTTP/1.0\r\n"
506  "Host: foo.bar.tld\r\n"
507  "\r\n";
508  uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
509  TcpSession ssn;
510  Packet *p = NULL;
511  Signature *s = NULL;
512  ThreadVars th_v;
513  DetectEngineThreadCtx *det_ctx;
515 
516  memset(&th_v, 0, sizeof(th_v));
517  memset(&f, 0, sizeof(f));
518  memset(&ssn, 0, sizeof(ssn));
519 
520  p = UTHBuildPacket(NULL, 0, IPPROTO_TCP);
521 
522  FLOW_INITIALIZE(&f);
523  f.protoctx = (void *)&ssn;
524  f.proto = IPPROTO_TCP;
525  f.flags |= FLOW_IPV4;
526 
527  p->flow = &f;
532 
533  StreamTcpInitConfig(true);
534 
536  if (de_ctx == NULL) {
537  goto end;
538  }
539 
540  de_ctx->flags |= DE_QUIET;
541 
542  s = de_ctx->sig_list = SigInit(de_ctx,
543  "alert tcp any any -> any any "
544  "(msg:\"Testing urilen\"; "
545  "urilen: <5; sid:1;)");
546  if (s == NULL) {
547  goto end;
548  }
549 
550  s = s->next = SigInit(de_ctx,
551  "alert tcp any any -> any any "
552  "(msg:\"Testing http_method\"; "
553  "urilen: >5; sid:2;)");
554  if (s == NULL) {
555  goto end;
556  }
557 
559  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
560 
561  int r = AppLayerParserParse(
562  NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1);
563  if (r != 0) {
564  SCLogDebug("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
565  goto end;
566  }
567 
568  HtpState *htp_state = f.alstate;
569  if (htp_state == NULL) {
570  SCLogDebug("no http state: ");
571  goto end;
572  }
573 
574  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
575 
576  if ((PacketAlertCheck(p, 1))) {
577  printf("sid 1 alerted, but should not have: \n");
578  goto end;
579  }
580  if (!PacketAlertCheck(p, 2)) {
581  printf("sid 2 did not alerted, but should have: \n");
582  goto end;
583  }
584 
585  result = 1;
586 
587 end:
588  if (alp_tctx != NULL)
590  if (de_ctx != NULL) SigGroupCleanup(de_ctx);
591  if (de_ctx != NULL) SigCleanSignatures(de_ctx);
592  if (de_ctx != NULL) DetectEngineCtxFree(de_ctx);
593 
594  StreamTcpFreeConfig(true);
595  FLOW_DESTROY(&f);
596  UTHFreePackets(&p, 1);
597  return result;
598 }
599 
600 /**
601  * \brief this function registers unit tests for DetectUrilen
602  */
603 void DetectUrilenRegisterTests(void)
604 {
605  UtRegisterTest("DetectUrilenParseTest01", DetectUrilenParseTest01);
606  UtRegisterTest("DetectUrilenParseTest02", DetectUrilenParseTest02);
607  UtRegisterTest("DetectUrilenParseTest03", DetectUrilenParseTest03);
608  UtRegisterTest("DetectUrilenParseTest04", DetectUrilenParseTest04);
609  UtRegisterTest("DetectUrilenParseTest05", DetectUrilenParseTest05);
610  UtRegisterTest("DetectUrilenParseTest06", DetectUrilenParseTest06);
611  UtRegisterTest("DetectUrilenParseTest07", DetectUrilenParseTest07);
612  UtRegisterTest("DetectUrilenParseTest08", DetectUrilenParseTest08);
613  UtRegisterTest("DetectUrilenParseTest09", DetectUrilenParseTest09);
614  UtRegisterTest("DetectUrilenParseTest10", DetectUrilenParseTest10);
615  UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01);
616  UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01);
617 }
618 #endif /* UNITTESTS */
util-byte.h
detect-engine-uint.h
SigTableElmt_::url
const char * url
Definition: detect.h:1287
DetectSignatureSetAppProto
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:1703
SignatureInitDataBuffer_::head
SigMatch * head
Definition: detect.h:518
detect-content.h
detect-engine.h
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
PKT_HAS_FLOW
#define PKT_HAS_FLOW
Definition: decode.h:1000
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1274
flow-util.h
SigTableElmt_::name
const char * name
Definition: detect.h:1284
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:62
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
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:141
Packet_::flags
uint32_t flags
Definition: decode.h:467
Flow_
Flow data structure.
Definition: flow.h:347
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:826
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2592
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:314
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:221
DE_QUIET
#define DE_QUIET
Definition: detect.h:314
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:337
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1824
DetectContentData_
Definition: detect-content.h:93
SigCleanSignatures
void SigCleanSignatures(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:46
DETECT_UINT_GT
#define DETECT_UINT_GT
Definition: detect-engine-uint.h:32
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:461
Flow_::protoctx
void * protoctx
Definition: flow.h:437
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1269
FLOW_IPV4
#define FLOW_IPV4
Definition: flow.h:96
DetectUrilenApplyToContent
void DetectUrilenApplyToContent(Signature *s, int list)
set prefilter dsize pair
Definition: detect-urilen.c:148
util-unittest.h
HtpState_
Definition: app-layer-htp.h:243
util-unittest-helper.h
Signature_::next
struct Signature_ * next
Definition: detect.h:656
StreamTcpInitConfig
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
Definition: stream-tcp.c:359
FLOW_INITIALIZE
#define FLOW_INITIALIZE(f)
Definition: flow-util.h:38
app-layer-htp.h
util-debug.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectEngineThreadCtx_
Definition: detect.h:1074
alp_tctx
AppLayerParserThreadCtx * alp_tctx
Definition: fuzz_applayerparserparse.c:22
DETECT_CONTENT_DEPTH
#define DETECT_CONTENT_DEPTH
Definition: detect-content.h:33
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
SigMatch_::next
struct SigMatch_ * next
Definition: detect.h:344
SigInit
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
Definition: detect-parse.c:2264
DetectContentData_::id
PatIntId id
Definition: detect-content.h:105
app-layer-parser.h
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:343
SigGroupCleanup
int SigGroupCleanup(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:2042
DetectContentData_::depth
uint16_t depth
Definition: detect-content.h:106
stream.h
Packet_
Definition: decode.h:430
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
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:653
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: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
AppLayerParserThreadCtxAlloc
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
Definition: app-layer-parser.c:293
Packet_::flow
struct Flow_ * flow
Definition: decode.h:469
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3308
DetectBufferTypeRegister
int DetectBufferTypeRegister(const char *name)
Definition: detect-engine.c:1060
StreamTcpFreeConfig
void StreamTcpFreeConfig(bool quiet)
Definition: stream-tcp.c:690
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:1307
suricata-common.h
SigMatch_::type
uint16_t type
Definition: detect.h:341
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:30
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:129
DetectUrilenRegister
void DetectUrilenRegister(void)
Registration function for urilen: keyword.
Definition: detect-urilen.c:61
DetectEngineCtx_::sig_list
Signature * sig_list
Definition: detect.h:834
SignatureInitData_::buffers
SignatureInitDataBuffer * buffers
Definition: detect.h:571
DETECT_UINT_LTE
#define DETECT_UINT_LTE
Definition: detect-engine-uint.h:38
str
#define str(s)
Definition: suricata-common.h:286
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
Flow_::alstate
void * alstate
Definition: flow.h:472
Signature_::id
uint32_t id
Definition: detect.h:616
Flow_::flags
uint32_t flags
Definition: flow.h:417
detect-parse.h
SignatureInitDataBuffer_::id
uint32_t id
Definition: detect.h:513
Signature_
Signature container.
Definition: detect.h:581
SigMatch_
a single match condition for a signature
Definition: detect.h:340
ALPROTO_HTTP
@ ALPROTO_HTTP
Definition: app-layer-protos.h:66
FLOW_PKT_ESTABLISHED
#define FLOW_PKT_ESTABLISHED
Definition: flow.h:223
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2553
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:828
AppLayerParserThreadCtx_
Definition: app-layer-parser.c:66
TcpSession_
Definition: stream-tcp-private.h:283
DetectUrilenValidateContent
bool DetectUrilenValidateContent(const Signature *s, int list, const char **sigerror)
Definition: detect-urilen.c:216
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:446
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
SignatureInitData_::buffer_index
uint32_t buffer_index
Definition: detect.h:572
DETECT_AL_URILEN
@ DETECT_AL_URILEN
Definition: detect-engine-register.h:131
FLOW_DESTROY
#define FLOW_DESTROY(f)
Definition: flow-util.h:127
DETECT_UINT_RA
#define DETECT_UINT_RA
Definition: detect-engine-uint.h:34
PKT_STREAM_EST
#define PKT_STREAM_EST
Definition: decode.h:997
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1276
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:468