Skip to content

Commit

Permalink
fix: invalid macro names
Browse files Browse the repository at this point in the history
Signed-off-by: Gianmatteo Palmieri <[email protected]>
  • Loading branch information
mrgian authored and poiana committed Feb 29, 2024
1 parent 5ad6568 commit f0b0c12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions tests/data/rules/falco.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ var FalcoRulesWarnings = run.NewStringFileAccessor(

var InvalidAppendMacro = run.NewStringFileAccessor(
"invalid_append_macro.yaml",
`- macro: some macro
`- macro: some_macro
condition: foo
append: true
`,
Expand All @@ -355,10 +355,10 @@ var InvalidAppendMacro = run.NewStringFileAccessor(
var InvalidAppendMacroMultipleDocs = run.NewStringFileAccessor(
"invalid_append_macro_multiple_docs.yaml",
`---
- macro: some macro
- macro: some_macro
condition: evt.type=execve
---
- macro: some macro
- macro: some_macro
condition: foo
append: true
`,
Expand Down Expand Up @@ -412,7 +412,7 @@ var InvalidArrayItemNotObject = run.NewStringFileAccessor(

var InvalidBaseMacro = run.NewStringFileAccessor(
"invalid_base_macro.yaml",
`- macro: some macro
`- macro: some_macro
condition: evt.type=execve
`,
)
Expand Down Expand Up @@ -552,7 +552,7 @@ var InvalidNotYaml = run.NewStringFileAccessor(

var InvalidOverwriteMacro = run.NewStringFileAccessor(
"invalid_overwrite_macro.yaml",
`- macro: some macro
`- macro: some_macro
condition: foo
append: false
`,
Expand All @@ -561,10 +561,10 @@ var InvalidOverwriteMacro = run.NewStringFileAccessor(
var InvalidOverwriteMacroMultipleDocs = run.NewStringFileAccessor(
"invalid_overwrite_macro_multiple_docs.yaml",
`---
- macro: some macro
- macro: some_macro
condition: evt.type=execve
---
- macro: some macro
- macro: some_macro
condition: foo
append: false
`,
Expand Down
12 changes: 6 additions & 6 deletions tests/falco/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ func TestFalco_Legacy_InvalidAppendMacro(t *testing.T) {
assert.NotNil(t, res.RuleValidation().AllErrors().
OfCode("LOAD_ERR_COMPILE_CONDITION").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("unexpected token after 'execve', expecting 'or', 'and'"))
assert.NotNil(t, res.RuleValidation().AllWarnings().
OfCode("LOAD_UNUSED_MACRO").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("Macro not referred to by any other rule/macro"))
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
Expand Down Expand Up @@ -532,7 +532,7 @@ func TestFalco_Legacy_InvalidOverwriteMacroMultipleDocs(t *testing.T) {
assert.NotNil(t, res.RuleValidation().AllErrors().
OfCode("LOAD_ERR_VALIDATE").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("Undefined macro 'foo' used in filter."))
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
Expand Down Expand Up @@ -1182,7 +1182,7 @@ func TestFalco_Legacy_InvalidAppendMacroMultipleDocs(t *testing.T) {
assert.NotNil(t, res.RuleValidation().AllErrors().
OfCode("LOAD_ERR_COMPILE_CONDITION").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("unexpected token after 'execve', expecting 'or', 'and'"))
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
Expand Down Expand Up @@ -1456,12 +1456,12 @@ func TestFalco_Legacy_InvalidOverwriteMacro(t *testing.T) {
assert.NotNil(t, res.RuleValidation().AllErrors().
OfCode("LOAD_ERR_VALIDATE").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("Undefined macro 'foo' used in filter."))
assert.NotNil(t, res.RuleValidation().AllWarnings().
OfCode("LOAD_UNUSED_MACRO").
OfItemType("macro").
OfItemName("some macro").
OfItemName("some_macro").
OfMessage("Macro not referred to by any other rule/macro"))
assert.Error(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, 1, res.ExitCode())
Expand Down

0 comments on commit f0b0c12

Please sign in to comment.