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

[Security Solution][Detections] Rule Preview should process override fields and exceptions (#4680) #140221

Merged
merged 12 commits into from
Sep 13, 2022

Conversation

e40pud
Copy link
Contributor

@e40pud e40pud commented Sep 7, 2022

Summary

This PR restructures the Rule Preview functionality to allow better UX. Main changes are:

  • Rule Preview component extracted from the Define rule step into a separate Flyout component
  • override fields and exceptions are respected by rule preview
  • provide Rule Preview for pre-built rules

Screenshot 2022-09-07 at 20 46 34

Main ticket #4680

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@e40pud e40pud added release_note:enhancement Team:Detections and Resp Security Detection Response Team Feature:Detection Rule Preview Security Solution Detection Rule Preview feature Team:Detection Rule Management Security Detection Rule Management Team Team:Detection Alerts Security Detection Alerts Area Team ci:cloud-deploy Create or update a Cloud deployment labels Sep 7, 2022
@e40pud e40pud self-assigned this Sep 7, 2022
@e40pud e40pud requested review from a team as code owners September 7, 2022 18:48
@e40pud e40pud requested a review from jpdjere September 7, 2022 18:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

- Types
- Unused translations
- Unit tests
@e40pud e40pud requested a review from a team as a code owner September 9, 2022 15:07
@kibanamachine
Copy link
Contributor

merge conflict between base and head

@e40pud
Copy link
Contributor Author

e40pud commented Sep 9, 2022

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Sep 9, 2022

@elasticmachine merge upstream

@@ -68,29 +68,21 @@ TagContainer.displayName = 'TagContainer';

const StepAboutRuleComponent: FC<StepAboutRuleProps> = ({
addPadding = false,
defaultValues,
defaultValues: initialState,
Copy link
Contributor

@jpdjere jpdjere Sep 9, 2022

Choose a reason for hiding this comment

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

One confusing behaviour of this step:

I tested the overrides locally and realized that two of the possible overridable fields (Severity override and Risk score override) are "normal" settings -not hidden-, while two others (Rule name override and Timestamp override) are part of the "Advanced settings" submenu, which the user has to unfold to see.

When testing updating these overrides and refreshing the preview, I realised there is a confusing difference between these two groups of overrides. The first two are applied to the Rule Preview as soon as you update them and click on "Refresh" in the Rule Preview flyout. On the contrary, if you update the "advanced" overrides, and click on "Refresh" the previewed alerts won't be updated. You first have to click on the "Continue" button of the "About rule" step, and only then click on "Refresh". Only then will the Rule Preview be updated.

Not exactly sure why this happens since they are all part of the same form, bu I think, considering all overrides live within the same step, that they should share the same behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that is a good point. I need to add those few fields to be observed and thus the value to be used to affect Rule Preview immediately. Thanks for catching that!

</EuiText>
</>
</EuiFlexItem>
<EuiSpacer />
Copy link
Contributor

@jpdjere jpdjere Sep 9, 2022

Choose a reason for hiding this comment

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

I realize this is not part of this PR but is the "loading" text (passed as subtitle prop to HeaderSection) when creating the Histogram intended? Looks a little weird to me, especially having the loading icon already there:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is intended and was like this since a long time (at least I see the same in 7.17.5 version). Though, we can ask what design team thinks about it and whether we need to update this behaviour. @yiyangliu9286 What do you think about this one?

@e40pud
Copy link
Contributor Author

e40pud commented Sep 12, 2022

@elasticmachine merge upstream

@e40pud e40pud requested a review from jpdjere September 12, 2022 12:22
if (isRequestTriggered && rule === null) {
setRule(
formatPreviewRule({
index,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work cleaning this up 👌🏾

@michaelolo24
Copy link
Contributor

Nice work with implementing this @e40pud! There were just a couple things I noticed doing some clickthrough testing. The rule preview seems to unmount when the window is resized? The other thing I saw was the data was retained when switching between rule types? It looks like a a refresh of a query takes place, but sometimes data is still shown without an actual associated query in the rule type selection view.

Copy link
Contributor

@jpdjere jpdjere left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. 👍 from Detections rules

@e40pud e40pud changed the title [Detections] Rule Preview should process override fields and exceptions (#4680) [Security Solution][Detections] Rule Preview should process override fields and exceptions (#4680) Sep 13, 2022
@e40pud
Copy link
Contributor Author

e40pud commented Sep 13, 2022

@elasticmachine merge upstream

@e40pud e40pud requested a review from michaelolo24 September 13, 2022 10:13
@e40pud
Copy link
Contributor Author

e40pud commented Sep 13, 2022

Thanks @michaelolo24 for the feedback! I addressed your comments in code and here are couple more notes:

The rule preview seems to unmount when the window is resized?

Looks like the whole create rule page is being unmounted due to restricted space. I might need to fix that in a separate PR due to limited time before the FF. @peluja1012 what do you think?

Screen.Recording.2022-09-13.at.12.20.36.mov

The other thing I saw was the data was retained when switching between rule types? It looks like a a refresh of a query takes place, but sometimes data is still shown without an actual associated query in the rule type selection view.

We do not clear preview results until user manually refreshes them. Even when user switches between different rule types.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 3065 3066 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 6.4MB 6.4MB -16.9KB

History

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

cc @e40pud

@michaelolo24
Copy link
Contributor

michaelolo24 commented Sep 13, 2022

This issue is happening on main already so not associated with this particular PR. 👍🏾

Great, thanks for the updates and making the changes. I agree the unmounting should be handled in a separate PR. Everything looks good, only other thing I saw was that the histogram count didn't match what's actually in the table.

image

@michaelolo24
Copy link
Contributor

One thing to add with the unmounting-remounting is that when you switch the rule type the "refresh" in the rule preview might lead a user to think the query has been rerun with the new rule type, but it actually hasn't. It might be worth just completely unmounting the component if the user changes the rule? Even though I start in ML in the video below, I was originally on a threshold rule. When I got to custom query nothing changes in the panel, but it does a little reload. When I hit refresh it still shows the threshold results. The results are only updated when I close and re-open the panel

Screen.Recording.2022-09-13.at.3.04.29.PM.mov

@e40pud e40pud requested a review from peluja1012 September 13, 2022 19:15
Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

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

Thanks for the work on this @e40pud 👍🏾 ! We discussed this ticket offline and the mounting issues will be taken care of on a follow up PR.

@e40pud
Copy link
Contributor Author

e40pud commented Sep 13, 2022

Thank you @michaelolo24! @peluja1012 could you please review those issues that Micheal found while testing? We need to decide whether those could be fixed in one of the upcoming PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment Feature:Detection Rule Preview Security Solution Detection Rule Preview feature release_note:enhancement Team:Detection Alerts Security Detection Alerts Area Team Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants