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

Can mistakenly append to a base rule from a rule with a different source. #3382

Closed
mstemm opened this issue Oct 16, 2024 · 0 comments · Fixed by #3383
Closed

Can mistakenly append to a base rule from a rule with a different source. #3382

mstemm opened this issue Oct 16, 2024 · 0 comments · Fixed by #3383
Assignees
Labels

Comments

@mstemm
Copy link
Contributor

mstemm commented Oct 16, 2024

Describe the bug

There is a bug in rule loading where a second rule definition with a different source and append: true is mistakenly being combined with the original rule instead of reporting an error.

How to reproduce it

Put this content in a file invalid_append.yaml and try to validate it with falco using falco -V ./invalid_append.yaml. You need to enable the k8saudit plugin.

- rule: my rule
  desc: Some desc
  condition: evt.name[xxx]=true
  output: some output
  priority: INFO
  source: k8s_audit

- rule: my rule
  desc: Some desc
  condition: and proc.name=apache
  output: Some output
  priority: INFO
  source: syscall
  append: true

You get this validation error. Note that the second rule condition is appended to the first rule when it should not:

./invalid_append.yaml: Invalid
1 Errors:
In rules content: (./invalid_append.yaml:0:0)
    rule 'my rule': (./invalid_append.yaml:0:2)
    rule condition: (./invalid_append.yaml:2:13)
    condition expression: ("evt.name[xxx]=t...":3:14)
------
evt.name[xxx]=true and proc.name=apache
                                        ^
------
LOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field evt.name[xxx]

Expected behaviour

Instead, the rule loader should return the same error that you get when defining a rule again with a different source "Rule has been re-defined with a different source".

Screenshots

Environment

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant