Go to the documentation of this file.
47 "^\\s*([A-Za-z0-9]+)\\s*,\"?\\s*\"?\\s*([a-zA-Z]+:\\/\\/)?([a-zA-Z0-9\\-_\\.\\/" \
53 static void ReferenceRegisterTests(
void);
109 pcre2_match_data *match = NULL;
113 "keyword argument - \"%s\". Invalid argument.",
116 pcre2_match_data_free(match);
123 pcre2_match_data_free(match);
128 pcre2len =
sizeof(key);
129 res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)key, &pcre2len);
131 SCLogError(
"pcre2_substring_copy_bynumber key failed");
136 pcre2len =
sizeof(scheme);
137 (void)pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)scheme, &pcre2len);
140 pcre2len =
sizeof(uri);
141 res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)uri, &pcre2len);
143 SCLogError(
"pcre2_substring_copy_bynumber domain-path failed");
147 size_t ref_len = strlen(uri);
149 if (strlen(key) == 0 || ref_len == 0)
152 if (strlen(scheme)) {
153 SCLogConfig(
"scheme value %s overrides key %s", scheme, key);
155 if (ref->
key == NULL) {
159 ref->
key_len = (uint16_t)strlen(scheme);
163 if (lookup_ref_conf == NULL) {
165 SCLogError(
"unknown reference key \"%s\"", key);
172 snprintf(
str,
sizeof(
str),
"config reference: %s undefined\n", key);
177 if (lookup_ref_conf == NULL)
182 if (ref->
key == NULL) {
192 SCLogError(
"strdup failed: %s", strerror(errno));
199 pcre2_match_data_free(match);
205 pcre2_match_data_free(match);
240 while (sig_refs->
next != NULL) {
241 sig_refs = sig_refs->
next;
243 sig_refs->
next = ref;
260 static int DetectReferenceParseTest01(
void)
272 "(msg:\"One reference\"; reference:one,001-2010; sid:2;)");
277 FAIL_IF (strcmp(ref->
key,
"http://www.one.com") != 0);
290 static int DetectReferenceParseTest02(
void)
302 "(msg:\"Two references\"; "
303 "reference:one,openinfosecdoundation.txt; "
304 "reference:two,001-2010; sid:2;)");
310 FAIL_IF (strcmp(ref->
key,
"http://www.one.com") != 0);
314 FAIL_IF (strcmp(ref->
key,
"http://www.two.com") != 0);
327 static int DetectReferenceParseTest03(
void)
339 "(msg:\"invalid ref\"; "
340 "reference:unknownkey,001-2010; sid:2;)");
353 static void ReferenceRegisterTests(
void)
355 UtRegisterTest(
"DetectReferenceParseTest01", DetectReferenceParseTest01);
356 UtRegisterTest(
"DetectReferenceParseTest02", DetectReferenceParseTest02);
357 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 *)
void SCRConfDeInitContext(DetectEngineCtx *de_ctx)
Releases de_ctx resources related to Reference Config API.
#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)