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

Dataset set postmatch 5576 v4 #2093

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/datasets-delayed-multi-postmatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Test
====

Test datasets only sets when there is a full signature match.
Test is with a signature using different keywords matching at different stages,
and pcap having different packets making the transaction progress step by step.
And test is using a multi-buffer to test that we only save the right occurences.

https://redmine.openinfosecfoundation.org/issues/5576

PCAP
====

Pcap crafted with some http server and some python client that delays or not the writing of the headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WC1maXJzdDogc2VjcmV0
SGVhZGVyMTogZmlyc3Q=
Binary file not shown.
1 change: 1 addition & 0 deletions tests/datasets-delayed-multi-postmatch/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any ( sid: 1; http.stat_code; content: "200"; fast_pattern; http.response_header; content: "first"; dataset:set,http_match,type string,save http_match.csv; file.data; content: "later";)
15 changes: 15 additions & 0 deletions tests/datasets-delayed-multi-postmatch/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
requires:
min-version: 8

args:
- -k none --no-random --data-dir=${OUTPUT_DIR}

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1
- file-compare:
filename: http_match.csv
expected: expected/http_match.csv
14 changes: 14 additions & 0 deletions tests/datasets-delayed-postmatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Test
====

Test datasets only sets when there is a full signature match.
Test is with a signature using different keywords matching at different stages,
and pcap having different packets making the transaction progress step by step.

https://redmine.openinfosecfoundation.org/issues/5576

PCAP
====

Pcap crafted with some http server and some python client that delays or not the writing of the headers

1 change: 1 addition & 0 deletions tests/datasets-delayed-postmatch/expected/http_match.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
L3BhZ2U/cGFyYW09dmFsdWU=
Binary file added tests/datasets-delayed-postmatch/input.pcap
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/datasets-delayed-postmatch/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alert http any any -> any any ( sid: 1; http.uri; content: "param"; fast_pattern; pcre: "/param=(.*)/,flow:paramval"; http.request_header; content: "Header1";)
alert http any any -> any any ( sid: 2; http.uri; content: "param"; fast_pattern; dataset:set,http_match,type string,save http_match.csv; http.method; content: "GET"; http.request_header; content: "Header1";)
21 changes: 21 additions & 0 deletions tests/datasets-delayed-postmatch/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
requires:
min-version: 8

args:
- -k none --no-random --data-dir=${OUTPUT_DIR}

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1
#TODO ticket 7197 metadata.flowvars[0].paramval: value
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 2
- file-compare:
filename: http_match.csv
expected: expected/http_match.csv
8 changes: 8 additions & 0 deletions tests/datasets-multibuf-postmatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Description

Test datasets only sets when there is a full signature match.
Test is with multibuffer where some are matching, but not other.

# Ticket

https://redmine.openinfosecfoundation.org/issues/5576
2 changes: 2 additions & 0 deletions tests/datasets-multibuf-postmatch/expected/http_match.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WC10aXRpOiB0b3RvMg==
WC10b3RvOiB2YWx1ZTE=
Binary file added tests/datasets-multibuf-postmatch/input.pcap
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/datasets-multibuf-postmatch/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# this will match, and thus write some headers to the dataset
alert http any any -> any any (msg:"HTTP learning"; http.request_header; content:"toto"; dataset:set,http_match,type string,save http_match.csv; sid:1;)
15 changes: 15 additions & 0 deletions tests/datasets-multibuf-postmatch/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
requires:
min-version: 8

args:
- -k none --no-random --data-dir=${OUTPUT_DIR}

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1
- file-compare:
filename: http_match.csv
expected: expected/http_match.csv
7 changes: 7 additions & 0 deletions tests/datasets-validate-postmatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Description

Test datasets only sets when there is a full signature match.

# Ticket

https://redmine.openinfosecfoundation.org/issues/5576
Binary file added tests/datasets-validate-postmatch/input.pcap
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/datasets-validate-postmatch/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# this will not match, and thus not write to the dataset
alert http any any -> $HOME_NET any (msg:"HTTP learning"; flow:established,to_client; http.content_type; content:"noone"; http.server; content:"ECS"; fast_pattern; dataset:set,http_none,type string,state output/none.intel; sid:2; rev:1; priority:2;)
# this will match, and thus write to the dataset
alert http any any -> $HOME_NET any (msg:"HTTP learning"; flow:established,to_client; http.content_type; content:"ocsp"; http.server; content:"ECS"; fast_pattern; dataset:set,http_match,type string,state output/match.intel; sid:3; rev:1; priority:2;)
25 changes: 25 additions & 0 deletions tests/datasets-validate-postmatch/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
requires:
min-version: 8

args:
- -k none

checks:
# only sid 3 should trigger
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 2
# data should only be written to one dataset
- shell:
args: cat none.intel | wc -l | xargs
expect: 0
- shell:
args: cat match.intel | wc -l | xargs
expect: 1
Loading