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: suricata hint missing runmode v1 #1434

Closed
wants to merge 1 commit into from

Conversation

comfort619
Copy link

@comfort619 comfort619 commented Oct 21, 2023

Ticket: 5711

Test for missing suricata capture runmode hint

Suricata PR: OISF/suricata#9674
Redmine ticket: https://redmine.openinfosecfoundation.org/issues/5711

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

Good try at creating a test like this!

We must adjust it to work with how Suricata-verify expects and runs things, though ;)

@@ -0,0 +1,14 @@
# Suricata Missing Runmode Issue

This repository contains test files and documentation for addressing the "Missing runmode" issue 5711 in Suricata.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: replace repository with directory :P


checks:
- shell:
args: suricata
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we run Suricata using something closer to what is used in the issue description? Maybe at least adding -S /dev/null as args (also see the other comment for info on how to pass arguments to Suricata when running it via Suricata verify ;)

Comment on lines +9 to +14
## Test Files

- `test.yaml`: This file defines a verification test that checks for the "Missing runmode" error.
- `runmode_test`: A directory where you can place any necessary configuration files or rules for the test.


Copy link
Contributor

Choose a reason for hiding this comment

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

It's a great practice to have a README file, but these explanations are very generic, so we can keep these out. :)

Comment on lines +5 to +7
checks:
- shell:
args: suricata
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the Suricata verify suite will run Suricata, you don't have to invoke shell to run it.

Instead, the suricata-verify way would be to have a line before the checks where you would pass the args for Suricata to run with. Check for instance https://github.com/OISF/suricata-verify/blob/master/tests/config-includes-array/test.yaml#L6-L7, these means that Suricata-verify will run Suricata as
suricata --dump-config -c suricata.yaml.

The -c suricata.yaml part is added by suricata-verify, which will use a suricata.yaml file present in the added test directory, if you provide one.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, thank you for the feedback

checks:
- shell:
args: suricata
expect: 1 # Expect an exit code of 1, indicating an error
Copy link
Contributor

Choose a reason for hiding this comment

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

When you want to indicate that a test expects Suricata to exit with error code 1, you should add an exit-code: 1 line, outside the checks. See:
https://github.com/OISF/suricata-verify/blob/master/tests/detect-strip_whitespace-01/test.yaml#L5C1-L5C1

Comment on lines +9 to +10
expect-output: "ERROR: Missing runmode" # Verify that the error message is present

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have a check option like that in Surica-verify, you could have a look at https://github.com/OISF/suricata-verify/pull/1431/files to see how to check for log output error messages in SV tests :)

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