-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
detect-flowbits: adding details for flowbits v2 #9685
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
#include "util-time.h" | ||
#include "util-validate.h" | ||
#include "util-conf.h" | ||
#include "detect-flowbits.h" | ||
|
||
static int rule_warnings_only = 0; | ||
|
||
|
@@ -861,6 +862,38 @@ static void DumpMatches(RuleAnalyzer *ctx, JsonBuilder *js, const SigMatchData * | |
jb_close(js); | ||
break; | ||
} | ||
case DETECT_FLOWBITS: { | ||
const DetectFlowbitsData *cd = (const DetectFlowbitsData *)smd->ctx; | ||
|
||
jb_open_object(js, "flowbits"); | ||
jb_set_uint(js, "idx", cd->idx); | ||
jb_set_uint(js, "or_list_size", cd->or_list_size); | ||
jb_set_uint(js, "or_list", cd->or_list); | ||
if (cd->or_list_size > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the list size is grater than 0, this means we have a list, and might need to use a |
||
jb_set_string(js, "name", cd->or_list[cd->idx]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm terribly sorry, I misguided you on how to access the variable name. I misunderstood Shivani's reply, and this led to that. Seeing the CI failures here I went and further investigated the code. For this work, I believe that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the above, I spent some time to understand the code. Aspects to consider:
So, in the cases when This info will be important to be able to properly proceed with this task, and also when improving the accompanying SV tests for them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I right to assume that if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that's not how this works. So you should not see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, so should I create an
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be simpler.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, and these would both go in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you'll have either one case or the other, the way I see this is as follows:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. understood. Thank you so much! |
||
switch (cd->cmd) { | ||
case DETECT_FLOWBITS_CMD_NOALERT: | ||
jb_set_string(js, "cmd", "noalert"); | ||
break; | ||
case DETECT_FLOWBITS_CMD_ISSET: | ||
jb_set_string(js, "cmd", "isset"); | ||
break; | ||
case DETECT_FLOWBITS_CMD_ISNOTSET: | ||
jb_set_string(js, "cmd", "isnotset"); | ||
break; | ||
case DETECT_FLOWBITS_CMD_SET: | ||
jb_set_string(js, "cmd", "set"); | ||
break; | ||
case DETECT_FLOWBITS_CMD_UNSET: | ||
jb_set_string(js, "cmd", "unset"); | ||
break; | ||
case DETECT_FLOWBITS_CMD_TOGGLE: | ||
jb_set_string(js, "cmd", "toggle"); | ||
break; | ||
} | ||
jb_close(js); | ||
break; | ||
} | ||
} | ||
jb_close(js); | ||
|
||
|
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.
I think that
or_list_size
can have some value for a rule writer, as feedback to indicate that the or flowbit rule that they created works, so we could keep that and maybe change the json key tovariables
.Following the same reasoning,
idx
andor_list
can be left out from this output.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.
Thank you for your detailed response. I'll look into this further and make the suggested changes.