-
Notifications
You must be signed in to change notification settings - Fork 90
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 to check for tcp_mss - v1 #1433
Conversation
Related to Issue: #6355
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.
Right path, but two adjustments needed ;)
filename: rules.json | ||
count: 1 | ||
match: | ||
# list.packet.matches[0].name: "tcp.mss" |
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 don't think this should be commented out.
count: 1 | ||
match: | ||
# list.packet.matches[0].name: "tcp.mss" | ||
list.packet.matches[0].mss.size: 536 |
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.
This check will fail with the rule you've provided ;)
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.
Actually, I have tried with other working tests, I don't necessarily have to test for name
, and the check still passes.
But for this tcp-mss.
Even testing for name
doesn't work.
That's where the issue is, I don't get the reason why it does not even recognise tcp.mss
as the name, that's why I did that.
Because normally, it will pass even without checking for name matches.
So I feel there's an issue with my code.
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 got it. It's not with the code.
The check should be for lists
, not list
;)
Also, as I pointed out, the size
check won't work with the rule you've added for this test.
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.
When such failures occur, what I do is open and compare my changes with a similar test, and carefully look for possible differences. That's what I did for this case. ;)
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 got it. It's not with the code.
The check should be forlists
, notlist
;)
Also, as I pointed out, thesize
check won't work with the rule you've added for this test.
Wiiiiiiii!
Thank you for catching that 😂.
It's really funny how the issues always be right in my face but still subtle.
But, why isn't the size
check working though? I've looked through it as well; it says Rule matches on packets
rules_analysis.txt but still fails.
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.
OK! I was tinkering around, and figured I'd have to include a test for all the options before the test could pass, which means a test for the
mode
,arg1
andarg2
.Which means, for each option, the code to log them must be present.
So I did
jb_set_uint
for each of them.And found out
mode: 1
=<
,mode: 3
=>
, andmode: 5
is used formin-max
.I'm not sure if
arg2
is used fortcp.mss
, but if it is, it is indeed better that you add a test to showcase that.
Great catch about themode
bit. As I am not familiar with this type of keyword, I wondered how the>/</
and similar was being represented, but didn't investigate further. This should definitely be present, thanks for pointing out! It also means there's more work to be done on the Suricata side of this task, as you will have to first log these fields, if you want to test the output here. I'll update my review there! :)
Yes! I have added the tests locally here.
But then, about adding the function that will relate the mode bits to their corresponding characters for setting up a proper configuration file, I would like to suggest;
lt
for Less than (< value).gt
for Greater than (> value).rg
orrange
for Range (min_value - max_value).
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.
Thanks for asking this.
Any reason not to add the full sentence? It feels to me that this makes it slightly harder to understand, in a situation where I'm not sure there's a need for concision - since this mode is only used for testing, so output size isn't so critical, I think 🤔
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.
We probably have also >=
and <=
, besides exact value too, right?
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.
We probably have also
>=
and<=
, besides exact value too, right?
Yes, there are these and even !
, but the format provided for tcp.mss
in the userguide for header keyword rules, only those three were given.
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.
Thanks for asking this.
Any reason not to add the full sentence? It feels to me that this makes it slightly harder to understand, in a situation where I'm not sure there's a need for concision - since this mode is only used for testing, so output size isn't so critical, I think 🤔
Oh yes! Actually, understanding is paramount.
I'll change it to full sentences then.
less than
greater than
range
When suricata-verify is done running, it says “FAILED”, but shows that “Rule matches on packet” in the |
Can you share the complete output for that, please? I'll double check your code and see if I can figure out what's going on. |
Which of the output? |
The one you mentioned ;) But I think at least we've figured why the test was failing. |
Test for rule type for tcp-mss keyword
Related to
Issue: #6355
Redmine ticket: https://redmine.openinfosecfoundation.org/issues/6355
Suricata PR: OISF/suricata#9673