-
Notifications
You must be signed in to change notification settings - Fork 1.5k
detect: factorize code for DetectSetupDirection (transactional rules) #13046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ticket: 7665 Instead of each keyword calling DetectSetupDirection, use a new flag SIGMATCH_SUPPORT_DIR so that DetectSetupDirection gets called, before parsing the rest of the keyword. Allows to support filesize keyword in transactional signatures
Information: QA ran without warnings. Pipeline 25721 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions inline, also needs a rebase
*/ | ||
static int DetectSetupDirection(Signature *s, char **str, bool only_dir) | ||
{ | ||
if (strncmp(*str, "to_client", strlen("to_client")) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will also match to_client_toto
I think. Will that be detected correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
After matching the prefix, we check further characters : optional spaces then comma or end of string
to_client_toto
gets to line 887 SCLogError("expecting to_client [, other]");
* | ||
* \retval 0 on success, -1 on failure | ||
*/ | ||
static int DetectSetupDirection(Signature *s, char **str, bool only_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not a single pointer char *str
? We're not passing something back, are we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not passing something back, are we?
Yes, we are moving forward the string pointer, so that the keyword filesize
only "sees" >100
when the signature had filesize: to_client, >100;
Rebased in #13120 |
Link to ticket: https://redmine.openinfosecfoundation.org/issues/
https://redmine.openinfosecfoundation.org/issues/7665
Describe changes:
This means adding facility to allow non-sticky buffer keywords
DetectSetupDirection
call site toSigParseOptions
instead of in each keyword and use a new flagSIGMATCH_SUPPORT_DIR
DetectSetupDirection
now takes a pointer to a string, and may move the string forward to allowfilesize: to_client, >100;
so thatDetectFilesizeSetup
gets called with ">100"SigMatchAppendSMToList
now setsonly_tc
andonly_ts
asDetectBufferSetActiveList
already does(3 commits may be better but debugging, I ended up squashing everything)
Now making transactional rules support other direction-ambiguous keywords should be one-liner like adding
SIGMATCH_SUPPORT_DIR
tosigmatch_table[DETECT_KEYWORD].flags
SV_BRANCH=OISF/suricata-verify#2453
#13045 clean