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
[backend] new logic engine for resolving FilterGroups for event streams (#4536) #4847
Conversation
/** | ||
* Gives the right tester function according to the filter key. | ||
* If the key is not handled, returns a function that always return false. | ||
* TODO: make it dependent on the schema. |
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.
The whole code in this file could be replaced by a more generic approach:
- update the schema to add the stix paths, value type and multiplicity
- extract the data thanks to the schema, according to the attribute key
And we would remove this ugly part of the code.
Now, it's far easier to say than done, so this version is MVP : it is based on the current filters available in the UI and handle each case specifically. We expect no regression.
In a next version we could work on this complex task involving schema.
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.
for the record, I think it could be like the stix converter
or the representative
inside an entity in the schema.
A field stixFilter
in AttributeDefinition
for the the individual tester logic ?
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.
We'll tackle this later, once a first working version is out. That's the priority.
opencti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-test.ts
Show resolved
Hide resolved
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #4847 +/- ##
===========================================
+ Coverage 0 87.27% +87.27%
===========================================
Files 0 3 +3
Lines 0 220 +220
Branches 0 55 +55
===========================================
+ Hits 0 192 +192
- Misses 0 28 +28 ☔ View full report in Codecov by Sentry. |
opencti-platform/opencti-graphql/src/utils/stix-filtering/stix-filtering.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-test.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-test.ts
Outdated
Show resolved
Hide resolved
...cti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-testers-test.ts
Outdated
Show resolved
Hide resolved
...cti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-testers-test.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/stix-testers.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/stix-testers.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/boolean-logic-engine.ts
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/stix-testers.ts
Outdated
Show resolved
Hide resolved
opencti-platform/opencti-graphql/src/utils/stix-filtering/stix-testers.ts
Outdated
Show resolved
Hide resolved
all comments addressed in last commit. |
...cti-platform/opencti-graphql/tests/02-integration/01-database/stix-filtering-testers-test.ts
Show resolved
Hide resolved
52e3edd
to
e13ede5
Compare
Last commits address most of the changes requested by @richard-julien after our pair review.
The following changes will be done AFTER merge with Cathia's feature branch
|
* use trim in string comparison * parse numbers as float * validate filters (throw on multiple keys or unhandled keys)
9923e07
to
9e92d70
Compare
Proposed changes
This code is completely independent and is only used by unit tests for now.
It implements our new filtering logic with nested, recursive Filter groups, in the case of stream events.
It's closely related to @Archidoit's work and will require some integration, so things might change on the edges.
I strongly suggest to read the code in parallel with unit tests, and to start "from the bottom"
Related issues
Checklist
Further comments
This implementation separates the responsibilities properly:
New boolean logic engine
A set of individual testers functions, one for each filter key currently possible
final function
isStixMatchFilterGroups
isStixMatchFilter
, the one used for streams, triggers and playbooks when we want to check a filter against a stix object