Go to the documentation of this file.
44 #define PARSE_REGEX "(.*),(.*)"
120 char varname[64], varcontent[64];
123 uint8_t *content = NULL;
124 uint16_t contentlen = 0;
126 pcre2_match_data *match = NULL;
130 SCLogError(
"\"%s\" is not a valid setting for flowvar.", rawstr);
132 pcre2_match_data_free(match);
137 pcre2len =
sizeof(varname);
138 res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)varname, &pcre2len);
140 pcre2_match_data_free(match);
141 SCLogError(
"pcre2_substring_copy_bynumber failed");
145 pcre2len =
sizeof(varcontent);
146 res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)varcontent, &pcre2len);
147 pcre2_match_data_free(match);
149 SCLogError(
"pcre2_substring_copy_bynumber failed");
153 int varcontent_index = 0;
154 if (strlen(varcontent) >= 2) {
155 if (varcontent[0] ==
'"')
157 if (varcontent[strlen(varcontent)-1] ==
'"')
158 varcontent[strlen(varcontent)-1] =
'\0';
160 SCLogDebug(
"varcontent %s", &varcontent[varcontent_index]);
174 memcpy(fd->
content, content, contentlen);
176 fd->
flags = contentflags;
196 DetectFlowvarDataFree(
de_ctx, fd);
204 uint8_t *key, uint16_t key_len,
205 uint8_t *buffer, uint16_t
len,
int type)
225 uint8_t *buffer, uint16_t
len,
int type)
230 for ( ; fs != NULL; fs = fs->
next) {
231 if (fs->
idx == idx) {
278 DetectFlowvarDataFree(
de_ctx, fv);
287 static int DetectFlowvarPostMatch(
302 if (fd->
idx == 0 || fd->
idx == fs->
idx) {
360 }
while (fs != NULL);
int DetectFlowvarPostMatchSetup(DetectEngineCtx *de_ctx, Signature *s, uint32_t idx)
Setup a post-match for flowvar storage We're piggyback riding the DetectFlowvarData struct.
union FlowVar_::@109 data
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
int DetectVarStoreMatch(DetectEngineThreadCtx *det_ctx, uint32_t idx, uint8_t *buffer, uint16_t len, int type)
Store flowvar in det_ctx so we can exec it post-match.
struct HtpBodyChunk_ * next
main detection engine ctx
void DetectVarProcessListInternal(DetectVarList *fs, Flow *f, Packet *p)
Handle flowvar candidate list in det_ctx: clean up the list.
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
#define DETECT_VAR_TYPE_PKT_POSTMATCH
int PktVarAdd(Packet *p, uint32_t id, uint8_t *value, uint16_t size)
add a key-value pktvar to the pkt
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
@ DETECT_SM_LIST_POSTMATCH
@ DETECT_FLOWVAR_POSTMATCH
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type)
#define DETECT_CONTENT_NEGATED
struct DetectVarList_ * next
void FlowVarAddIdValue(Flow *f, uint32_t idx, uint8_t *value, uint16_t size)
SignatureInitData * init_data
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define DETECT_VAR_TYPE_FLOW_POSTMATCH
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int DetectContentDataParse(const char *keyword, const char *contentstr, uint8_t **pstr, uint16_t *plen)
Parse a content string, ie "abc|DE|fgh".
void DetectFlowvarRegister(void)
#define SCLogError(...)
Macro used to log ERROR messages.
int DetectVarStoreMatchKeyValue(DetectEngineThreadCtx *det_ctx, uint8_t *key, uint16_t key_len, uint8_t *buffer, uint16_t len, int type)
Store flowvar in det_ctx so we can exec it post-match.
#define SpmSearch(text, textlen, needle, needlelen)
int PktVarAddKeyValue(Packet *p, uint8_t *key, uint16_t ksize, uint8_t *value, uint16_t size)
add a key-value pktvar to the pkt
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
FlowVar * FlowVarGet(Flow *f, uint32_t idx)
get the flowvar with index 'idx' from the flow
int DetectFlowvarMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)