-
Notifications
You must be signed in to change notification settings - Fork 912
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 on better exception handling #1376
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My second round of review, after the one we had all together on Slack.
Just some nits.
In the meantime, I'm trying to better figure out all the use case combinations about the "backward compatibility" topic.
Anyways, thanks a lot for this Mark!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About performance, depending on the implementation, it could make rule evaluation faster. If we stored the set of field values separate from the condition, we could match against them in parallel. However, @ldegio suggested we actually fold the exception into the condition to keep the rule parsing centralized around condition expressions, so that's what I proposed here. |
2d454a0
to
04cf7ea
Compare
Okay, I think I addressed all the feedback. Please take another look! |
Right now, the exception works in two parts:
My main concern is on the usability:
My proposal is similar to SCC in openshift, which is the 1st class object as SecurityContext. Users have full flexibility of what filters can be used as exceptions. |
So @Kaizhe 's proposal would define Exceptions like this instead (please let me know if I misinterpreted it):
The big difference is that the definition of the fields that make up an exception move into the exception object and not the rule, with the rule being unchanged. I don't think it's a really big difference but I do prefer the version in the original proposal, with exception fields embedded in the rule and exception values provided separately:
I'd like of course to see what other people think. I'm sure we can make it work one way or the other. |
@mstemm , I am thinking the exception in a different way:
|
I see—the field names and values would be combined. That would make it really hard to express lists of exceptions though, wouldn’t it? You’d have to repeat the field names over and over for each set of field values. |
You're right, or
This is like privilege grant in the role definition in k8s. |
We discussed this during the Falco community call on 9/16 and I think there was a slight preference for having the exception fields embedded in the rule. I encouraged people during the call to add their preferences to the comments here. It also sounds like there was consensus to add this to Falco, so hopefully we can merge this PR and I'll also jump in on the implementation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been going trough this with @leodido so this comment is from a shared thought:
We analyzed the proposed language addition and we understood that to make a complete exception one would need to write something like:
- rule: Write below binary dir
desc: an attempt to write to any file below a set of binary directories
condition: >
bin_dir and evt.dir = < and open_write
and not package_mgmt_procs
and not exe_running_docker_save
and not python_running_get_pip
and not python_running_ms_oms
and not user_known_write_below_binary_dir_activities
exceptions:
- proc_writer: [proc.name, fd.directory]
- container_writer: [container.image.repository, fd.directory]
- exception: Write below binary dir
items:
- proc_writer:
- [apk, /usr/lib/alpine]
- [npm, /usr/node/bin]
- container_writer:
- [docker.io/alpine, /usr/libexec/alpine]
We unrolled that and we think that if we want to make the exception a rules only construct, we'd prefer them to be 100% colocated to the rule. Something like this:
- rule: Write below binary dir
desc: an attempt to write to any file below a set of binary directories
condition: >
bin_dir and evt.dir = < and open_write
and not package_mgmt_procs
and not exe_running_docker_save
and not python_running_get_pip
and not python_running_ms_oms
and not user_known_write_below_binary_dir_activities
exceptions:
- proc.name: apk
fd.directory: /usr/lib/alpine
- proc.name: npm
fd.directory: /usr/node/bin
- container.image.repository: docker.io/alpine
fd.directory: /usr/libexec/alpine
This completely remove the need of a first class citizen exception construct which could also lead to misunderstandings while using them because one might think that they are reusable given their top level nature.
Ideas? Do you envision any pros/cons of this other approach? We kind tried to reverse engineer your thought for the syntax :)
|
||
### Implementation | ||
|
||
Each exception can be thought of as an implicit "and not (field1=val1 and field2=val2 and...)" appended to the rule's condition. In practice, that's how exceptions will be implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this detail.
Signed-off-by: Leonardo Grasso <[email protected]>
Signed-off-by: Leonardo Grasso <[email protected]>
LGTM label has been added. Git tree hash: 82f158129fc67a4116ebc1eac91a2b38d17b6078
|
Support exceptions properties on rules as described in #1376. - When parsing rules, add an empty exceptions table if not specified. - If exceptions are specified, they must contain names and lists of fields, and optionally can contain lists of comps and lists of lists of values. - If comps are not specified, = is used. - If a rule has exceptions and append:true, add values to the original rule's exception values with the matching name. - It's a warning but not an error to have exception values with a name not matching any fields. After loading all rules, build the exception condition string based on any exceptions: - If an exception has a single value for the "fields" property, values are combined into a single set to build a condition string like "field cmp (val1, val2, ...)". - Otherwise, iterate through each rule's exception values, finding the matching field names (field1, field2, ...) and comp operators (cmp1, cmp2, ...), then iterating over the list of field values (val1a, val1b, ...), (val2a, val2b, ...), building up a string of the form: and not ((field1 cmp1 val1a and field2 cmp2 val1b and ...) or (field1 cmp1 val2a and field2 cmp2 val2b and ...)... )" - If a value is not already quoted and contains a space, quote it in the string. Signed-off-by: Mark Stemm <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fntlnz, leogr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Support exceptions properties on rules as described in #1376. - When parsing rules, add an empty exceptions table if not specified. - If exceptions are specified, they must contain names and lists of fields, and optionally can contain lists of comps and lists of lists of values. - If comps are not specified, = is used. - If a rule has exceptions and append:true, add values to the original rule's exception values with the matching name. - It's a warning but not an error to have exception values with a name not matching any fields. After loading all rules, build the exception condition string based on any exceptions: - If an exception has a single value for the "fields" property, values are combined into a single set to build a condition string like "field cmp (val1, val2, ...)". - Otherwise, iterate through each rule's exception values, finding the matching field names (field1, field2, ...) and comp operators (cmp1, cmp2, ...), then iterating over the list of field values (val1a, val1b, ...), (val2a, val2b, ...), building up a string of the form: and not ((field1 cmp1 val1a and field2 cmp2 val1b and ...) or (field1 cmp1 val2a and field2 cmp2 val2b and ...)... )" - If a value is not already quoted and contains a space, quote it in the string. Signed-off-by: Mark Stemm <[email protected]>
Support exceptions properties on rules as described in #1376. - When parsing rules, add an empty exceptions table if not specified. - If exceptions are specified, they must contain names and lists of fields, and optionally can contain lists of comps and lists of lists of values. - If comps are not specified, = is used. - If a rule has exceptions and append:true, add values to the original rule's exception values with the matching name. - It's a warning but not an error to have exception values with a name not matching any fields. After loading all rules, build the exception condition string based on any exceptions: - If an exception has a single value for the "fields" property, values are combined into a single set to build a condition string like "field cmp (val1, val2, ...)". - Otherwise, iterate through each rule's exception values, finding the matching field names (field1, field2, ...) and comp operators (cmp1, cmp2, ...), then iterating over the list of field values (val1a, val1b, ...), (val2a, val2b, ...), building up a string of the form: and not ((field1 cmp1 val1a and field2 cmp2 val1b and ...) or (field1 cmp1 val2a and field2 cmp2 val2b and ...)... )" - If a value is not already quoted and contains a space, quote it in the string. Signed-off-by: Mark Stemm <[email protected]>
Support exceptions properties on rules as described in #1376. - When parsing rules, add an empty exceptions table if not specified. - If exceptions are specified, they must contain names and lists of fields, and optionally can contain lists of comps and lists of lists of values. - If comps are not specified, = is used. - If a rule has exceptions and append:true, add values to the original rule's exception values with the matching name. - It's a warning but not an error to have exception values with a name not matching any fields. After loading all rules, build the exception condition string based on any exceptions: - If an exception has a single value for the "fields" property, values are combined into a single set to build a condition string like "field cmp (val1, val2, ...)". - Otherwise, iterate through each rule's exception values, finding the matching field names (field1, field2, ...) and comp operators (cmp1, cmp2, ...), then iterating over the list of field values (val1a, val1b, ...), (val2a, val2b, ...), building up a string of the form: and not ((field1 cmp1 val1a and field2 cmp2 val1b and ...) or (field1 cmp1 val2a and field2 cmp2 val2b and ...)... )" - If a value is not already quoted and contains a space, quote it in the string. Signed-off-by: Mark Stemm <[email protected]>
This proposes adding exceptions as a first class object to falco rules
files.
It adds a new key "exceptions" to rule objects that allows a rule
writer to define tuples of field names that comprise an exception, and a
new top level object "exception" that contains lists of tuples of field
values that define exceptions to rules.
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area proposals
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: