-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution][Platform] - Exceptions export duplicates #116698
[Security Solution][Platform] - Exceptions export duplicates #116698
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
@elasticmachine merge upstream |
x-pack/plugins/security_solution/server/lib/detection_engine/scripts/check_env_variables.sh
Show resolved
Hide resolved
const listHash = createHash('sha256').update(JSON.stringify(list)).digest('hex'); | ||
if (!uniqueExceptionLists.has(listHash)) { | ||
uniqueExceptionLists.add(listHash); | ||
return !NON_EXPORTABLE_LIST_IDS.includes(list.list_id); |
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.
Why are you using a hash here and not just a unique identifier such as the list_id
? Shouldn't that be enough for this to work. If two are the same list but they are different in ordering then the hash will begin to fail on you.
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 had gone with this because I worried about possibilities of the list_id
being the same once they become shareable. Although, at that point I think something else would be wrong. I'll update to just use the id
as those should be globally unique.
…ibana into exceptions_export_duplicates
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @yctercero |
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.
Looked it over 👍 , did not test run it though.
## Summary Addresses elastic#116329 Removes duplicate exception lists on rule export when multiple rules reference the same list.
## Summary Addresses elastic#116329 Removes duplicate exception lists on rule export when multiple rules reference the same list.
## Summary Addresses #116329 Removes duplicate exception lists on rule export when multiple rules reference the same list. Co-authored-by: Yara Tercero <[email protected]>
## Summary Addresses #116329 Removes duplicate exception lists on rule export when multiple rules reference the same list. Co-authored-by: Yara Tercero <[email protected]>
Summary
Addresses #116329
Removes duplicate exception lists on rule export when multiple rules reference the same list.
Testing
Create an exception list:
cd x-pack/plugins/lists/server/scripts
./post_exception_list.sh
Add exception list items to it:
./post_x_exception_list_items.sh
Using the
id
of the exception list created above, updatex-pack/plugins/security_solution/server/lib/detection_engine/scripts/rules/queries/references/query_with_single_exception_list.json
so that it references your exception list.Create rule with exception list:
cd x-pack/plugins/security_solution/server/lib/detection_engine/scripts
./post_rule.sh ./rules/queries/references/query_with_single_exception_list.json
Update
x-pack/plugins/security_solution/server/lib/detection_engine/scripts/rules/queries/references/query_with_single_exception_list.json
so that it has a differentrule_id
andname
. and create a second rule referencing the same list../post_rule.sh ./rules/queries/references/query_with_single_exception_list.json
Export rule:
cd x-pack/plugins/security_solution/server/lib/detection_engine/scripts
./export_rules.sh
Sample Export
With duplicates
Without duplicates
Checklist