]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add tests for tls.cert_chain_len
authorjason taylor <jtfas90@gmail.com>
Thu, 12 Oct 2023 13:31:12 +0000 (13:31 +0000)
committerVictor Julien <victor@inliniac.net>
Fri, 17 Nov 2023 08:33:44 +0000 (09:33 +0100)
Ticket: #6386

Signed-off-by: jason taylor <jtfas90@gmail.com>
tests/tls/tls-cert-chain-len/README.md [new file with mode: 0644]
tests/tls/tls-cert-chain-len/suricata.yaml [new file with mode: 0644]
tests/tls/tls-cert-chain-len/test.rules [new file with mode: 0644]
tests/tls/tls-cert-chain-len/test.yaml [new file with mode: 0644]

diff --git a/tests/tls/tls-cert-chain-len/README.md b/tests/tls/tls-cert-chain-len/README.md
new file mode 100644 (file)
index 0000000..d79f24a
--- /dev/null
@@ -0,0 +1,14 @@
+Test
+====
+
+Test alerts with the tls.cert_chain_len keyword
+
+PCAP
+----
+
+We are reusing/referencing the pcap file from other tls tests
+
+Related Issues
+--------------
+
+https://redmine.openinfosecfoundation.org/issues/6386
diff --git a/tests/tls/tls-cert-chain-len/suricata.yaml b/tests/tls/tls-cert-chain-len/suricata.yaml
new file mode 100644 (file)
index 0000000..0211a9f
--- /dev/null
@@ -0,0 +1,16 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: no
+            payload-buffer-size: 4kb
+            payload-printable: no
+            packet: no
+            metadata: no
+        - tls
diff --git a/tests/tls/tls-cert-chain-len/test.rules b/tests/tls/tls-cert-chain-len/test.rules
new file mode 100644 (file)
index 0000000..8956d25
--- /dev/null
@@ -0,0 +1,9 @@
+alert tls any any -> any any (msg:"cert chain exact value"; tls.cert_chain_len:3; classtype:misc-activity; sid:1; rev:1;)
+
+alert tls any any -> any any (msg:"cert chain less than value"; tls.cert_chain_len:<4; classtype:misc-activity; sid:2; rev:1;)
+
+alert tls any any -> any any (msg:"cert chain greater than value"; tls.cert_chain_len:>0; classtype:misc-activity; sid:3; rev:1;)
+
+alert tls any any -> any any (msg:"cert chain greater than less than value"; tls.cert_chain_len:0<>4; classtype:misc-activity; sid:4; rev:1;)
+
+alert tls any any -> any any (msg:"cert chain not value"; tls.cert_chain_len:!2; classtype:misc-activity; sid:5; rev:1;)
diff --git a/tests/tls/tls-cert-chain-len/test.yaml b/tests/tls/tls-cert-chain-len/test.yaml
new file mode 100644 (file)
index 0000000..393f824
--- /dev/null
@@ -0,0 +1,42 @@
+requires:
+  min-version: 7.0.0
+  features:
+    - HAVE_LIBJANSSON
+
+args:
+ - -k none
+
+pcap: ../tls-certs-alert/input.pcap
+
+checks:
+  # Check that we can alert on all three certs in the certificate chain
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        app_proto: tls
+        alert.signature_id: 1
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        app_proto: tls
+        alert.signature_id: 2
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        app_proto: tls
+        alert.signature_id: 3
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        app_proto: tls
+        alert.signature_id: 4
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        app_proto: tls
+        alert.signature_id: 5