Skip to content

Commit

Permalink
tests: showcase endswith, distance + within usage
Browse files Browse the repository at this point in the history
Suricata docs state that `endswith` cannot be mixed with `offset`,
`within` or `distance` for the same pattern, but apparently, at least
from Suricata 7 on, this seems possible.

Tests created based on material and scenarios provided by Brandon
Murphy in the Redmine ticket.

Related to
Task #5030
  • Loading branch information
jufajardini committed Sep 24, 2024
1 parent 4dcc8ff commit 5b813ce
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 0 deletions.
Binary file added tests/bug-docs-5030-01/35_bytes.pcap
Binary file not shown.
18 changes: 18 additions & 0 deletions tests/bug-docs-5030-01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test

Showcase the usage of `distance`, `within` and `endswith`, as proposed
in https://redmine.openinfosecfoundation.org/issues/5030.

## Behavior

There should be an alert. "The distance and within effectively limit how much
of a payload can be present while ensuring the packet still "endswith" the
desired content." This happens for this pcap.

## Pcap

35_bytes.pcap Shared by Brandon Murphy in the aforementioned ticket.

## Redmine ticket

https://redmine.openinfosecfoundation.org/issues/5030
1 change: 1 addition & 0 deletions tests/bug-docs-5030-01/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert tcp any any -> any any (msg:"Test"; content:"yYYYYYYYYYYYYYYYY"; distance:9; within:29; endswith; sid:1;)
9 changes: 9 additions & 0 deletions tests/bug-docs-5030-01/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
args:
- -k none

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1
Binary file added tests/bug-docs-5030-02/39_bytes.pcap
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/bug-docs-5030-02/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Test

Showcase the usage of `distance`, `within` and `endswith`, as proposed
in https://redmine.openinfosecfoundation.org/issues/5030.

## Behavior

There should be no alert. "The distance and within effectively limit how much
of a payload can be present while ensuring the packet still "endswith" the
desired content." As the content is greater than the 38 bytes limit (9+29) set
by the rule, the signature isn't fired..

## Pcap

39_bytes.pcap shared by Brandon Murphy in the aforementioned ticket.

## Redmine ticket

https://redmine.openinfosecfoundation.org/issues/5030
1 change: 1 addition & 0 deletions tests/bug-docs-5030-02/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert tcp any any -> any any (msg:"Test"; content:"yYYYYYYYYYYYYYYYY"; distance:9; within:29; endswith; sid:1;)
9 changes: 9 additions & 0 deletions tests/bug-docs-5030-02/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
args:
- -k none

checks:
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 1

0 comments on commit 5b813ce

Please sign in to comment.