]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add tests for exception policy master switch 1286/head
authorJuliana Fajardini <jufajardini@oisf.net>
Thu, 1 Dec 2022 15:10:10 +0000 (12:10 -0300)
committerVictor Julien <victor@inliniac.net>
Wed, 5 Jul 2023 04:41:23 +0000 (06:41 +0200)
Add tests for the new master switch config for the Exception policies.
Added also a check in the exception-policy test that checks the default
behavior, to ensure that things work as expected with the master switch
disabled and the exception policies not set.

Task #5219

38 files changed:
tests/bug-6149-exception-policy-auto-ids/test.yaml
tests/bug-6149-exception-policy-auto-ips/test.yaml
tests/exception-policy-default-01/suricata.yaml
tests/exception-policy-master-switch/exception-policy-master-switch-01/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-01/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-01/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-01/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-01/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-02/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-02/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-02/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-02/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-02/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-03/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-03/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-03/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-03/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-03/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-04/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-04/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-04/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-04/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-04/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-05/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-05/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-05/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-05/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-05/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-06/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-06/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-06/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-06/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-06/test.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-07/README.md [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-07/input.pcap [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-07/suricata.yaml [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-07/test.rules [new file with mode: 0644]
tests/exception-policy-master-switch/exception-policy-master-switch-07/test.yaml [new file with mode: 0644]

index 4f52c44f93a20abd605a6574e8309ca01c88ee68..77f2756b21f1af2d078c5a3a1f5563a78833c182 100644 (file)
@@ -30,4 +30,4 @@ checks:
         log_level: Info
         event_type: engine
         engine.module: exception-policy
-        engine.message: "master exception-policy set to: ignore"
+        engine.message: "master exception-policy set to: auto"
index 587a8b8b239d2c177f362ee0337d9e7aca6b24f6..b35b50d2daf3dcc9ba813aea5e772625d85aff72 100644 (file)
@@ -29,4 +29,4 @@ checks:
         log_level: Info
         event_type: engine
         engine.module: exception-policy
-        engine.message: "master exception-policy set to: drop-flow"
+        engine.message: "master exception-policy set to: auto"
index b1a0e258cabe4a457ce14be462f7ac1f47af38c5..a22e556bf1ac6a0d7bea45502680dad7a9d6b3b5 100644 (file)
@@ -18,3 +18,5 @@ action-order:
   - drop
   - reject
   - alert
+
+exception-policy: ignore
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-01/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-01/README.md
new file mode 100644 (file)
index 0000000..48a0ee0
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check the expected auto behavior, for the master switch for drop-packet and
+drop-flow in case of traffic exceptions, in IPS mode.
+
+# Behavior
+
+We expect to have no alerts, and see drop events, includding for the flow. Checks
+for the bypassed flow are left to highlight the fact that the indicated exception
+policy is overwritten by the master switch.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-01/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-01/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-01/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-01/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-01/suricata.yaml
new file mode 100644 (file)
index 0000000..510b047
--- /dev/null
@@ -0,0 +1,29 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-01/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-01/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-01/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-01/test.yaml
new file mode 100644 (file)
index 0000000..1d4f2b8
--- /dev/null
@@ -0,0 +1,35 @@
+requires:
+  min-version: 7
+
+args:
+- --simulate-ips
+- --set exception-policy=auto
+
+checks:
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+  - filter:
+      count: 1
+      match:
+        event_type: drop
+        drop.reason: stream midstream
+  - filter:
+      count: 9
+      match:
+        event_type: drop
+  - filter:
+      count: 0
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      count: 1
+      match:
+        event_type: flow
+        flow.action: drop
+  - filter:
+      count: 0
+      match:
+        event_type: http
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-02/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-02/README.md
new file mode 100644 (file)
index 0000000..290c37b
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check the bypass behavior for the Exception policies master switch in IPS
+mode in case of traffic exceptions.
+
+# Behavior
+
+We expect to have no alerts, nor drop events, only the flow in bypassed state.
+Checks are left to highlight the expected behavior in comparison to other
+possible behaviors, with different policies in place.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-02/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-02/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-02/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-02/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-02/suricata.yaml
new file mode 100644 (file)
index 0000000..e9d7d7d
--- /dev/null
@@ -0,0 +1,30 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+exception-policy: bypass
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-02/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-02/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-02/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-02/test.yaml
new file mode 100644 (file)
index 0000000..dd2a2d5
--- /dev/null
@@ -0,0 +1,25 @@
+requires:
+  min-version: 7
+
+args:
+- --simulate-ips
+- --set stream.midstream=true
+
+checks:
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+  - filter:
+      count: 0
+      match:
+        event_type: drop
+  - filter:
+      count: 1
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      count: 0
+      match:
+        event_type: http
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-03/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-03/README.md
new file mode 100644 (file)
index 0000000..2a46cee
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check that the proper default exception policy is applied in case the master
+switch is disabled and there is no exception policy configured.
+stage.
+
+# Behavior
+
+We expect to have ``alert`` and ``http`` events logged, as the flow will
+be inspected still.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-03/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-03/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-03/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-03/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-03/suricata.yaml
new file mode 100644 (file)
index 0000000..b0edf36
--- /dev/null
@@ -0,0 +1,31 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+exception-policy: ignore
+
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-03/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-03/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-03/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-03/test.yaml
new file mode 100644 (file)
index 0000000..efcc374
--- /dev/null
@@ -0,0 +1,25 @@
+requires:
+  min-version: 7
+
+args:
+- --simulate-ips
+- --set stream.midstream=true
+
+checks:
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+  - filter:
+      count: 0
+      match:
+        event_type: drop
+  - filter:
+      count: 0
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      count: 1
+      match:
+        event_type: http
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-04/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-04/README.md
new file mode 100644 (file)
index 0000000..a7e9908
--- /dev/null
@@ -0,0 +1,14 @@
+# Test
+
+Check the expected overriding behavior, in IPS mode, if an Exception Policy is
+set, regardless of what is defined in the master switch.
+
+# Behavior
+
+We expect to see a flow event with the action set to pass, and the http
+protocol event, since a pass policy will still mean inspection, just no detection.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-04/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-04/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-04/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-04/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-04/suricata.yaml
new file mode 100644 (file)
index 0000000..1f38982
--- /dev/null
@@ -0,0 +1,31 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+exception-policy: auto
+
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-04/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-04/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-04/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-04/test.yaml
new file mode 100644 (file)
index 0000000..ef36588
--- /dev/null
@@ -0,0 +1,26 @@
+requires:
+  min-version: 7
+
+args:
+- --simulate-ips
+- --set stream.midstream=true
+- --set stream.midstream-policy=pass-flow
+
+checks:
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+  - filter:
+      count: 0
+      match:
+        event_type: drop
+  - filter:
+      count: 1
+      match:
+        event_type: flow
+        flow.action: pass
+  - filter:
+      count: 1
+      match:
+        event_type: http
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-05/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-05/README.md
new file mode 100644 (file)
index 0000000..c6c06c9
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check that the Exception Policy is properly applied in case it's set to
+``bypass`` in IDS mode, when the engine firstly sees the stream during
+SYNACK stage.
+
+# Behavior
+
+We expect to have no events other than ``flow``, with an indication that it was
+bypassed.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-05/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-05/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-05/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-05/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-05/suricata.yaml
new file mode 100644 (file)
index 0000000..e9d7d7d
--- /dev/null
@@ -0,0 +1,30 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+exception-policy: bypass
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-05/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-05/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-05/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-05/test.yaml
new file mode 100644 (file)
index 0000000..54c74b3
--- /dev/null
@@ -0,0 +1,20 @@
+requires:
+  min-version: 7
+
+args:
+- --set stream.midstream=true
+
+checks:
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+  - filter:
+      count: 1
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      count: 0
+      match:
+        event_type: http
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-06/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-06/README.md
new file mode 100644 (file)
index 0000000..7df9896
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check that the Exception Policy is properly applied in case it's set to
+``auto`` in IPS mode, when the engine is set to midstream=true.
+
+# Behavior
+
+We expect the engine to define the exception policy for midstream as `ignore`,
+as that's the default configuration value when midstream flows are accepted.
+This means we should see ``alert`` and ``http`` events.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-06/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-06/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-06/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-06/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-06/suricata.yaml
new file mode 100644 (file)
index 0000000..17e07b8
--- /dev/null
@@ -0,0 +1,39 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+exception-policy: auto
+
+logging:
+  default-log-level: notice
+  outputs:
+  - file:
+      enabled: yes
+      level: debug
+      filename: suricata.json
+      type: json
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-06/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-06/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-06/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-06/test.yaml
new file mode 100644 (file)
index 0000000..e861245
--- /dev/null
@@ -0,0 +1,36 @@
+requires:
+  min-version: 7
+
+args:
+- --set stream.midstream=true
+- --simulate-ips
+
+checks:
+  - filter:
+      filename: eve.json
+      count: 1
+      match:
+        event_type: alert
+  - filter:
+      filename: eve.json
+      count: 0
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      filename: eve.json
+      count: 1
+      match:
+        event_type: http
+  - filter:
+      filename: eve.json
+      count: 0
+      match:
+        event_type: drop
+  - filter:
+      filename: suricata.json
+      count: 0
+      match:
+        event_type: engine
+        log_level: Warning
+        engine.module: exception-policy
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-07/README.md b/tests/exception-policy-master-switch/exception-policy-master-switch-07/README.md
new file mode 100644 (file)
index 0000000..6da9817
--- /dev/null
@@ -0,0 +1,15 @@
+# Test
+
+Check that the Exception Policy is properly applied with default configuration
+in IPS mode, when the engine is set to midstream=true.
+
+# Behavior
+
+We expect the engine to define the exception policy for midstream as `ignore`,
+as that's the default configuration value when midstream flows are accepted.
+This means we should see ``alert`` and ``http`` events.
+
+# Pcap
+
+Pcap is the result of a curl to www.testmyids.com, later extracted with
+Wireshark to keep the ``http`` packets only.
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-07/input.pcap b/tests/exception-policy-master-switch/exception-policy-master-switch-07/input.pcap
new file mode 100644 (file)
index 0000000..7a89ef1
Binary files /dev/null and b/tests/exception-policy-master-switch/exception-policy-master-switch-07/input.pcap differ
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-07/suricata.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-07/suricata.yaml
new file mode 100644 (file)
index 0000000..bd9e214
--- /dev/null
@@ -0,0 +1,37 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: yes
+            payload-buffer-size: 4kb
+            payload-printable: yes
+            packet: yes
+            http: yes
+            tls: yes
+            ssh: yes
+            smtp: yes
+            xff:
+              enabled: yes
+              mode: extra-data
+              deployment: reverse
+              header: X-Forwarded-For
+        - flow
+        - http
+        - drop:
+            alerts: yes
+            flows: all
+
+logging:
+  default-log-level: notice
+  outputs:
+  - file:
+      enabled: yes
+      level: debug
+      filename: suricata.json
+      type: json
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-07/test.rules b/tests/exception-policy-master-switch/exception-policy-master-switch-07/test.rules
new file mode 100644 (file)
index 0000000..9f1307b
--- /dev/null
@@ -0,0 +1 @@
+alert ip any any -> any any (msg:"GPL ATTACK_RESPONSE id check returned root"; content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:2100498; rev:7;)
diff --git a/tests/exception-policy-master-switch/exception-policy-master-switch-07/test.yaml b/tests/exception-policy-master-switch/exception-policy-master-switch-07/test.yaml
new file mode 100644 (file)
index 0000000..e861245
--- /dev/null
@@ -0,0 +1,36 @@
+requires:
+  min-version: 7
+
+args:
+- --set stream.midstream=true
+- --simulate-ips
+
+checks:
+  - filter:
+      filename: eve.json
+      count: 1
+      match:
+        event_type: alert
+  - filter:
+      filename: eve.json
+      count: 0
+      match:
+        event_type: flow
+        flow.state: bypassed
+  - filter:
+      filename: eve.json
+      count: 1
+      match:
+        event_type: http
+  - filter:
+      filename: eve.json
+      count: 0
+      match:
+        event_type: drop
+  - filter:
+      filename: suricata.json
+      count: 0
+      match:
+        event_type: engine
+        log_level: Warning
+        engine.module: exception-policy