-
Notifications
You must be signed in to change notification settings - Fork 910
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
Proposal/discussion: More flexible ways to enable/disable rules from configuration #3174
Comments
/assign |
Hey @LucaGuerra I really like the idea of applying commands in sequence 👍 It would solve the issues we currently have. After a quick look, I also have some ideas for possible improvements.
rules:
- disable:
rule: *
- enable:
tag: network
- enable:
rule: Directory traversal monitored file
- enable:
rule: k8s_*
- disable:
rule: Some rule wdyt? 🤔 |
Thanks for the suggestions @leogr , I do like them! Re. the removal of For the yaml, of course it will need some experimentation but if our engine can allow us to do something like rules:
- enable:
tag: network
rule: something else could be an error or both could be applied |
I'd apply both because of the commutative property (the order does not matter when using the same command). |
cc @falcosecurity/falco-maintainers for visibility Tentatively for |
Hi @LucaGuerra thanks for getting a PR going. Similar to the existing CLI flags it is unclear to me how we handle precedence -> what is at the end enabled when there are conflicting statements? For example, I first disable one rule by name that has |
If I understood correctly, each entry under Example: (a)
and Results: all k8s rules are enabled. Counter example: (a)
and Results: All K8s rules are enabled, but "K8s specific rule" @LucaGuerra Is my interpretation correct? IMO, it's understandable and natural. Basically, each enabling/disabling step is applied in order. That's it. |
@incertum thanks for the comment. So, I agree with you that what happens needs to be clear. While reading the code I noticed that it's even hard to understand what the current options are doing. In this case, think of it like a series of "commands" that you issue after the ruleset is loaded and are evaluated in order. In your example it works exactly as you mentioned: you first disable a rule, and then enable all rules that match a specific pattern. The end result is logically that you might have re-enabled the rule that you disabled at the beginning. In the Falco Slack channel today we discussed a concrete use case with an adopter: rules:
- disable:
rule: *
- enable:
rule: Netcat Remote Code Execution in Container
- enable:
rule: Delete or rename shell history
- enable:
rule: Terminal shell in container
- enable:
rule: Launch Privileged Container first you disable everything, then you enable only what you need. Their feedback on such a potential solution was positive. |
Ok in order works. Another quick question: This config determines the final behavior when for example a rule is disabled in the rules file, but enabled here? All we need at the end is not just good docs but maybe also some informational print statements in such cases? |
Yes, basically this takes precedence. First all rules including overrides are applied and then this configuration.
Interesting idea. When would you print that? Do you think having that printed at Falco startup would be useful? Something like this at startup:
or did you have something different in mind? |
@LucaGuerra was thinking -- perhaps let's do something very simple and just print all enabled rules (in original order) when test running Falco with the --dry-run option. This would be similar to printing all interesting syscalls for the adaptive syscalls selection option. I find this very useful to double check a config before deploying. |
@incertum this makes sense to me. I think it's not really part of this feature but it'd be a welcome addition so you can easily troubleshoot what happens! |
Thank you for this! I think this is something we really need! I'm on board with the design, it seems to cover all our use cases. Just one question, should we deprecate the old command line options |
@Andreagit97 +1 re deprecating the old flags just so that we have a simpler interface going forward. The timeline you suggest is good. |
👍 for me too |
Motivation
Currently, we have several rules files and many users that wish to enable and disable rules without having to go through each rule file and changing the
enabled
field. We now have the following options:-D <substring>
Turn off any rules with names having the substring<substring>
. This option can be passed multiple times. It cannot be mixed with-t
.-T <tag>
Turn off any rules with atag=<tag>
. This option can be passed multiple times. This option can not be mixed with-t
.-t <tag>
Only enable those rules with atag=<tag>
. This option can be passed multiple times. This option can not be mixed with-T
/-D
.There are two main issues here:
falco.yaml
or from the configmapFor this reason I would like to propose another way of accessing this data. The design is up for discussion and feedback is absolutely welcome.
Feature Proposal
I thought about a design that fixes the above two points. A new key in the
falco.yaml
version calledrules
(name can be discussed but I would like to keep it short) that allows to specify a sequence of "commands" to enable and disable rules. It would accept a triplet of<command>:<object>:<name>
example (rule and tag names are made up)
At the end of this example, Falco would only consider networking tagged rules except for one
connection_to_suspicious_server
, plus all rules starting withk8s_
and theshell_in_container
rule.The same configuration could also be specified on the command line with something like:
Note that the syntax
rules[]
which allows to add an element to a sequence does not exist today and would need to be introduced.Note that while in my opinion this mechanism provides a good degree of flexibility it may not be ideal and the design could be changed a lot before implementation. Comments are very welcome!
The text was updated successfully, but these errors were encountered: