-
Notifications
You must be signed in to change notification settings - Fork 166
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
refactor(userspace/libsinsp): catch filter field-operator compatibility at compile-time instead of run-time #1857
Conversation
/milestone 0.17.0 |
e84f822
to
3993021
Compare
…ir own source file (1) Signed-off-by: Jason Dellaluce <[email protected]>
…ir own source file (2) Signed-off-by: Jason Dellaluce <[email protected]>
…d check compatibility in filter compiler Signed-off-by: Jason Dellaluce <[email protected]>
Signed-off-by: Jason Dellaluce <[email protected]>
… types Signed-off-by: Jason Dellaluce <[email protected]>
d0a8d67
to
edf3d29
Compare
Signed-off-by: Jason Dellaluce <[email protected]>
Signed-off-by: Jason Dellaluce <[email protected]>
Signed-off-by: Jason Dellaluce <[email protected]>
test_filter_compile(factory, "c.buffer bstartswith abc_1", true); | ||
} | ||
|
||
TEST(sinsp_filter_compiler, operators_field_types_compatibility) |
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.
Thank you for this! <3
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.
LGTM
LGTM label has been added. Git tree hash: c52d4694549ab29673fd85f521eedbb154abdc40
|
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, jasondellaluce, LucaGuerra 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 |
What type of PR is this?
/kind bug
/kind cleanup
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
This attempts solving an historical bug in the filtering code area of libsinsp. When using a comparison operator with a field type with which it's not compatible (e.g. doing
fd.num contains 5
, wherefd.num
is a numeric field on which thecontainer
operator can't be applied), we used to throw an exception only when the filter was evaluated at run-time. This is problematic, because if no event never reaches that specific check for evaluation (due to the boolean expression of the filter), then it becomes totally unpredictable to understand if the check is valid or now -- rather, we'd discover it from an non-deterministic unexpected exception.This PR attempts solving the problem as follows:
filter_compare.cpp
, whereas they used to inappropriately be insinsp_filtercheck.cpp
. Git blame has been preserved wherever possibleflt_is_comparable_*
functions that are invoked for compile-time checking by the sinsp filter compilerI paid extra attention in respecting the type-operator grid currently supported (whether by mistake or intentionally).
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?: