Skip to content
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][Detection Engine] Allow to edit actions for prepackaged rules #61312

Conversation

patrykkopycinski
Copy link
Contributor

@patrykkopycinski patrykkopycinski commented Mar 25, 2020

Summary

  • allow to edit actions for prepacked rules
  • don't override actions when updating prepacked rules

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@patrykkopycinski patrykkopycinski requested review from XavierM and FrankHassanabad and removed request for XavierM March 25, 2020 19:29
@patrykkopycinski patrykkopycinski self-assigned this Mar 25, 2020
@patrykkopycinski patrykkopycinski added release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.7.0 v8.0.0 labels Mar 25, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

@patrykkopycinski patrykkopycinski marked this pull request as ready for review March 25, 2020 19:29
@patrykkopycinski patrykkopycinski requested a review from a team as a code owner March 25, 2020 19:29
@patrykkopycinski patrykkopycinski requested a review from tsg March 26, 2020 09:18
@tsg
Copy link
Contributor

tsg commented Mar 26, 2020

Thank you, @patrykkopycinski, for finding a quick solution. I think I like this for 7.7 at least, but we should discuss the following two points:

  • are we comfortable with mixing immutable and mutable data into the same saved object? Does this have the potential to cause issues with other features like import/export?

  • is the UI experience acceptable? We are showing the Edit button for immutable rules, but then the only active tab is Alerts.

CC @FrankHassanabad @spong @MikePaquette @XavierM @marrasherrier for the discussion.

@MikePaquette
Copy link

@tsg @patrykkopycinski @FrankHassanabad @spong @XavierM

Amazing, this has the potential to save users hours of time whenever we update our prebuilt rules.

are we comfortable with mixing immutable and mutable data into the same saved object? Does this have the potential to cause issues with other features like import/export?

We also need to consider the common case of prebuilt rules being "updated" (e.g., each time we release updated rules). The expected experience is that the alerting settings (and in the future, allowlist settings) would be preserved independently, even though the rule contents (immutable parts) may change during updates.

is the UI experience acceptable? We are showing the Edit button for immutable rules, but then the only active tab is Alerts.

I'd say yes. @marrasherrier and I spoke about this yesterday with @lindseypoli, and while we may come up with a better experience in the future, this seems quite acceptable. In fact, we thought ahead to when we add support for rule exceptions, and this approach would be easily extensible to that. (i.e., if the user edits a pre-built rule, the only active tabs would be "Alerts" and "Exceptions.")

@patrykkopycinski
Copy link
Contributor Author

  • are we comfortable with mixing immutable and mutable data into the same saved object? Does this have the potential to cause issues with other features like import/export?

@tsg @MikePaquette we don't allow to export, so to import prepackaged rules. With my changes, we will not override actions for prepackaged rules during the update

@tsg
Copy link
Contributor

tsg commented Mar 26, 2020

We also need to consider the common case of prebuilt rules being "updated" (e.g., each time we release updated rules). The expected experience is that the alerting settings (and in the future, allowlist settings) would be preserved independently, even though the rule contents (immutable parts) may change during updates.

That should work with the current PR, if I understand it correctly. I'm just worried if this (technical) design is perhaps too brittle for the future. But we can always improve it as needed.

@XavierM
Copy link
Contributor

XavierM commented Mar 26, 2020

Maybe, we should create rules_actions saved object, therefore we do not save action with the rules saved objects so it is independent of the rules and we can keep the immutable logic in rules for pre-packaged rules.
Also updating pre-packaged rules my overwrite the actions if it is set up in prepackaged rules.

@patrykkopycinski patrykkopycinski requested a review from a team as a code owner March 29, 2020 17:57
@patrykkopycinski
Copy link
Contributor Author

@elasticmachine merge upstream

elasticmachine and others added 4 commits March 30, 2020 15:33
 Conflicts:
	x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts
 Conflicts:
	x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/create/helpers.ts
	x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts
We missed adding throttle in one spot, here.
Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran things locally, two notes:

  1. Adding actions doesn't affect a prepackaged rule's version, so 👍 there
  2. When adding an action to a prepackaged rule, the rule was automatically enabled. This was unexpected to me so I'm thinking it might be a bug?

I just fixed the one test failure, so hopefully this'll be green in a little bit here. I'm babysitting some other stuff so I'll keep an eye on this one as well.

export const isRuleActionsSavedObjectType = (
obj: unknown
): obj is SavedObject<IRuleActionsAttributesSavedObjectAttributes> => {
return get('attributes', obj) != null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't every saved object have an attributes property? Ditto for the check of saved_objects below. If these are not guaranteed to find only the type in question, then these are functionally equivalent to just saying as [Type], and have all the same downsides.

…trykkopycinski/kibana into feat/siem-prepackedrules-actions-edit
…packedrules-actions-edit

# Conflicts:
#	x-pack/legacy/plugins/siem/server/plugin.ts
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:SIEM v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants