-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[SIEM][Detections] Allow synchronous rule actions to be updated via PATCH #67914
Conversation
This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes.
Now that patchRules uses this field, we simply need to pass it.
Pinging @elastic/siem (Team:SIEM) |
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.
Checked out and verified fix locally as follows:
- Created new rule with synchronous slack action (and default action message)
- Created
./rules/patches/update_action.json
patch with updated action message - Used CLI scripts to update action:
./patch_rule.sh ./rules/patches/update_action.json
- Verified UI/API returned action with updated message
- Verified in subsequent executions that the action fired with the updated message
Many thanks for the sleuthing and detailed description in both the issue and fix @rylnd! And thanks also to Mercwri over on the community forums for finding this one, appreciate the time! 🙂
LGTM! 👍 I'd say this fix is low-impact enough to make it into 7.8, and 7.7.2 as well. As for the disparity between synch and asynch actions, let's open an issue for tracking, and continue our discussion from earlier today with the team to see what we can do to improve this area of the codebase.
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…ATCH (elastic#67914) * Update synchronous actions in patchRules This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes. * Allow synchronous actions to be patched either individually or in bulk Now that patchRules uses this field, we simply need to pass it. Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts
…ATCH (#67914) (#67990) * Update synchronous actions in patchRules This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes. * Allow synchronous actions to be patched either individually or in bulk Now that patchRules uses this field, we simply need to pass it. Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts
…ATCH (#67914) (#67988) * Update synchronous actions in patchRules This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes. * Allow synchronous actions to be patched either individually or in bulk Now that patchRules uses this field, we simply need to pass it. Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…ATCH (elastic#67914) * Update synchronous actions in patchRules This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes. * Allow synchronous actions to be patched either individually or in bulk Now that patchRules uses this field, we simply need to pass it. Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts # x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts
… via PATCH (#67914) (#68684) * [SIEM][Detections] Allow synchronous rule actions to be updated via PATCH (#67914) * Update synchronous actions in patchRules This method was typed to accept actions, but it was not doing anything with them. This was mainly a "bug by omission" so I'm simply adding unit tests for regression purposes. * Allow synchronous actions to be patched either individually or in bulk Now that patchRules uses this field, we simply need to pass it. Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts # x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts # x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts * Update tests for backport This API changed since 7.7, so we can't just backport our uses of it (e.g. the tests).
Pinging @elastic/security-solution (Team: SecuritySolution) |
Summary
Fixes #67815.
Notes
patchRules
function. Testing this at higher levels isn't currently possible due to the way that we generate rule responses: the actions that exist on the rule SO itself (i.e. synchronous actions executed during rule execution) are not part of the rule output and are masked in those situations by the separate ruleActions SO (which is used for asynchronous actions). However, we always create a separate ruleActions SO for these synchronous actions even though it is never used, which is what made this bug so confusing: everything in the UI and API tell you that the actions have been updated, which is partially true: one version of the actions has been updated, but it's not the version that's actually used.As a visualization:
rule.actions
ruleActions
ruleActions
ruleActions
This PR updates things so that both
rule.actions
andruleActions
are updated together, but it does not address the above disparity. I'm happy to create an issue to discuss removingrule.actions
or other potential solutions to the above.Checklist
For maintainers