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

tests: add rule type check for flowbits #1438

Closed

Conversation

hadiqaalamdar
Copy link
Contributor

@hadiqaalamdar hadiqaalamdar commented Oct 24, 2023

Task#6309
Related to
Issue: #6309

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/6309

Suricata PR: OISF/suricata#9685

@jufajardini jufajardini added the outreachy Contributions made by Outreachy applicants label Oct 24, 2023
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.

Thanks for submitting this PR, as I said, it's much easier to review and offer feedback.

Please see inline comments. :)

In the commit message, can you please add a space between Task and ticket number? Thanks a lot!

alert ip any any -> any any (msg:"isnotset rule need an option"; flowbits:isnotset; sid:2)
alert ip any any -> any any (msg:"set rule need an option"; flowbits:set; sid:3;)
alert ip any any -> any any (msg:"unset rule need an option"; flowbits:unset; sid:4;)
alert ip any any -> any any (msg:"toggle rule need an option"; flowbits:toggle; sid:5;)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also have a rule for the flowbits:noalert option, please :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,5 @@
alert ip any any -> any any (msg:"isset rule need an option"; flowbits:isset; sid:1;)
alert ip any any -> any any (msg:"isnotset rule need an option"; flowbits:isnotset; sid:2)
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to the lack of a name for the flowbits variable, this rule would also result in a parse error because it lacks the ; after the rule sid. Each field within the parenthesis must be followed by those. ;)

@@ -0,0 +1,5 @@
alert ip any any -> any any (msg:"isset rule need an option"; flowbits:isset; sid:1;)
Copy link
Contributor

Choose a reason for hiding this comment

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

As seen in the flowbits documentation, this keyword needs two values, so all the rules written here will result in a parse error due to the lack of the second field.

(cf https://docs.suricata.io/en/latest/rules/flow-keywords.html#flowbits)

Tip: when an SV test fails with FAILED: got exit code 1, expected 0 this indicates that Suricata finished with an error state, so to debug such cases you should check the output directory in the test folder and see what's in stderr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what to pass as the second value? I have changed the code for DETECT-FLOWBITS case so that the name is being stored in ored_variables array, should I pass this array as the second value?

Copy link
Contributor

Choose a reason for hiding this comment

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

The second value is a variable name, and as such it's not predefined. Just like a code variable, it is user-defined. Does this clear up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, okay, that makes sense. Thanks!

match:
id: 1
lists.packet.matches[0].name: "flowbits"
lists.packet.matches[0].flowbits.option: "isset"
Copy link
Contributor

Choose a reason for hiding this comment

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

The checks use flowbits.option, but the Suri code change has flowbits.cmd, which results in a check failure with SV.

@hadiqaalamdar
Copy link
Contributor Author

Work continued on: #1439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
outreachy Contributions made by Outreachy applicants
Development

Successfully merging this pull request may close these issues.

2 participants