forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detection Engine] Fix importing rules with multip…
…le types of exception lists (elastic#198868) ## Summary Fixes elastic#198461 When a rule import file has both single-namespace and namespace-agnostic exception lists, there was a bug in the logic that fetched the existing exception lists after importing them. A missing set of parentheses caused a KQL query that should have read `(A OR B) AND (C OR D)` to be `(A OR B) AND C OR D`, meaning that the logic was satisfied by `D` alone instead of requiring `A` or `B` to be true along with `D`. In this case `A` and `B` are filters on `exception-list` and `exception-list-agnostic` SO attributes so that we (should) only be looking at the list container objects, i.e. `exception-list.attributes.list_type: list`. `C` and `D` are filters by `list_id`, e.g. `exception-list.attributes.list_id: (test_list_id)`. Without the extra parentheses around `C OR D`, the query finds both `list` and `item` documents for the list IDs specified in `D`. When the `findExceptionList` logic encounters a list item unexpectedly, it still tries to convert the SO into our internal representation of an exception list with `transformSavedObjectToExceptionList`. Most fields are shared between lists and items, which makes it confusing to debug. However, the `type` of items can only be `simple`, whereas lists have a variety of types. During the conversion, the `type` field of the resulting object is defaulted to `detection` if the `type` field of the SO doesn't match the allowed list type values. Since the related SDH involved importing a `rule_default` exception list instead, the list types didn't match up when the import route compared the exception list on the rule to import vs the "existing list" (which was actually a list item coerced into a list container schema with `type: detection`) and import fails.
- Loading branch information
1 parent
544525d
commit 0cc2e56
Showing
5 changed files
with
91 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters