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

[FEATURE] Support selective rule overrides / merging #1340

Closed
jonny-wg2 opened this issue Aug 1, 2020 · 28 comments · Fixed by #2981
Closed

[FEATURE] Support selective rule overrides / merging #1340

jonny-wg2 opened this issue Aug 1, 2020 · 28 comments · Fixed by #2981

Comments

@jonny-wg2
Copy link

Motivation

Falco has around 60 default rules configured. However, I am only interested in say configuring 15 rules with an alert policy because of my setup. Falcosidekick is a great tool for managing the alerting of falco rules with setting a default priority on what it should fire.

At current, there are priorities of notice, informational, error (which I find a weird name), but also the priorities alert, critical and emergency. As part of the default rules, alert and emergency are not used. Weird.

My main goal is to change 15 alerts to the alert priority.

The only way to do this is copy the entire rule into my rules.local.yaml. There has to be a smarter and better way for changing this.

Feature

- rule: xyz
  append: priority
  priority: alert

Alternatives

My alternative is copying the entire rule from the default rules into my rules.local

Additional context

Others have had this problem: https://kubernetes.slack.com/archives/CMWH3EH32/p1596015898189000

@stale
Copy link

stale bot commented Oct 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Issues labeled "cncf", "roadmap" and "help wanted" will not be automatically closed. Please refer to a maintainer to get such label added if you think this should be kept open.

@stale stale bot added the wontfix label Oct 1, 2020
@stale stale bot closed this as completed Oct 10, 2020
@ossie-git
Copy link

ossie-git commented Jan 26, 2021

This issue was closed but was it every resolved? I find that some priorities need modification but I'd rather just add a line or two instead of having to copy over the entire rule to my local rules file. Thanks

@bsod90
Copy link

bsod90 commented May 22, 2023

So, copying is the only way for now?

@jasondellaluce
Copy link
Contributor

/reopen

This is still not addressed.

@poiana poiana reopened this May 23, 2023
@poiana
Copy link
Contributor

poiana commented May 23, 2023

@jasondellaluce: Reopened this issue.

In response to this:

/reopen

This is still not addressed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jonny-wg2
Copy link
Author

jonny-wg2 commented May 23, 2023 via email

@incertum
Copy link
Contributor

incertum commented Jul 5, 2023

Assigning myself and will take care of it as it is related to other similar asks I opened up PRs for.

priority is a string, therefore instead of append ability we need either (option 1) a new override: true that allows overriding just for example the priority without needing to define/re-define the entire rule or (option 2) support this feature silently, that is, if we see the same rule name and for example just the priority field is re-defined we only override that field and keep the other old fields?

Which option is the preferred one from a user experience perspective? My vote goes for option 2 and code changes needed should be minimal.

@tspearconquest
Copy link
Contributor

Option 2

@jonny-wg2
Copy link
Author

jonny-wg2 commented Jul 9, 2023 via email

@incertum
Copy link
Contributor

@jasondellaluce and I have synced and will prioritize any items related to rules loading and managements which fits in nicely with the upcoming revamp according to a new rules maturity framework. There will be a more official announcement before the Falco 0.36 release.

/milestone 0.36.0

@poiana poiana added this to the 0.36.0 milestone Jul 11, 2023
@incertum incertum removed the wontfix label Jul 11, 2023
@incertum incertum changed the title Add ability to append a new priority to an existing rule Support partial overrides / merging for existing rule (e.g. priority field) to complement the append functionality Jul 11, 2023
@incertum
Copy link
Contributor

@jonny-wg2 in addition I renamed the issue title, please let me know if the new version is ok with you. Thanks a bunch!

@incertum
Copy link
Contributor

incertum commented Jul 11, 2023

@ericjulien-okta and @tspearconquest I have closed your other 2 related issues to have one consolidated issue, hope this is ok with you, thanks!

@tspearconquest
Copy link
Contributor

tspearconquest commented Jul 11, 2023 via email

@incertum
Copy link
Contributor

incertum commented Aug 1, 2023

I have a complete PR up https://github.com/falcosecurity/falco/pull/2671/files

Falco would now allow

(1) partial overrides of any yaml keys when re-defining
(2) append to output and tags keys in append mode
(3) override for enabled and priority fields in append mode as well

The PR includes a new unit test suite and a test yaml, @tspearconquest @jonny-wg2 @ericjulien-okta, would you mind taking a look at the test conditions and letting me know if there are more edge cases I could test? And of course please confirm that those are the capabilities that would help you.

Thank you!

There are still some other fixes we need for tags related filtering and enabling that @jasondellaluce wanted to resolve.

@jonny-wg2
Copy link
Author

@incertum I don't see the following below in your test. Would just appending the priority without having to also include the condition work? E.g.

- rule: Dummy Rule 5
  append: true
  priority: CRITICAL

@incertum
Copy link
Contributor

incertum commented Aug 4, 2023

@jonny-wg2 understood, added this feature in as well, see latest commit.
Mind checking again if we cover all requested scenarios?

@jonny-wg2
Copy link
Author

Looks GTG @incertum - Thanks again for taking on this endeavour. Much appreciated!! 🤗

@incertum
Copy link
Contributor

incertum commented Aug 7, 2023

Posted in the PR #2671 (comment), we may need another round of discussion so that everyone is on board so there is a chance for these chances to be approved.

@jasondellaluce
Copy link
Contributor

@incertum I don't see the following below in your test. Would just appending the priority without having to also include the condition work? E.g.

- rule: Dummy Rule 5
  append: true
  priority: CRITICAL

@jonny-wg2 Hi! Just so that I understand better, what's your use case for this? What are you trying to accomplish by appending to a priority?

@jonny-wg2
Copy link
Author

jonny-wg2 commented Aug 8, 2023

@jasondellaluce described in my iniatial ticket perhaps is the best explanation, but I can reword it.

Out of 60 rules, I only want to receive slack notifications on 15 rules. I configured falco + falcosidekick to forward all alerts with priority alert to send to falcosidekick, and then sent to slack.

Falco provides a lot of insight into what is happening on the host that is beneficial for investigations but perhaps not the best for trigger oncall alerts.

So the aim of the game is to have a list of 15 rules that are deemed as oncall and change the priority of these alerts.

Right now, we have a custom script that will copy these rules + logic to just change the priority and really messy.

As a user, you would assume that the priority field could be easily changed as ALERT and EMERGENCY are not used by any of the default rules.

@Andreagit97
Copy link
Member

If we implement this logic #2671 we should resolve this issue 🤔

@leogr
Copy link
Member

leogr commented Sep 7, 2023

In PR #2671, multiple approaches were discussed, though a consensus on implementation was not reached. IMO, the main challenge here is the cumbersome nature of overriding or merging specific fields in Falco rules without replicating the entire rule in the local configuration.

With that in mind, and after having rethought the entire issue, below is my proposal. I'm keen to hear feedback and suggestions for improvements.

Also, since we are too late to include this in 0.36, I propose to implement this in the 0.37 dev cycle. I apologize that this took so long. The rules syntax is a complex matter, and we know well from our experience that introducing features too hastily causes more problems than benefits.

cc @falcosecurity/falco-maintainers

[PROPOSAL] Selective rule ovveride

I'd like to suggest the introduction of an override field, structured as:

override:
  [key]: [append|replace]

Where:

  • [key] targets the field we wish to override (e.g., condition, priority).
  • [append|replace] specifies the operation on the targeted field.

This feature should be supported by rule, macro, and list constructs.

Examples:

- rule: Rule 1
  condition: evt.type=openat
  
- rule: Rule 1
  condition: and evt.type=openat
  priority: CRITICAL
  override:
    condition: append
    priority: replace

The above example would append to the existing condition and replace the priority.

Backward Compatibility

To ensure backward compatibility, the existing append shortcut will remain:

- macro: xxx
  condition: yyy
  append: true

Equivalent to:

- macro: xxx
  condition: yyy
  override:
    condition: append

Using both append and override together would result in an error.

When ovveride is not specified, we will retain its current behavior (e.g., the enabled special case).

Benefits

  1. Backward Compatibility: Existing configurations remain unaffected.
  2. Extensibility: The proposal is future-proof and can be extended with new operations, e.g., prepend.

TBD

  • Decide which keys should be supported by ovveride (good examples in this comment)

@FedeDP
Copy link
Contributor

FedeDP commented Sep 7, 2023

I like the new design @leogr and i think it is also good because it allows us to retain backward compatibility; moreover, it's really fine-grained since it allows to specifcy which keys should [append,replace] the eventually existing ones from the original rule.

Also, since we are too late to include this in 0.36, I propose to implement this in the 0.37 dev cycle.

+1 also for this. Don't mess up with rules syntax 25d from a release!

@Andreagit97
Copy link
Member

Andreagit97 commented Sep 7, 2023

Let's say I am not a big fan of postponing it, but since we have not reached an agreement on the design yet and since this feature will require not only lines of code but also a great documentation effort, I'm not sure one of us has time to deliver it in time... I agree with moving it to the next release, but we should definitely implement it in the next release cycle.

I tend to agree with the proposed design because with a single block, we can replace/append all the fields we want.

Decide which keys should be supported by ovveride (good examples in #2671 (comment))

I would say all the ones that bring a value, so condition, output, tags and desc. Not sure about exceptions... first I would like to understand how this feature is related to exceptions and if in some way we can do what exceptions do with this new feature

Moreover, I would propose to deprecate the append: field since it will be replace by this feature

@incertum
Copy link
Contributor

incertum commented Sep 7, 2023

@leogr +1 re the design.

@Andreagit97 +1 re starting the deprecation of append: add a warning for Falco 0.37 and deprecate in Falco 0.38.

re exceptions I would like to discuss the faith of exceptions in general separately in the next dev cycle.

We should support all fields, however priority and enabled can really only be replaced and not appended to, else both options should be supported.

re postponing to Falco 0.37, what @Andreagit97 said about no one of us having the time right now is true. Therefore, sadly we almost have no choice other than postponing.

@Andreagit97 Andreagit97 modified the milestones: 0.36.0, 0.37.0 Sep 8, 2023
@incertum
Copy link
Contributor

incertum commented Oct 5, 2023

We brought this up again in today's core maintainer meeting.

@jasondellaluce will open the new PR according to above's agreed upon design plus new tests (possibly recovering some unit tests from the old PR, creating new tests and / or add tests to the Falco regression testing suite).

Milestone remains Falco 0.37

@LucaGuerra
Copy link
Contributor

/assign

@incertum incertum changed the title Support partial overrides / merging for existing rule (e.g. priority field) to complement the append functionality [FEATURE] Support selective rule overrides / merging Dec 22, 2023
@incertum
Copy link
Contributor

incertum commented Dec 22, 2023

Hi 👋 @jonny-wg2 @ossie-git @bsod90 @ericjulien-okta @atmosx and @tspearconquest

This feature is now available in the master build for testing. Thanks in advance for your feedback!

Happy Holidays!

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

Successfully merging a pull request may close this issue.