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

next/sv/508/20240628/v1 #1947

Merged
merged 4 commits into from
Jul 2, 2024
Merged
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
6 changes: 6 additions & 0 deletions tests/threshold/detection_filter-rule-flow/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
alert icmp any any -> any any (itype:8; sid:1;)
alert icmp any any -> any any (itype:8; detection_filter:track by_flow, count 1, seconds 3600; sid:2;)
alert icmp any any -> any any (itype:8; detection_filter:track by_flow, count 2, seconds 3600; sid:3;)
alert icmp any any -> any any (itype:8; detection_filter:track by_flow, count 4, seconds 3600; sid:4;)
alert icmp any any -> any any (itype:8; detection_filter:track by_flow, count 7, seconds 3600; sid:5;)
alert icmp any any -> any any (itype:8; detection_filter:track by_flow, count 8, seconds 3600; sid:6;)
36 changes: 36 additions & 0 deletions tests/threshold/detection_filter-rule-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
requires:
min-version: 8

pcap: ../threshold-rule-flow/icmp.pcap

checks:
- filter:
count: 8
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 7
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 6
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 4
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: 6
6 changes: 6 additions & 0 deletions tests/threshold/detection_filter-rule-hostsrc/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
alert icmp any any -> any any (itype:8; sid:1;)
alert icmp any any -> any any (itype:8; detection_filter:track by_src, count 1, seconds 3600; sid:2;)
alert icmp any any -> any any (itype:8; detection_filter:track by_src, count 2, seconds 3600; sid:3;)
alert icmp any any -> any any (itype:8; detection_filter:track by_src, count 4, seconds 3600; sid:4;)
alert icmp any any -> any any (itype:8; detection_filter:track by_src, count 7, seconds 3600; sid:5;)
alert icmp any any -> any any (itype:8; detection_filter:track by_src, count 8, seconds 3600; sid:6;)
36 changes: 36 additions & 0 deletions tests/threshold/detection_filter-rule-hostsrc/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
requires:
min-version: 8

pcap: ../threshold-rule-flow/icmp.pcap

checks:
- filter:
count: 8
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 7
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 6
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 4
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: 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Threshold.config with by_flow

This test checks threshold.config file using by_flow tracking

The pcap file is from http-all-headers test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop tcp any any -> any any (dsize:0; sid: 1000001;)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- alert
- drop:
flows: all
alerts: true
- http
- anomaly
30 changes: 30 additions & 0 deletions tests/threshold/threshold-config-rate-filter-alert-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pcap: ../../http-all-headers/input.pcap

requires:
min-version: 8

args:
- --set threshold-file=${TEST_DIR}/threshold.config
- --simulate-ips

checks:
- filter:
count: 3
match:
event_type: alert
alert.signature_id: 1000001
alert.action: blocked
- filter:
count: 16
match:
event_type: alert
alert.signature_id: 1000001
alert.action: allowed
- filter:
count: 3
match:
event_type: drop
- filter:
count: 1
match:
event_type: http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rate_filter gen_id 1, sig_id 1000001, track by_flow, count 3, seconds 60, new_action alert, timeout 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again confused a bit, why should a drop rule be allowed to change action?
Related to #1893 (review), perhaps for later discussion, what a terminating action for packet should be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of a good use case for it, but I think the rate_filter does support it. It's coming from the Snort language, so not sure if this case was considered at the time.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Threshold.config with by_flow

This test checks threshold.config file using by_flow keyword

The pcap file is from http-all-headers test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert tcp any any -> any any (dsize:0; sid: 1000001;)
15 changes: 15 additions & 0 deletions tests/threshold/threshold-config-threshold-both-flow/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- alert
- drop:
flows: all
alerts: true
- http
- anomaly
19 changes: 19 additions & 0 deletions tests/threshold/threshold-config-threshold-both-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pcap: ../../http-all-headers/input.pcap

requires:
min-version: 8

args:
- --set threshold-file=${TEST_DIR}/threshold.config
- --simulate-ips

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1000001
- filter:
count: 1
match:
event_type: http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
threshold gen_id 1, sig_id 1000001, type both, track by_flow, count 5, seconds 60
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Threshold.config with by_flow

This test checks threshold.config file using by_flow keyword

The pcap file is from http-all-headers test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert tcp any any -> any any (dsize:0; sid: 1000001;)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- alert
- drop:
flows: all
alerts: true
- http
- anomaly
19 changes: 19 additions & 0 deletions tests/threshold/threshold-config-threshold-limit-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pcap: ../../http-all-headers/input.pcap

requires:
min-version: 8

args:
- --set threshold-file=${TEST_DIR}/threshold.config
- --simulate-ips

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1000001
- filter:
count: 1
match:
event_type: http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
threshold gen_id 1, sig_id 1000001, type limit, track by_flow, count 1, seconds 60
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Threshold.config with by_flow

This test checks threshold.config file using by_flow keyword

The pcap file is from http-all-headers test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert tcp any any -> any any (dsize:0; sid: 1000001;)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- alert
- drop:
flows: all
alerts: true
- http
- anomaly
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pcap: ../../http-all-headers/input.pcap

requires:
min-version: 8

args:
- --set threshold-file=${TEST_DIR}/threshold.config
- --simulate-ips

checks:
- filter:
count: 3
match:
event_type: alert
alert.signature_id: 1000001
- filter:
count: 1
match:
event_type: http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
threshold gen_id 1, sig_id 1000001, type threshold, track by_flow, count 5, seconds 60
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alert tcp any any -> any any (dsize:>0; sid:1;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 1, multiplier 2; sid:2;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 3, multiplier 2; sid:3;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 5, multiplier 5; sid:4;)
26 changes: 26 additions & 0 deletions tests/threshold/threshold-rule-flow-backoff-single-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
requires:
min-version: 8

pcap: ../../filestore-filecontainer-smb/filecontainer-smb.pcap

checks:
- filter:
count: 6676
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 13
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 12
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 5
match:
event_type: alert
alert.signature_id: 4
4 changes: 4 additions & 0 deletions tests/threshold/threshold-rule-flow-backoff/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alert tcp any any -> any any (dsize:>0; sid:1;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 1, multiplier 2; sid:2;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 3, multiplier 2; sid:3;)
alert tcp any any -> any any (dsize:>0; threshold:type backoff, track by_flow, count 1, multiplier 10; sid:4;)
26 changes: 26 additions & 0 deletions tests/threshold/threshold-rule-flow-backoff/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
requires:
min-version: 8

pcap: ../../bug-2482-01/proxyCONNECT_443.pcap

checks:
- filter:
count: 1725
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 707
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 338
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 257
match:
event_type: alert
alert.signature_id: 4
3 changes: 3 additions & 0 deletions tests/threshold/threshold-rule-flow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PCAP
====
PCAP from https://wiki.wireshark.org/Internet_Control_Message_Protocol
Binary file added tests/threshold/threshold-rule-flow/icmp.pcap
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/threshold/threshold-rule-flow/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alert icmp any any -> any any (itype:8; sid:1;)
alert icmp any any -> any any (itype:8; threshold:type limit, track by_flow, count 1, seconds 3600; sid:2;)
alert icmp any any -> any any (itype:8; threshold:type limit, track by_flow, count 2, seconds 3600; sid:3;)
alert icmp any any -> any any (itype:8; threshold:type both, track by_flow, count 3, seconds 3600; sid:4;)
24 changes: 24 additions & 0 deletions tests/threshold/threshold-rule-flow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
requires:
min-version: 8

checks:
- filter:
count: 8
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 2
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 4
Loading