Go to the documentation of this file.
48 "^\\s*([A-Za-z0-9]+)\\s*,\"?\\s*\"?\\s*([a-zA-Z]+:\\/\\/)?([a-zA-Z0-9\\-_\\.\\/" \
54 static void ReferenceRegisterTests(
void);
110 pcre2_match_data *match = NULL;
114 "keyword argument - \"%s\". Invalid argument.",
117 pcre2_match_data_free(match);
124 pcre2_match_data_free(match);
129 pcre2len =
sizeof(key);
130 res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)key, &pcre2len);
132 SCLogError(
"pcre2_substring_copy_bynumber key failed");
137 pcre2len =
sizeof(scheme);
138 (void)pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)scheme, &pcre2len);
141 pcre2len =
sizeof(uri);
142 res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)uri, &pcre2len);
144 SCLogError(
"pcre2_substring_copy_bynumber domain-path failed");
148 int ref_len = strlen(uri);
150 if (strlen(key) == 0 || ref_len == 0)
153 if (strlen(scheme)) {
154 SCLogConfig(
"scheme value %s overrides key %s", scheme, key);
157 ref->
key_len = (uint16_t)strlen(scheme);
161 if (lookup_ref_conf != NULL) {
167 SCLogError(
"unknown reference key \"%s\"", key);
174 snprintf(
str,
sizeof(
str),
"config reference: %s undefined\n", key);
179 if (lookup_ref_conf == NULL)
187 SCLogError(
"strdup failed: %s", strerror(errno));
194 pcre2_match_data_free(match);
200 pcre2_match_data_free(match);
235 while (sig_refs->
next != NULL) {
236 sig_refs = sig_refs->
next;
238 sig_refs->
next = ref;
255 static int DetectReferenceParseTest01(
void)
266 "(msg:\"One reference\"; reference:one,001-2010; sid:2;)");
271 FAIL_IF (strcmp(ref->
key,
"http://www.one.com") != 0);
284 static int DetectReferenceParseTest02(
void)
295 "(msg:\"Two references\"; "
296 "reference:one,openinfosecdoundation.txt; "
297 "reference:two,001-2010; sid:2;)");
303 FAIL_IF (strcmp(ref->
key,
"http://www.one.com") != 0);
307 FAIL_IF (strcmp(ref->
key,
"http://www.two.com") != 0);
320 static int DetectReferenceParseTest03(
void)
331 "(msg:\"invalid ref\"; "
332 "reference:unknownkey,001-2010; sid:2;)");
338 static void ReferenceRegisterTests(
void)
340 UtRegisterTest(
"DetectReferenceParseTest01", DetectReferenceParseTest01);
341 UtRegisterTest(
"DetectReferenceParseTest02", DetectReferenceParseTest02);
342 UtRegisterTest(
"DetectReferenceParseTest03", DetectReferenceParseTest03);
#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.
void DetectReferenceFree(DetectReference *ref)
Free a Reference object.
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 PASS
Pass the test.
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
DetectReference * references
bool SigMatchStrictEnabled(const enum DetectKeywordId id)
#define SCLogWarning(...)
Macro used to log WARNING messages.
Signature reference list.
#define REFERENCE_SYSTEM_NAME_MAX
int SCRConfLoadReferenceConfigFile(DetectEngineCtx *de_ctx, FILE *fd)
Loads the Reference info from the reference.config file.
#define SCReturnPtr(x, type)
void DetectReferenceRegister(void)
Registration function for the reference: keyword.
int SCRConfAddReference(DetectEngineCtx *de_ctx, const char *line)
Parses a line from the reference config file and adds it to Reference Config hash table DetectEngineC...
struct DetectReference_ * next
SCRConfReference * SCRConfGetReference(const char *rconf_name, DetectEngineCtx *de_ctx)
Gets the reference config from the corresponding hash table stored in the Detection Engine Context's ...
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Holds a reference from the file - reference.config.
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
#define SCLogError(...)
Macro used to log ERROR messages.
DetectEngineCtx * DetectEngineCtxInit(void)
FILE * SCRConfGenerateValidDummyReferenceConfigFD01(void)
Creates a dummy reference config, with all valid references, for testing purposes.
#define REFERENCE_CONTENT_NAME_MAX
void(* RegisterTests)(void)