Go to the documentation of this file.
39 #define PARSE_REGEX "^\\s*([a-zA-Z][a-zA-Z0-9-_]*)\\s*$"
45 static void DetectClasstypeRegisterTests(
void);
70 static int DetectClasstypeParseRawString(
const char *rawstr,
char *out,
size_t outsize)
84 ret = pcre2_substring_copy_bynumber(parse_regex.
match, 1, (PCRE2_UCHAR8 *)e, &pcre2len);
86 SCLogError(
"pcre2_substring_copy_bynumber failed");
117 "keyword detected.");
121 "keyword detected. Using instance with highest priority");
125 if (DetectClasstypeParseRawString(rawstr, parsed_ct_name,
sizeof(parsed_ct_name)) < 0) {
126 SCLogError(
"invalid value for classtype keyword: "
136 SCLogError(
"unknown classtype '%s'", parsed_ct_name);
142 "unknown classtype: \"%s\", using default priority %d. "
143 "This message won't be shown again for this classtype",
147 "unknown classtype: \"%s\", using default priority %d. "
148 "This message won't be shown again for this classtype",
152 "using default priority %d. "
153 "This message won't be shown again for this classtype",
158 snprintf(
str,
sizeof(
str),
159 "config classification: %s,Unknown Classtype,%d\n",
175 bool update_ct =
false;
179 }
else if (s->
prio == -1) {
189 if (real_ct && update_ct) {
201 static int DetectClasstypeTest01(
void)
210 "(msg:\"Classtype test\"; "
211 "Classtype:not_available; sid:1;)");
224 static int DetectClasstypeTest02(
void)
234 "(Classtype:bad-unknown; sid:1;)");
238 "(Classtype:not-there; sid:2;)");
242 "(Classtype:Bad-UnkNown; sid:3;)");
246 "(Classtype:nothing-wrong; sid:4;)");
250 "(Classtype:attempted_dos; Classtype:bad-unknown; sid:5;)");
256 "(Classtype:nothing-wrong; Classtype:Bad-UnkNown; sid:6;)");
268 static int DetectClasstypeTest03(
void)
278 "(msg:\"Classtype test\"; Classtype:bad-unknown; priority:1; sid:1;)");
283 "(msg:\"Classtype test\"; Classtype:unKnoWn; "
284 "priority:3; sid:2;)");
289 "Classtype:nothing-wrong; priority:1; sid:3;)");
293 "(msg:\"Classtype test\"; Classtype:bad-unknown; Classtype:undefined; "
294 "priority:5; sid:4;)");
305 static void DetectClasstypeRegisterTests(
void)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
int DetectParsePcreExec(DetectParseRegex *parse_regex, const char *str, int start_offset, int options)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
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.
size_t strlcpy(char *dst, const char *src, size_t siz)
#define PASS
Pass the test.
Container for a Classtype from the Classification.config file.
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
int SCClassConfAddClasstype(DetectEngineCtx *de_ctx, char *rawstr, uint16_t index)
Parses a line from the classification file and adds it to Classtype hash table in DetectEngineCtx,...
bool SigMatchStrictEnabled(const enum DetectKeywordId id)
#define SCLogWarning(...)
Macro used to log WARNING messages.
SCClassConfClasstype * SCClassConfGetClasstype(const char *ct_name, DetectEngineCtx *de_ctx)
Gets the classtype from the corresponding hash table stored in the Detection Engine Context's class c...
#define SIG_FLAG_INIT_PRIO_EXPLICT
bool SCClassConfLoadClassficationConfigFile(DetectEngineCtx *de_ctx, FILE *fd)
Loads the Classtype info from the classification.config file.
SignatureInitData * init_data
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
#define SCLogError(...)
Macro used to log ERROR messages.
#define CLASSTYPE_NAME_MAX_LEN
DetectEngineCtx * DetectEngineCtxInit(void)
FILE * SCClassConfGenerateValidDummyClassConfigFD01(void)
Creates a dummy classification file, with all valid Classtypes, for testing purposes.
#define DETECT_DEFAULT_PRIO
void DetectClasstypeRegister(void)
Registers the handler functions for the "Classtype" keyword.
void(* RegisterTests)(void)