Skip to content

Commit

Permalink
update(tests/falco): add case for appending to unknown rule
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce authored and poiana committed Sep 1, 2023
1 parent b39c807 commit 9110022
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/data/rules/falco.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,3 +1377,19 @@ var ShadowingRules = run.NewStringFileAccessor(
priority: WARNING
`,
)

var AppendUnknownSource = run.NewStringFileAccessor(
"append_unknown_source.yaml",
`
- rule: Rule1
desc: NoDesc
condition: evt.type=open
priority: INFO
output: Never
source: mysource
- rule: Rule1
append: true
condition: or evt.type=openat
`,
)
17 changes: 17 additions & 0 deletions tests/falco/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,23 @@ func TestFalco_Legacy_NoPluginsUnknownSource(t *testing.T) {
assert.Equal(t, 0, res.ExitCode())
}

func TestFalco_Legacy_AppendUnknownSource(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
res := falco.Test(
tests.NewFalcoExecutableRunner(t),
falco.WithOutputJSON(),
falco.WithRulesValidation(rules.AppendUnknownSource),
)
assert.NotNil(t, res.RuleValidation().AllWarnings().
OfCode("LOAD_UNKNOWN_SOURCE").
OfItemType("rule").
OfItemName("Rule1").
OfMessage("Unknown source mysource, skipping"))
assert.NoError(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 0, res.ExitCode())
}

func TestFalco_Legacy_NoPluginsUnknownSourceRuleException(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
Expand Down

0 comments on commit 9110022

Please sign in to comment.