Skip to content

Commit

Permalink
Unit tests for skipping unknown filter
Browse files Browse the repository at this point in the history
New unit test for skipping unknown filter. Test cases:

 - A rule that refers to an unknown filter results in an error.
 - A rule that refers to an unknown filter, but has
   "skip-if-unknown-filter: true", can be read, but doesn't match any events.
 - A rule that refers to an unknown filter, but has
   "skip-if-unknown-filter: false", returns an error.

Also test the case of a filtercheck like evt.arg.xxx working properly
with the embedded patterns as well as proc.aname/apid which work both ways.
  • Loading branch information
mstemm committed May 2, 2018
1 parent a3f2b57 commit 3adc1cf
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/falco_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,30 @@ trace_files: !mux
- open_dev_null: 1
dev_null: 0
trace_file: trace_files/cat_write.scap

skip_unknown_noevt:
detect: False
stdout_contains: Skipping rule "Contains Unknown Event And Skipping" that contains unknown filter proc.nobody
rules_file:
- rules/skip_unknown_evt.yaml
trace_file: trace_files/cat_write.scap

skip_unknown_prefix:
detect: False
rules_file:
- rules/skip_unknown_prefix.yaml
trace_file: trace_files/cat_write.scap

skip_unknown_error:
exit_status: 1
stderr_contains: Rule "Contains Unknown Event And Not Skipping" contains unknown filter proc.nobody. Exiting.
rules_file:
- rules/skip_unknown_error.yaml
trace_file: trace_files/cat_write.scap

skip_unknown_unspec_error:
exit_status: 1
stderr_contains: Rule "Contains Unknown Event And Unspecified" contains unknown filter proc.nobody. Exiting.
rules_file:
- rules/skip_unknown_unspec.yaml
trace_file: trace_files/cat_write.scap
6 changes: 6 additions & 0 deletions test/rules/skip_unknown_error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- rule: Contains Unknown Event And Not Skipping
desc: Contains an unknown event
condition: proc.nobody=cat
output: Never
skip-if-unknown-filter: false
priority: INFO
6 changes: 6 additions & 0 deletions test/rules/skip_unknown_evt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- rule: Contains Unknown Event And Skipping
desc: Contains an unknown event
condition: evt.type=open and proc.nobody=cat
output: Never
skip-if-unknown-filter: true
priority: INFO
8 changes: 8 additions & 0 deletions test/rules/skip_unknown_prefix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- rule: Contains Prefix of Filter
desc: Testing matching filter prefixes
condition: >
evt.type=open and evt.arg.path="foo" and evt.arg[0]="foo"
and proc.aname="ls" and proc.aname[1]="ls"
and proc.apid=10 and proc.apid[1]=10
output: Never
priority: INFO
5 changes: 5 additions & 0 deletions test/rules/skip_unknown_unspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- rule: Contains Unknown Event And Unspecified
desc: Contains an unknown event
condition: proc.nobody=cat
output: Never
priority: INFO

0 comments on commit 3adc1cf

Please sign in to comment.