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 a test for missing runmode v2 #1442

Closed
wants to merge 1 commit into from

Conversation

comfort619
Copy link

@comfort619 comfort619 commented Oct 25, 2023

Ticket: 5711

Test for missing suricata capture runmode hint
Incoporated previous feedback on running test

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


## Issue Description

The issue relates to Suricata not providing adequate feedback when the runmode is missing, leading to confusion for users.
Copy link
Member

Choose a reason for hiding this comment

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

nit: please add redmine ticket link here

The issue relates to Suricata not providing adequate feedback when the runmode is missing, leading to confusion for users.



Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace





Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace





Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace


exit-code: 1
args:
- --dump-config
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed for the test, it was an example given by Juliana. The args should be just like mentioned in the redmine ticket.

Comment on lines +9 to +12
checks:
- shell:
args: suricata -S /dev/null
expect: 1
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this test. Could you please explain what were you trying to do here?
Note: This test does not seem to be testing what you've done in your Suricata PR, you should be looking for the error message in the Suricata logs/stderr. e.g. tests/detect-bsize-01/test.yaml
Hint: Recommended steps to follow:

  1. Try to understand what shell checks are doing looking at other tests.
  2. Check out the output dir created in your test after you run it. See what's inside each file.
  3. Get back to fixing the test.

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand this test. Could you please explain what were you trying to do here? Note: This test does not seem to be testing what you've done in your Suricata PR, you should be looking for the error message in the Suricata logs/stderr. e.g. tests/detect-bsize-01/test.yaml Hint: Recommended steps to follow:

  1. Try to understand what shell checks are doing looking at other tests.
  2. Check out the output dir created in your test after you run it. See what's inside each file.
  3. Get back to fixing the test.

Okay, I actually included this test to check whether Suricata behaves correctly when a specific run mode is missing. To do that, I ran Suricata with the '-S /dev/null' argument, which simulates the absence of the 'capture' run mode. I expected Suricata to return an error code (1) in this scenario, indicating that the run mode is missing.
But if I understand, I am expected to check for the presence of the expected error message in Suricata logs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for going through your thought process :)

So, as I mentioned on the previous review, you don't have to invoke shell to run suricata in Suricata-verify tests. So, whatever arguments you want to pass for this test to run suricata with, those would passed in that args section where you've putt the --dump-config option, instead.

For the expected exit code, and how to check for an error message from the output - in case you don't want to check log outputs, you can check this test: https://github.com/OISF/suricata-verify/blob/master/tests/detect-strip_whitespace-01/test.yaml#L5C1-L5C1

Not that right above the first args section, there's an exit-code: 1 line. That is how you tell suricata-verify that you expect Suri to exit with error code 1.

I hope this helps you move forward with this contribution! :)

Copy link
Author

Choose a reason for hiding this comment

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

Okay, thanks. It helps

@jufajardini jufajardini added the outreachy Contributions made by Outreachy applicants label Oct 26, 2023
@comfort619 comfort619 closed this Nov 4, 2023
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.

3 participants