Skip to content
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 v5 #9971

Closed

Conversation

hadiqaalamdar
Copy link
Contributor

@hadiqaalamdar hadiqaalamdar commented Dec 5, 2023

Task #6309

Link to redmine ticket: https://redmine.openinfosecfoundation.org/issues/6309
Previous PR: #9691

Describe changes:

  • added the recommended changes from the last PR.

SV_BRANCH=OISF/suricata-verify#1512

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Merging #9971 (91fbf2a) into master (2fe2d82) will increase coverage by 0.04%.
Report is 154 commits behind head on master.
The diff coverage is 51.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9971      +/-   ##
==========================================
+ Coverage   82.39%   82.43%   +0.04%     
==========================================
  Files         968      970       +2     
  Lines      274337   271392    -2945     
==========================================
- Hits       226047   223734    -2313     
+ Misses      48290    47658     -632     
Flag Coverage Δ
fuzzcorpus 64.51% <0.00%> (-0.19%) ⬇️
suricata-verify 61.31% <51.51%> (+0.39%) ⬆️
unittests 62.87% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@jufajardini
Copy link
Contributor

Updated PR description to make redmine ticket link visible and use SV_BRANCH= style, so CI checks can pick up the SV PR

switch (cd->cmd) {
case DETECT_FLOWBITS_CMD_NOALERT:
jb_set_string(js, "action", "noalert");
// jb_set_string(js,"name", NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented our line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, don't know how I missed that. I'll remove it right away.

Copy link
Contributor

@jufajardini jufajardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting there, I see that most SV checks are passing, now, kudos!

I've left some comments for the work to continue :)

Also please note that the commit message is still not following our guidelines.
Something like detect/analyzer: add details to flowbits keyword for the commit title would work. The ticket indication is good!

switch (cd->cmd) {
case DETECT_FLOWBITS_CMD_NOALERT:
jb_set_string(js, "action", "noalert");
// jb_set_string(js,"name", NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover? :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I must have missed the commented out code. Sorry!

Comment on lines +891 to +901
jb_open_array(js, "names");
if (cd->or_list_size == 0) {
jb_append_string(js, VarNameStoreSetupLookup(cd->idx, VAR_TYPE_FLOW_BIT));
} else if (cd->or_list_size > 0) {
for (uint8_t i = 0; i < cd->or_list_size; i++) {
const char *varname =
VarNameStoreSetupLookup(cd->or_list[i], VAR_TYPE_FLOW_BIT);
jb_append_string(js, varname);
}
}
jb_close(js); // array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that for noalert there won't be an associated variable name, I don't think we want to always open this array, only when it's not noalert, I guess. Not sure what's the best approach in terms of implementation, for this, right now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(btw, my guess is that that's what's causing the last check in the SV test to fail. this double close when nothing was added to the json object is leading to suricata not having the json object with the flowbits info, in the noalert case.)

}
}
jb_close(js); // array
jb_close(js); // object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the discussion here - #9691 (comment) -, we are missing the operator to be added to the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, I was thinking about creating an operator array that stores "or" if it encounters '|' in the the list, but I'm not sure on how to store "and" yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say skip and for now, multiple flowbit objs in the output for a rule for the same cmd and w/o or would indicate and. It'll quickly get too complicated otherwise.

@hadiqaalamdar
Copy link
Contributor Author

hadiqaalamdar commented Dec 7, 2023

New PR: #10008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants