Go to the documentation of this file.
36 #define PARSE_REGEX "^\\s*(\\d+|\"\\d+\")\\s*$"
42 static void PriorityRegisterTests(
void);
62 char copy_str[128] =
"";
65 pcre2_match_data *match = NULL;
72 pcre2_match_data_free(match);
76 pcre2len =
sizeof(copy_str);
77 ret = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
79 SCLogError(
"pcre2_substring_copy_bynumber failed");
80 pcre2_match_data_free(match);
84 pcre2_match_data_free(match);
86 int prio = (int)strtol(copy_str, &endptr, 10);
87 if (endptr == NULL || *endptr !=
'\0') {
89 "to priority keyword");
95 "keyword. Using highest priority in the rule");
108 static int DetectPriorityTest01(
void)
114 "(msg:\"Priority test\"; priority:2; sid:1;)");
123 static int DetectPriorityTest02(
void)
129 "(msg:\"Priority test\"; priority:1; sid:1;)");
134 "(msg:\"Priority test\"; priority:boo; sid:2;)");
138 "(msg:\"Priority test\"; priority:10boo; sid:3;)");
142 "(msg:\"Priority test\"; priority:b10oo; sid:4;)");
146 "(msg:\"Priority test\"; priority:boo10; sid:5;)");
150 "(msg:\"Priority test\"; priority:-1; sid:6;)");
154 "(msg:\"Priority test\"; sid:7;)");
159 "(msg:\"Priority test\"; priority:5; priority:4; sid:8;)");
164 "(msg:\"Priority test\"; priority:5; priority:4; "
165 "priority:1; sid:9;)");
176 static void PriorityRegisterTests(
void)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
SigTableElmt * sigmatch_table
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define SIG_FLAG_INIT_PRIO_EXPLICIT
void DetectPriorityRegister(void)
Registers the handler functions for the "priority" keyword.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
#define PASS
Pass the test.
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
#define SCLogWarning(...)
Macro used to log WARNING messages.
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
SignatureInitData * init_data
#define SCLogError(...)
Macro used to log ERROR messages.
DetectEngineCtx * DetectEngineCtxInit(void)
void(* RegisterTests)(void)