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
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 SCDetectUrilenParse(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 
107  return -1;
108 
109  urilend = DetectUrilenParse(urilenstr);
110  if (urilend == NULL)
111  goto error;
112 
113  if (urilend->raw_buffer) {
115  g_http_raw_uri_buffer_id) == NULL) {
116  goto error;
117  }
118  } else {
120  g_http_uri_buffer_id) == NULL) {
121  goto error;
122  }
123  }
124 
125  SCReturnInt(0);
126 
127 error:
128  DetectUrilenFree(de_ctx, urilend);
129  SCReturnInt(-1);
130 }
131 
132 /**
133  * \brief this function will free memory associated with DetectUrilenData
134  *
135  * \param ptr pointer to DetectUrilenData
136  */
137 static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
138 {
139  if (ptr == NULL)
140  return;
141 
142  DetectUrilenData *urilend = (DetectUrilenData *)ptr;
143  SCDetectUrilenFree(urilend);
144 }
145 
146 /** \brief set prefilter dsize pair
147  * \param s signature to get dsize value from
148  */
150 {
151  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
152  if (s->init_data->buffers[x].id != (uint32_t)list)
153  continue;
154 
155  uint16_t high = UINT16_MAX;
156  bool found = false;
157 
158  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
159  if (sm->type != DETECT_URILEN)
160  continue;
161 
162  DetectUrilenData *dd = (DetectUrilenData *)sm->ctx;
163 
164  switch (dd->du16.mode) {
165  case DETECT_UINT_LT:
166  if (dd->du16.arg1 < UINT16_MAX) {
167  high = dd->du16.arg1 + 1;
168  }
169  break;
170  case DETECT_UINT_LTE:
171  // fallthrough
172  case DETECT_UINT_EQ:
173  high = dd->du16.arg1;
174  break;
175  case DETECT_UINT_RA:
176  if (dd->du16.arg2 < UINT16_MAX) {
177  high = dd->du16.arg2 + 1;
178  }
179  break;
180  case DETECT_UINT_NE:
181  // fallthrough
182  case DETECT_UINT_GTE:
183  // fallthrough
184  case DETECT_UINT_GT:
185  high = UINT16_MAX;
186  break;
187  }
188  found = true;
189  }
190 
191  // skip 65535 to avoid mismatch on uri > 64k
192  if (!found || high == UINT16_MAX)
193  return;
194 
195  SCLogDebug("high %u", high);
196 
197  for (SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
198  if (sm->type != DETECT_CONTENT) {
199  continue;
200  }
201  DetectContentData *cd = (DetectContentData *)sm->ctx;
202  if (cd == NULL) {
203  continue;
204  }
205 
206  if (cd->depth == 0 || cd->depth > high) {
207  cd->depth = high;
209  SCLogDebug("updated %u, content %u to have depth %u "
210  "because of urilen.",
211  s->id, cd->id, cd->depth);
212  }
213  }
214  }
215 }
216 
218  const Signature *s, const char **sigerror, const DetectBufferType *dbt)
219 {
220  for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
221  if (s->init_data->buffers[x].id != (uint32_t)dbt->id)
222  continue;
223  for (const SigMatch *sm = s->init_data->buffers[x].head; sm != NULL; sm = sm->next) {
224  if (sm->type != DETECT_CONTENT) {
225  continue;
226  }
227  DetectContentData *cd = (DetectContentData *)sm->ctx;
228  if (cd == NULL) {
229  continue;
230  }
231 
232  if (cd->depth && cd->depth < cd->content_len) {
233  *sigerror = "depth or urilen smaller than content len";
234  SCLogError("depth or urilen %u smaller "
235  "than content len %u",
236  cd->depth, cd->content_len);
237  return false;
238  }
239  }
240  }
241  return true;
242 }
243 
244 #ifdef UNITTESTS
245 
246 #include "stream.h"
247 #include "stream-tcp-private.h"
248 #include "stream-tcp-reassemble.h"
249 #include "detect-engine-mpm.h"
250 #include "app-layer-parser.h"
251 #include "detect-engine-alert.h"
252 
253 /** \test Test the Urilen keyword setup */
254 static int DetectUrilenParseTest01(void)
255 {
256  DetectUrilenData *urilend = DetectUrilenParse("10");
257  FAIL_IF_NULL(urilend);
258  FAIL_IF(urilend->du16.arg1 != 10);
259  FAIL_IF(urilend->du16.mode != DETECT_UINT_EQ);
260  FAIL_IF(urilend->raw_buffer);
261 
262  DetectUrilenFree(NULL, urilend);
263  PASS;
264 }
265 
266 /** \test Test the Urilen keyword setup */
267 static int DetectUrilenParseTest02(void)
268 {
269  DetectUrilenData *urilend = DetectUrilenParse(" < 10 ");
270  FAIL_IF_NULL(urilend);
271  FAIL_IF(urilend->du16.arg1 != 10);
272  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
273  FAIL_IF(urilend->raw_buffer);
274 
275  DetectUrilenFree(NULL, urilend);
276  PASS;
277 }
278 
279 /** \test Test the Urilen keyword setup */
280 static int DetectUrilenParseTest03(void)
281 {
282  DetectUrilenData *urilend = DetectUrilenParse(" > 10 ");
283  FAIL_IF_NULL(urilend);
284  FAIL_IF(urilend->du16.arg1 != 10);
285  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
286  FAIL_IF(urilend->raw_buffer);
287 
288  DetectUrilenFree(NULL, urilend);
289  PASS;
290 }
291 
292 /** \test Test the Urilen keyword setup */
293 static int DetectUrilenParseTest04(void)
294 {
295  DetectUrilenData *urilend = DetectUrilenParse(" 5 <> 10 ");
296  FAIL_IF_NULL(urilend);
297  FAIL_IF(urilend->du16.arg1 != 5);
298  FAIL_IF(urilend->du16.arg2 != 10);
299  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
300  FAIL_IF(urilend->raw_buffer);
301 
302  DetectUrilenFree(NULL, urilend);
303  PASS;
304 }
305 
306 /** \test Test the Urilen keyword setup */
307 static int DetectUrilenParseTest05(void)
308 {
309  DetectUrilenData *urilend = DetectUrilenParse("5<>10,norm");
310  FAIL_IF_NULL(urilend);
311  FAIL_IF(urilend->du16.arg1 != 5);
312  FAIL_IF(urilend->du16.arg2 != 10);
313  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
314  FAIL_IF(urilend->raw_buffer);
315 
316  DetectUrilenFree(NULL, urilend);
317  PASS;
318 }
319 
320 /** \test Test the Urilen keyword setup */
321 static int DetectUrilenParseTest06(void)
322 {
323  DetectUrilenData *urilend = DetectUrilenParse("5<>10,raw");
324  FAIL_IF_NULL(urilend);
325  FAIL_IF(urilend->du16.arg1 != 5);
326  FAIL_IF(urilend->du16.arg2 != 10);
327  FAIL_IF(urilend->du16.mode != DETECT_UINT_RA);
328  FAIL_IF(!urilend->raw_buffer);
329 
330  DetectUrilenFree(NULL, urilend);
331  PASS;
332 }
333 
334 /** \test Test the Urilen keyword setup */
335 static int DetectUrilenParseTest07(void)
336 {
337  DetectUrilenData *urilend = DetectUrilenParse(">10, norm ");
338  FAIL_IF_NULL(urilend);
339  FAIL_IF(urilend->du16.arg1 != 10);
340  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
341  FAIL_IF(urilend->raw_buffer);
342 
343  DetectUrilenFree(NULL, urilend);
344  PASS;
345 }
346 
347 /** \test Test the Urilen keyword setup */
348 static int DetectUrilenParseTest08(void)
349 {
350  DetectUrilenData *urilend = DetectUrilenParse("<10, norm ");
351  FAIL_IF_NULL(urilend);
352  FAIL_IF(urilend->du16.arg1 != 10);
353  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
354  FAIL_IF(urilend->raw_buffer);
355 
356  DetectUrilenFree(NULL, urilend);
357  PASS;
358 }
359 
360 /** \test Test the Urilen keyword setup */
361 static int DetectUrilenParseTest09(void)
362 {
363  DetectUrilenData *urilend = DetectUrilenParse(">10, raw ");
364  FAIL_IF_NULL(urilend);
365  FAIL_IF(urilend->du16.arg1 != 10);
366  FAIL_IF(urilend->du16.mode != DETECT_UINT_GT);
367  FAIL_IF(!urilend->raw_buffer);
368 
369  DetectUrilenFree(NULL, urilend);
370  PASS;
371 }
372 
373 /** \test Test the Urilen keyword setup */
374 static int DetectUrilenParseTest10(void)
375 {
376  DetectUrilenData *urilend = DetectUrilenParse("<10, raw ");
377  FAIL_IF_NULL(urilend);
378  FAIL_IF(urilend->du16.arg1 != 10);
379  FAIL_IF(urilend->du16.mode != DETECT_UINT_LT);
380  FAIL_IF(!urilend->raw_buffer);
381 
382  DetectUrilenFree(NULL, urilend);
383  PASS;
384 }
385 
386 /**
387  * \brief this function is used to initialize the detection engine context and
388  * setup the signature with passed values.
389  *
390  */
391 
392 static int DetectUrilenInitTest(DetectEngineCtx **de_ctx, Signature **sig,
393  DetectUrilenData **urilend, const char *str)
394 {
395  char fullstr[1024];
396  int result = 0;
397 
398  *de_ctx = NULL;
399  *sig = NULL;
400 
401  if (snprintf(fullstr, 1024, "alert ip any any -> any any (msg:\"Urilen "
402  "test\"; urilen:%s; sid:1;)", str) >= 1024) {
403  goto end;
404  }
405 
407  if (*de_ctx == NULL) {
408  goto end;
409  }
410 
411  (*de_ctx)->flags |= DE_QUIET;
412 
413  (*de_ctx)->sig_list = SigInit(*de_ctx, fullstr);
414  if ((*de_ctx)->sig_list == NULL) {
415  goto end;
416  }
417 
418  *sig = (*de_ctx)->sig_list;
419 
420  *urilend = DetectUrilenParse(str);
421 
422  result = 1;
423 
424 end:
425  return result;
426 }
427 
428 /**
429  * \test DetectUrilenSetpTest01 is a test for setting up an valid urilen values
430  * with valid "<>" operator and include spaces arround the given values.
431  * In the test the values are setup with initializing the detection engine
432  * context and setting up the signature itself.
433  */
434 
435 static int DetectUrilenSetpTest01(void)
436 {
437  DetectUrilenData *urilend = NULL;
438  Signature *sig = NULL;
439  DetectEngineCtx *de_ctx = NULL;
440 
441  uint8_t res = DetectUrilenInitTest(&de_ctx, &sig, &urilend, "1 <> 3");
442  FAIL_IF(res == 0);
443  FAIL_IF_NULL(urilend);
444  FAIL_IF_NOT(urilend->du16.arg1 == 1);
445  FAIL_IF_NOT(urilend->du16.arg2 == 3);
446  FAIL_IF_NOT(urilend->du16.mode == DETECT_UINT_RA);
447 
448  DetectUrilenFree(NULL, urilend);
450  PASS;
451 }
452 
453 /** \test Check a signature with given urilen */
454 static int DetectUrilenSigTest01(void)
455 {
456  Flow f;
457  uint8_t httpbuf1[] = "POST /suricata HTTP/1.0\r\n"
458  "Host: foo.bar.tld\r\n"
459  "\r\n";
460  uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
461  TcpSession ssn;
462  ThreadVars th_v;
463  DetectEngineThreadCtx *det_ctx = NULL;
465 
466  memset(&th_v, 0, sizeof(th_v));
467  memset(&f, 0, sizeof(f));
468  memset(&ssn, 0, sizeof(ssn));
469 
470  Packet *p = UTHBuildPacket(NULL, 0, IPPROTO_TCP);
471 
472  FLOW_INITIALIZE(&f);
473  f.protoctx = (void *)&ssn;
474  f.proto = IPPROTO_TCP;
475  f.flags |= FLOW_IPV4;
476 
477  p->flow = &f;
482 
483  StreamTcpInitConfig(true);
484 
487  de_ctx->flags |= DE_QUIET;
488 
489  Signature *s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
490  "(msg:\"Testing urilen\"; "
491  "urilen: <5; sid:1;)");
492  FAIL_IF_NULL(s);
493  s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
494  "(msg:\"Testing http_method\"; "
495  "urilen: >5; sid:2;)");
496  FAIL_IF_NULL(s);
497 
499  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
500 
501  int r = AppLayerParserParse(
502  NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1);
503  FAIL_IF(r != 0);
504 
505  HtpState *htp_state = f.alstate;
506  FAIL_IF_NULL(htp_state);
507 
508  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
509 
510  FAIL_IF(PacketAlertCheck(p, 1));
511  FAIL_IF(!PacketAlertCheck(p, 2));
512 
513  UTHFreePackets(&p, 1);
514  FLOW_DESTROY(&f);
515 
517  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
519  StreamTcpFreeConfig(true);
520  StatsThreadCleanup(&th_v);
521  PASS;
522 }
523 
524 /**
525  * \brief this function registers unit tests for DetectUrilen
526  */
527 void DetectUrilenRegisterTests(void)
528 {
529  UtRegisterTest("DetectUrilenParseTest01", DetectUrilenParseTest01);
530  UtRegisterTest("DetectUrilenParseTest02", DetectUrilenParseTest02);
531  UtRegisterTest("DetectUrilenParseTest03", DetectUrilenParseTest03);
532  UtRegisterTest("DetectUrilenParseTest04", DetectUrilenParseTest04);
533  UtRegisterTest("DetectUrilenParseTest05", DetectUrilenParseTest05);
534  UtRegisterTest("DetectUrilenParseTest06", DetectUrilenParseTest06);
535  UtRegisterTest("DetectUrilenParseTest07", DetectUrilenParseTest07);
536  UtRegisterTest("DetectUrilenParseTest08", DetectUrilenParseTest08);
537  UtRegisterTest("DetectUrilenParseTest09", DetectUrilenParseTest09);
538  UtRegisterTest("DetectUrilenParseTest10", DetectUrilenParseTest10);
539  UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01);
540  UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01);
541 }
542 #endif /* UNITTESTS */
util-byte.h
detect-engine-uint.h
SigTableElmt_::url
const char * url
Definition: detect.h:1460
SignatureInitDataBuffer_::head
SigMatch * head
Definition: detect.h:534
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:1459
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:79
PKT_HAS_FLOW
#define PKT_HAS_FLOW
Definition: decode.h:1268
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1444
flow-util.h
SigTableElmt_::name
const char * name
Definition: detect.h:1457
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:69
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:279
DETECT_UINT_NE
#define DETECT_UINT_NE
Definition: detect-engine-uint.h:36
Flow_::proto
uint8_t proto
Definition: flow.h:370
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:142
Packet_::flags
uint32_t flags
Definition: decode.h:544
Flow_
Flow data structure.
Definition: flow.h:348
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:932
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2634
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:225
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:2416
DetectBufferType_
Definition: detect.h:449
DetectContentData_
Definition: detect-content.h:93
SCDetectSignatureSetAppProto
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2229
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:3439
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:532
Flow_::protoctx
void * protoctx
Definition: flow.h:433
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1439
FLOW_IPV4
#define FLOW_IPV4
Definition: flow.h:100
DetectUrilenApplyToContent
void DetectUrilenApplyToContent(Signature *s, int list)
set prefilter dsize pair
Definition: detect-urilen.c:149
util-unittest.h
HtpState_
Definition: app-layer-htp.h:181
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:496
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:18
DetectEngineThreadCtx_
Definition: detect.h:1244
alp_tctx
AppLayerParserThreadCtx * alp_tctx
Definition: fuzz_applayerparserparse.c:23
DETECT_CONTENT_DEPTH
#define DETECT_CONTENT_DEPTH
Definition: detect-content.h:33
SCEnter
#define SCEnter(...)
Definition: util-debug.h:281
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:388
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:3364
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:3097
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:501
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:94
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:747
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:1419
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2194
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:217
Packet_::flow
struct Flow_ * flow
Definition: decode.h:546
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:867
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:1277
suricata-common.h
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:36
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Definition: detect-engine.c:3596
DetectUrilenRegister
void DetectUrilenRegister(void)
Registration function for urilen: keyword.
Definition: detect-urilen.c:61
SignatureInitData_::buffers
SignatureInitDataBuffer * buffers
Definition: detect.h:647
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:271
Flow_::alstate
void * alstate
Definition: flow.h:471
Signature_::id
uint32_t id
Definition: detect.h:713
Flow_::flags
uint32_t flags
Definition: flow.h:413
detect-parse.h
SignatureInitDataBuffer_::id
uint32_t id
Definition: detect.h:525
Signature_
Signature container.
Definition: detect.h:668
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:227
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2595
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:934
AppLayerParserThreadCtx_
Definition: app-layer-parser.c:60
TcpSession_
Definition: stream-tcp-private.h:283
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:442
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:285
SignatureInitData_::buffer_index
uint32_t buffer_index
Definition: detect.h:648
StatsThreadCleanup
void StatsThreadCleanup(ThreadVars *tv)
Definition: counters.c:1324
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:1264
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1446
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