Go to the documentation of this file.
37 #define PARSE_REGEX "^\\s*(\\d+|\"\\d+\")\\s*$"
43 static void PriorityRegisterTests(
void);
63 char copy_str[128] =
"";
66 pcre2_match_data *match = NULL;
73 pcre2_match_data_free(match);
77 pcre2len =
sizeof(copy_str);
78 ret = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
80 SCLogError(
"pcre2_substring_copy_bynumber failed");
81 pcre2_match_data_free(match);
85 pcre2_match_data_free(match);
87 long prio = strtol(copy_str, &endptr, 10);
88 if (endptr == NULL || *endptr !=
'\0') {
90 "to priority keyword");
96 "keyword. Using highest priority in the rule");
109 static int DetectPriorityTest01(
void)
115 "(msg:\"Priority test\"; priority:2; sid:1;)");
124 static int DetectPriorityTest02(
void)
130 "(msg:\"Priority test\"; priority:1; sid:1;)");
135 "(msg:\"Priority test\"; priority:boo; sid:2;)");
139 "(msg:\"Priority test\"; priority:10boo; sid:3;)");
143 "(msg:\"Priority test\"; priority:b10oo; sid:4;)");
147 "(msg:\"Priority test\"; priority:boo10; sid:5;)");
151 "(msg:\"Priority test\"; priority:-1; sid:6;)");
155 "(msg:\"Priority test\"; sid:7;)");
160 "(msg:\"Priority test\"; priority:5; priority:4; sid:8;)");
165 "(msg:\"Priority test\"; priority:5; priority:4; "
166 "priority:1; sid:9;)");
177 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)