suricata
detect-rpc.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 Pablo Rincon <pablo.rincon.crespo@gmail.com>
22  *
23  * Implements RPC keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "decode.h"
28 
29 #include "detect.h"
30 #include "detect-rpc.h"
31 #include "detect-parse.h"
32 #include "detect-engine.h"
33 #include "detect-engine-mpm.h"
34 #include "detect-engine-siggroup.h"
35 #include "detect-engine-address.h"
36 #include "detect-engine-build.h"
37 
38 #include "util-unittest.h"
39 #include "util-unittest-helper.h"
40 #include "util-debug.h"
41 #include "util-byte.h"
42 
43 /**
44  * \brief Regex for parsing our rpc options
45  */
46 #define PARSE_REGEX "^\\s*([0-9]{0,10})\\s*(?:,\\s*([0-9]{0,10}|[*])\\s*(?:,\\s*([0-9]{0,10}|[*]))?)?\\s*$"
47 
48 static DetectParseRegex parse_regex;
49 
50 static int DetectRpcMatch (DetectEngineThreadCtx *, Packet *,
51  const Signature *, const SigMatchCtx *);
52 static int DetectRpcSetup (DetectEngineCtx *, Signature *, const char *);
53 #ifdef UNITTESTS
54 static void DetectRpcRegisterTests(void);
55 #endif
56 void DetectRpcFree(DetectEngineCtx *, void *);
57 
58 /**
59  * \brief Registration function for rpc keyword
60  */
61 void DetectRpcRegister (void)
62 {
64  sigmatch_table[DETECT_RPC].desc = "match RPC procedure numbers and RPC version";
65  sigmatch_table[DETECT_RPC].url = "/rules/payload-keywords.html#rpc";
66  sigmatch_table[DETECT_RPC].Match = DetectRpcMatch;
67  sigmatch_table[DETECT_RPC].Setup = DetectRpcSetup;
69 #ifdef UNITTESTS
70  sigmatch_table[DETECT_RPC].RegisterTests = DetectRpcRegisterTests;
71 #endif
72  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
73 }
74 
75 /*
76  * returns 0: no match
77  * 1: match
78  * -1: error
79  */
80 
81 /**
82  * \brief This function is used to match rpc request set on a packet with those passed via rpc
83  *
84  * \param t pointer to thread vars
85  * \param det_ctx pointer to the pattern matcher thread
86  * \param p pointer to the current packet
87  * \param m pointer to the sigmatch that we will cast into DetectRpcData
88  *
89  * \retval 0 no match
90  * \retval 1 match
91  */
92 static int DetectRpcMatch (DetectEngineThreadCtx *det_ctx, Packet *p,
93  const Signature *s, const SigMatchCtx *ctx)
94 {
95  /* PrintRawDataFp(stdout, p->payload, p->payload_len); */
96  const DetectRpcData *rd = (const DetectRpcData *)ctx;
97  char *rpcmsg = (char *)p->payload;
98 
99  if (PKT_IS_TCP(p)) {
100  /* if Rpc msg too small */
101  if (p->payload_len < 28) {
102  SCLogDebug("TCP packet to small for the rpc msg (%u)", p->payload_len);
103  return 0;
104  }
105  rpcmsg += 4;
106  } else if (PKT_IS_UDP(p)) {
107  /* if Rpc msg too small */
108  if (p->payload_len < 24) {
109  SCLogDebug("UDP packet to small for the rpc msg (%u)", p->payload_len);
110  return 0;
111  }
112  } else {
113  SCLogDebug("No valid proto for the rpc message");
114  return 0;
115  }
116 
117  /* Point through the rpc msg structure. Use SCNtohl() to compare values */
118  RpcMsg *msg = (RpcMsg *)rpcmsg;
119 
120  /* If its not a call, no match */
121  if (SCNtohl(msg->type) != 0) {
122  SCLogDebug("RPC message type is not a call");
123  return 0;
124  }
125 
126  if (SCNtohl(msg->prog) != rd->program)
127  return 0;
128 
129  if ((rd->flags & DETECT_RPC_CHECK_VERSION) && SCNtohl(msg->vers) != rd->program_version)
130  return 0;
131 
132  if ((rd->flags & DETECT_RPC_CHECK_PROCEDURE) && SCNtohl(msg->proc) != rd->procedure)
133  return 0;
134 
135  SCLogDebug("prog:%u pver:%u proc:%u matched", SCNtohl(msg->prog), SCNtohl(msg->vers), SCNtohl(msg->proc));
136  return 1;
137 }
138 
139 /**
140  * \brief This function is used to parse rpc options passed via rpc keyword
141  *
142  * \param de_ctx Pointer to the detection engine context
143  * \param rpcstr Pointer to the user provided rpc options
144  *
145  * \retval rd pointer to DetectRpcData on success
146  * \retval NULL on failure
147  */
148 static DetectRpcData *DetectRpcParse (DetectEngineCtx *de_ctx, const char *rpcstr)
149 {
150  DetectRpcData *rd = NULL;
151  char *args[3] = {NULL,NULL,NULL};
152  int ret = 0, res = 0;
153  size_t pcre2_len;
154 
155  ret = DetectParsePcreExec(&parse_regex, rpcstr, 0, 0);
156  if (ret < 1 || ret > 4) {
157  SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 ", string %s", ret, rpcstr);
158  goto error;
159  }
160 
161  if (ret > 1) {
162  const char *str_ptr;
163  res = pcre2_substring_get_bynumber(
164  parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
165  if (res < 0) {
166  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
167  goto error;
168  }
169  args[0] = (char *)str_ptr;
170 
171  if (ret > 2) {
172  res = pcre2_substring_get_bynumber(
173  parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
174  if (res < 0) {
175  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
176  goto error;
177  }
178  args[1] = (char *)str_ptr;
179  }
180  if (ret > 3) {
181  res = pcre2_substring_get_bynumber(
182  parse_regex.match, 3, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
183  if (res < 0) {
184  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
185  goto error;
186  }
187  args[2] = (char *)str_ptr;
188  }
189  }
190 
191  rd = SCMalloc(sizeof(DetectRpcData));
192  if (unlikely(rd == NULL))
193  goto error;
194  rd->flags = 0;
195  rd->program = 0;
196  rd->program_version = 0;
197  rd->procedure = 0;
198 
199  int i;
200  for (i = 0; i < (ret - 1); i++) {
201  if (args[i]) {
202  switch (i) {
203  case 0:
204  if (StringParseUint32(&rd->program, 10, strlen(args[i]), args[i]) <= 0) {
205  SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc program:\"%s\"", args[i]);
206  goto error;
207  }
209  break;
210  case 1:
211  if (args[i][0] != '*') {
212  if (StringParseUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) {
213  SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc version:\"%s\"", args[i]);
214  goto error;
215  }
217  }
218  break;
219  case 2:
220  if (args[i][0] != '*') {
221  if (StringParseUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) {
222  SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
223  goto error;
224  }
226  }
227  break;
228  }
229  } else {
230  SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",rpcstr);
231  goto error;
232  }
233  }
234  for (i = 0; i < (ret -1); i++){
235  if (args[i] != NULL)
236  pcre2_substring_free((PCRE2_UCHAR8 *)args[i]);
237  }
238  return rd;
239 
240 error:
241  for (i = 0; i < (ret -1) && i < 3; i++){
242  if (args[i] != NULL)
243  pcre2_substring_free((PCRE2_UCHAR8 *)args[i]);
244  }
245  if (rd != NULL)
246  DetectRpcFree(de_ctx, rd);
247  return NULL;
248 
249 }
250 
251 /**
252  * \brief this function is used to add the parsed rpcdata into the current signature
253  *
254  * \param de_ctx pointer to the Detection Engine Context
255  * \param s pointer to the Current Signature
256  * \param m pointer to the Current SigMatch
257  * \param rpcstr pointer to the user provided rpc options
258  *
259  * \retval 0 on Success
260  * \retval -1 on Failure
261  */
262 int DetectRpcSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rpcstr)
263 {
264  DetectRpcData *rd = NULL;
265  SigMatch *sm = NULL;
266 
267  rd = DetectRpcParse(de_ctx, rpcstr);
268  if (rd == NULL) goto error;
269 
270  sm = SigMatchAlloc();
271  if (sm == NULL)
272  goto error;
273 
274  sm->type = DETECT_RPC;
275  sm->ctx = (SigMatchCtx *)rd;
276 
279 
280  return 0;
281 
282 error:
283  if (rd != NULL) DetectRpcFree(de_ctx, rd);
284  if (sm != NULL) SCFree(sm);
285  return -1;
286 
287 }
288 
289 /**
290  * \brief this function will free memory associated with DetectRpcData
291  *
292  * \param rd pointer to DetectRpcData
293  */
295 {
296  SCEnter();
297 
298  if (ptr == NULL) {
299  SCReturn;
300  }
301 
302  DetectRpcData *rd = (DetectRpcData *)ptr;
303  SCFree(rd);
304 
305  SCReturn;
306 }
307 
308 #ifdef UNITTESTS
309 #include "detect-engine-alert.h"
310 /**
311  * \test DetectRpcTestParse01 is a test to make sure that we return "something"
312  * when given valid rpc opt
313  */
314 static int DetectRpcTestParse01 (void)
315 {
316  DetectRpcData *rd = DetectRpcParse(NULL, "123,444,555");
317  FAIL_IF_NULL(rd);
318 
319  DetectRpcFree(NULL, rd);
320  PASS;
321 }
322 
323 /**
324  * \test DetectRpcTestParse02 is a test for setting the established rpc opt
325  */
326 static int DetectRpcTestParse02 (void)
327 {
328  DetectRpcData *rd = NULL;
329  rd = DetectRpcParse(NULL, "111,222,333");
330  FAIL_IF_NULL(rd);
334  FAIL_IF_NOT(rd->program == 111);
335  FAIL_IF_NOT(rd->program_version == 222);
336  FAIL_IF_NOT(rd->procedure == 333);
337 
338  DetectRpcFree(NULL, rd);
339 
340  PASS;
341 }
342 
343 /**
344  * \test DetectRpcTestParse03 is a test for checking the wildcards
345  * and not specified fields
346  */
347 static int DetectRpcTestParse03 (void)
348 {
349  DetectRpcData *rd = NULL;
350 
351  rd = DetectRpcParse(NULL, "111,*,333");
352  FAIL_IF_NULL(rd);
353 
357  FAIL_IF_NOT(rd->program == 111);
358  FAIL_IF_NOT(rd->program_version == 0);
359  FAIL_IF_NOT(rd->procedure == 333);
360 
361  DetectRpcFree(NULL, rd);
362 
363  rd = DetectRpcParse(NULL, "111,222,*");
364  FAIL_IF_NULL(rd);
365 
369  FAIL_IF_NOT(rd->program == 111);
370  FAIL_IF_NOT(rd->program_version == 222);
371  FAIL_IF_NOT(rd->procedure == 0);
372 
373  DetectRpcFree(NULL, rd);
374 
375  rd = DetectRpcParse(NULL, "111,*,*");
376  FAIL_IF_NULL(rd);
377 
381  FAIL_IF_NOT(rd->program == 111);
382  FAIL_IF_NOT(rd->program_version == 0);
383  FAIL_IF_NOT(rd->procedure == 0);
384 
385  DetectRpcFree(NULL, rd);
386 
387  rd = DetectRpcParse(NULL, "111,222");
388  FAIL_IF_NULL(rd);
389 
393  FAIL_IF_NOT(rd->program == 111);
394  FAIL_IF_NOT(rd->program_version == 222);
395  FAIL_IF_NOT(rd->procedure == 0);
396 
397  DetectRpcFree(NULL, rd);
398 
399  rd = DetectRpcParse(NULL, "111");
400  FAIL_IF_NULL(rd);
401 
405  FAIL_IF_NOT(rd->program == 111);
406  FAIL_IF_NOT(rd->program_version == 0);
407  FAIL_IF_NOT(rd->procedure == 0);
408 
409  DetectRpcFree(NULL, rd);
410  PASS;
411 }
412 
413 /**
414  * \test DetectRpcTestParse04 is a test for check the discarding of empty options
415  */
416 static int DetectRpcTestParse04 (void)
417 {
418  DetectRpcData *rd = NULL;
419  rd = DetectRpcParse(NULL, "");
420 
421  FAIL_IF_NOT_NULL(rd);
422  DetectRpcFree(NULL, rd);
423 
424  PASS;
425 }
426 
427 /**
428  * \test DetectRpcTestParse05 is a test for check invalid values
429  */
430 static int DetectRpcTestParse05 (void)
431 {
432  DetectRpcData *rd = NULL;
433  rd = DetectRpcParse(NULL, "111,aaa,*");
434 
435  FAIL_IF_NOT_NULL(rd);
436  DetectRpcFree(NULL, rd);
437 
438  PASS;
439 }
440 
441 /**
442  * \test DetectRpcTestParse05 is a test to check the match function
443  */
444 static int DetectRpcTestSig01(void)
445 {
446  /* RPC Call */
447  uint8_t buf[] = {
448  /* XID */
449  0x64,0xb2,0xb3,0x75,
450  /* Message type: Call (0) */
451  0x00,0x00,0x00,0x00,
452  /* RPC Version (2) */
453  0x00,0x00,0x00,0x02,
454  /* Program portmap (100000) */
455  0x00,0x01,0x86,0xa0,
456  /* Program version (2) */
457  0x00,0x00,0x00,0x02,
458  /* Program procedure (3) = GETPORT */
459  0x00,0x00,0x00,0x03,
460  /* AUTH_NULL */
461  0x00,0x00,0x00,0x00,
462  /* Length 0 */
463  0x00,0x00,0x00,0x00,
464  /* VERIFIER NULL */
465  0x00,0x00,0x00,0x00,
466  /* Length 0 */
467  0x00,0x00,0x00,0x00,
468  /* Program portmap */
469  0x00,0x01,0x86,0xa2,
470  /* Version 2 */
471  0x00,0x00,0x00,0x02,
472  /* Proto UDP */
473  0x00,0x00,0x00,0x11,
474  /* Port 0 */
475  0x00,0x00,0x00,0x00 };
476  uint16_t buflen = sizeof(buf);
477  Packet *p = NULL;
478  Signature *s = NULL;
479  ThreadVars th_v;
480  DetectEngineThreadCtx *det_ctx;
481 
482  memset(&th_v, 0, sizeof(th_v));
483 
484  p = UTHBuildPacket(buf, buflen, IPPROTO_UDP);
485 
488 
489  de_ctx->flags |= DE_QUIET;
490 
492  "alert udp any any -> any any (msg:\"RPC Get Port Call\"; rpc:100000, 2, 3; sid:1;)");
493  FAIL_IF_NULL(s);
494 
496  "alert udp any any -> any any (msg:\"RPC Get Port Call\"; rpc:100000, 2, *; sid:2;)");
497  FAIL_IF_NULL(s);
498 
500  "alert udp any any -> any any (msg:\"RPC Get Port Call\"; rpc:100000, *, 3; sid:3;)");
501  FAIL_IF_NULL(s);
502 
504  "alert udp any any -> any any (msg:\"RPC Get Port Call\"; rpc:100000, *, *; sid:4;)");
505  FAIL_IF_NULL(s);
506 
507  s = DetectEngineAppendSig(de_ctx, "alert udp any any -> any any (msg:\"RPC Get XXX Call.. no "
508  "match\"; rpc:123456, *, 3; sid:5;)");
509  FAIL_IF_NULL(s);
510 
512  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
513 
514  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
515  FAIL_IF(PacketAlertCheck(p, 1) == 0);
516  FAIL_IF(PacketAlertCheck(p, 2) == 0);
517  FAIL_IF(PacketAlertCheck(p, 3) == 0);
518  FAIL_IF(PacketAlertCheck(p, 4) == 0);
519  FAIL_IF(PacketAlertCheck(p, 5) > 0);
520 
521  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
523 
524  UTHFreePackets(&p, 1);
525 
526  PASS;
527 }
528 
529 /**
530  * \brief this function registers unit tests for DetectRpc
531  */
532 static void DetectRpcRegisterTests(void)
533 {
534  UtRegisterTest("DetectRpcTestParse01", DetectRpcTestParse01);
535  UtRegisterTest("DetectRpcTestParse02", DetectRpcTestParse02);
536  UtRegisterTest("DetectRpcTestParse03", DetectRpcTestParse03);
537  UtRegisterTest("DetectRpcTestParse04", DetectRpcTestParse04);
538  UtRegisterTest("DetectRpcTestParse05", DetectRpcTestParse05);
539  UtRegisterTest("DetectRpcTestSig01", DetectRpcTestSig01);
540 }
541 #endif /* UNITTESTS */
PKT_IS_UDP
#define PKT_IS_UDP(p)
Definition: decode.h:245
util-byte.h
DetectParseRegex::match
pcre2_match_data * match
Definition: detect-parse.h:47
SigTableElmt_::url
const char * url
Definition: detect.h:1238
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:1237
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, const char *str, int start_offset, int options)
Definition: detect-parse.c:2488
SC_ERR_INVALID_VALUE
@ SC_ERR_INVALID_VALUE
Definition: util-error.h:160
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1225
detect-engine-siggroup.h
DetectParseRegex
Definition: detect-parse.h:44
SigTableElmt_::name
const char * name
Definition: detect.h:1235
PARSE_REGEX
#define PARSE_REGEX
Regex for parsing our rpc options.
Definition: detect-rpc.c:46
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DetectRpcData_
Definition: detect-rpc.h:47
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
DetectRpcData_::flags
uint8_t flags
Definition: detect-rpc.h:51
DetectRpcData_::procedure
uint32_t procedure
Definition: detect-rpc.h:50
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:296
RpcMsg_
Definition: detect-rpc.h:35
Packet_::payload
uint8_t * payload
Definition: decode.h:567
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
DetectRpcRegister
void DetectRpcRegister(void)
Registration function for rpc keyword.
Definition: detect-rpc.c:61
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:784
DetectRpcData_::program_version
uint32_t program_version
Definition: detect-rpc.h:49
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2445
DETECT_RPC_CHECK_PROCEDURE
#define DETECT_RPC_CHECK_PROCEDURE
Definition: detect-rpc.h:32
DE_QUIET
#define DE_QUIET
Definition: detect.h:287
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:339
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1788
SC_ERR_PCRE_GET_SUBSTRING
@ SC_ERR_PCRE_GET_SUBSTRING
Definition: util-error.h:34
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1220
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:568
DETECT_RPC
@ DETECT_RPC
Definition: detect-engine-register.h:84
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
detect-rpc.h
PKT_IS_TCP
#define PKT_IS_TCP(p)
Definition: decode.h:244
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
SC_ERR_PCRE_MATCH
@ SC_ERR_PCRE_MATCH
Definition: util-error.h:32
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectEngineThreadCtx_
Definition: detect.h:1024
DetectRpcData_::program
uint32_t program
Definition: detect-rpc.h:48
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2611
SCEnter
#define SCEnter(...)
Definition: util-debug.h:298
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
DETECT_SM_LIST_MATCH
@ DETECT_SM_LIST_MATCH
Definition: detect.h:78
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:316
SCReturn
#define SCReturn
Definition: util-debug.h:300
Signature_::flags
uint32_t flags
Definition: detect.h:540
Packet_
Definition: decode.h:425
detect-engine-build.h
detect-engine-alert.h
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1203
SigMatchAlloc
SigMatch * SigMatchAlloc(void)
Definition: detect-parse.c:238
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:1954
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:308
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *de_ctx, const char *sigstr)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2434
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3154
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:3368
SigMatch_::type
uint16_t type
Definition: detect.h:314
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:76
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:255
DetectRpcFree
void DetectRpcFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectRpcData
Definition: detect-rpc.c:294
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
SCFree
#define SCFree(p)
Definition: util-mem.h:61
SCNtohl
#define SCNtohl(x)
Definition: suricata-common.h:402
detect-parse.h
Signature_
Signature container.
Definition: detect.h:539
SigMatch_
a single match condition for a signature
Definition: detect.h:313
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2406
DETECT_RPC_CHECK_PROGRAM
#define DETECT_RPC_CHECK_PROGRAM
Definition: detect-rpc.h:30
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:785
msg
const char * msg
Definition: app-layer-htp.c:571
DETECT_RPC_CHECK_VERSION
#define DETECT_RPC_CHECK_VERSION
Definition: detect-rpc.h:31
SigMatchAppendSMToList
void SigMatchAppendSMToList(Signature *s, SigMatch *new, int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:352
detect-engine-address.h
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1227
SIG_FLAG_REQUIRE_PACKET
#define SIG_FLAG_REQUIRE_PACKET
Definition: detect.h:215
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:470