From: Victor Julien Date: Fri, 26 Feb 2021 07:15:10 +0000 (+0100) Subject: tests: add more complex tests for bug 4199 X-Git-Tag: suricata-6.0.4~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcce826be3c76f7f607599053d9746a22c23ab2e;p=thirdparty%2Fsuricata-verify.git tests: add more complex tests for bug 4199 --- diff --git a/tests/bug-4199-3/input.pcap b/tests/bug-4199-3/input.pcap new file mode 100644 index 000000000..b9eec15c8 Binary files /dev/null and b/tests/bug-4199-3/input.pcap differ diff --git a/tests/bug-4199-3/test.rules b/tests/bug-4199-3/test.rules new file mode 100644 index 000000000..c8be08639 --- /dev/null +++ b/tests/bug-4199-3/test.rules @@ -0,0 +1,2 @@ +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri;content:"exec";fast_pattern;http.request_body;content:"/etc/passwd"; nocase; sid:1;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri;content:"exec";fast_pattern;http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:2;) diff --git a/tests/bug-4199-3/test.yaml b/tests/bug-4199-3/test.yaml new file mode 100644 index 000000000..59fce2d42 --- /dev/null +++ b/tests/bug-4199-3/test.yaml @@ -0,0 +1,15 @@ +requires: + min-version: 6 + +checks: + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 1 + + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 2 diff --git a/tests/bug-4199-4/input.pcap b/tests/bug-4199-4/input.pcap new file mode 100644 index 000000000..b9eec15c8 Binary files /dev/null and b/tests/bug-4199-4/input.pcap differ diff --git a/tests/bug-4199-4/test.rules b/tests/bug-4199-4/test.rules new file mode 100644 index 000000000..7911ec5c4 --- /dev/null +++ b/tests/bug-4199-4/test.rules @@ -0,0 +1,17 @@ +# no xforms, should match +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.request_body; content:"id=cat"; nocase; sid:1;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; content:"id=cat"; nocase; sid:2;) + +# no xforms, should not match +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.request_body; content:"/etc/passwd"; nocase; sid:11;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; content:"/etc/passwd"; nocase; sid:12;) + +# xforms should match +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:3;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; fast_pattern; http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:4;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; url_decode; content:"/etc/passwd"; nocase; fast_pattern; sid:5;) + +# xforms should not match +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.request_body; url_decode; content:"/passwd/etc"; nocase; sid:13;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; fast_pattern; http.request_body; url_decode; content:"/passwd/etc"; nocase; sid:14;) +alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; url_decode; content:"/passwd/etc"; nocase; fast_pattern; sid:15;) diff --git a/tests/bug-4199-4/test.yaml b/tests/bug-4199-4/test.yaml new file mode 100644 index 000000000..4099e9bac --- /dev/null +++ b/tests/bug-4199-4/test.yaml @@ -0,0 +1,54 @@ +requires: + min-version: 6 + +checks: + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 1 + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 2 + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 3 + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 4 + - filter: + count: 1 + match: + event_type: alert + alert.signature_id: 5 + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 11 + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 12 + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 13 + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 14 + - filter: + count: 0 + match: + event_type: alert + alert.signature_id: 15