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] Add threshold, machine_learning_job_id and anomaly_threshold editable fields #200323

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

nikitaindik
Copy link
Contributor

@nikitaindik nikitaindik commented Nov 16, 2024

Partially addresses: #171520

Summary

Changes in this PR:

  • threshold and machine_learning_job_id, anomaly_threshold are now editable in the Rule Upgrade flyout
Scherm­afbeelding 2024-11-26 om 08 59 24

Testing

  • Ensure the prebuiltRulesCustomizationEnabled feature flag is enabled.
  • To simulate the availability of prebuilt rule upgrades, downgrade a currently installed prebuilt rule using the PATCH api/detection_engine/rules API.
    • Set version: 1 in the request body to downgrade it to version 1.
    • Modify other rule fields in the request body as needed to test the changes.

@nikitaindik nikitaindik added release_note:skip Skip the PR/issue when compiling release notes v9.0.0 Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team backport:version Backport to applied version labels v8.17.0 labels Nov 16, 2024
@nikitaindik nikitaindik self-assigned this Nov 16, 2024
@nikitaindik nikitaindik force-pushed the machine-learning-fields branch from c195e14 to ff1858e Compare November 17, 2024 18:08
@banderror banderror added v8.18.0 and removed v8.17.0 labels Nov 21, 2024
@nikitaindik nikitaindik force-pushed the machine-learning-fields branch from ff1858e to d13fb76 Compare November 26, 2024 07:22
@nikitaindik nikitaindik marked this pull request as ready for review November 26, 2024 07:58
@nikitaindik nikitaindik requested review from a team as code owners November 26, 2024 07:58
@nikitaindik nikitaindik requested a review from rylnd November 26, 2024 07:58
@elasticmachine
Copy link
Contributor

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

@nikitaindik nikitaindik requested a review from maximpn November 26, 2024 07:58
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@nikitaindik nikitaindik force-pushed the machine-learning-fields branch from f198cad to b6a9d92 Compare November 26, 2024 09:01
@nikitaindik nikitaindik requested a review from xcrzx November 26, 2024 09:02
@banderror banderror added the Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area label Nov 26, 2024
@nikitaindik
Copy link
Contributor Author

@xcrzx I've addressed the feedback. Feel free to take another look!

@nikitaindik nikitaindik requested a review from xcrzx December 3, 2024 14:31
Copy link
Contributor

@xcrzx xcrzx 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 fixes! I did another round of review, and the validation regression spotted earlier has been resolved.

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.

Excellent work here, @nikitaindik !

I first verified that the existing create/update rule flows work as expected, since those were modified here as well. Things look good there, besides a potential bug with threshold fields (showing more fields than we should); I'm going to ping @vitaliidm since he has more familiarity with threshold rules and that area was more significantly modified. ML rules changes look good, though.

There might be some cleanup around the forms here, now; I had one comment about whether empty schema definitions were required. Have you discussed this style of refactor with @sebelga at all? He may have thoughts on how best to factor/place things as we shift more toward this "field-first" approach to our forms.

I was also able to validate that the missing validations that @xcrzx referenced are now there, at least for the ML fields that I was exercising.

One small UX note: on the upgrade page it's not obvious that clicking the rule's name will bring up the "review" flow; I was expecting there to be a "review" button instead of (or in addition to) the disabled "upgrade rule" button.

All minor things in the broader context, here, so approving in the meantime. Hopefully @vitaliidm can confirm the threshold changes before this is merged.

@container (min-width: ${CONTAINER_BREAKPOINT}px) {
flex: 1;
max-width: calc(
100% - ${OPERATOR_WIDTH}px - ${INPUT_WIDTH}px - ${euiThemeVars.euiSizeL} -
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious if

 - ${euiThemeVars.euiSizeL} - ${euiThemeVars.euiSizeL} 

is preferred over

 - (${euiThemeVars.euiSizeL} * 2)

? And if so, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

euiThemeVars.euiSizeL is actually a string with px at the end. 24px in this case, so I can't multiply it.

import * as i18n from './translations';

const buttonClassName = css`
margin-top: 20px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number? Should we be referencing a theme variable instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need 20px here to make the button flush with the dropdown. euiSizeM is 16px, euiSizeL is 24px.

Scherm­afbeelding 2024-12-04 om 13 17 55

But now as you pointed this out, I think the margin should live outside of this component since it's related to an external thing.

)}
{isThresholdRule && (
<EuiFormRow data-test-subj="thresholdInput" fullWidth>
<ThresholdEdit esFields={indexPattern.fields as FieldSpec[]} path="threshold" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Using indexPattern.fields instead of the filtered aggFields means we're now showing non-aggregatable fields in the threshold field select, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great catch, Ryland! I somehow missed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed the fix

@rylnd rylnd requested a review from vitaliidm December 3, 2024 23:39
@nikitaindik
Copy link
Contributor Author

@rylnd

One small UX note: on the upgrade page it's not obvious that clicking the rule's name will bring up the "review" flow; I was expecting there to be a "review" button instead of (or in addition to) the disabled "upgrade rule" button.

Will add to this to feedback to share this with Kseniia and Alex.

@vitaliidm
Copy link
Contributor

@rylnd

Things look good there, besides a potential bug with threshold fields (showing more fields than we should); I'm going to ping @vitaliidm since he has more familiarity with threshold rules and that area was more significantly modified

can you give me more details on this one?

Meanwhile I tested PR a bit (did not review code, since Ryland already did this)

  1. UI has changed. Width of threshold elements in particularly. Number inputs become very narrow, even on a wide screen.
    Was this changed approved? Or side effect of refactoring?

old UI

Screenshot 2024-12-04 at 14 20 24

new UI

Screenshot 2024-12-04 at 14 20 45
  1. As side effect of UI change, error message looks very crumbled and >= is not aligned in a middle of input components anymore. but gets dragged lower

new UI

Screenshot 2024-12-04 at 14 24 22

old UI

Screenshot 2024-12-04 at 14 27 21

@vitaliidm vitaliidm requested review from vitaliidm and removed request for vitaliidm December 4, 2024 14:32
@banderror banderror marked this pull request as draft December 4, 2024 16:22
@nikitaindik
Copy link
Contributor Author

Hey, everyone! Thanks for reviewing and testing. There's still a minor issue with form element sizing that need to be addressed, but I urgently need to switch to high-priority Rule Customization tickets. So, I've set this PR to draft. I will reopen it and ping those who haven't approved it yet once I resolve the issues.

@rylnd
Copy link
Contributor

rylnd commented Dec 5, 2024

can you give me more details on this one?

@vitaliidm I was referring to this comment about passing a wider set of fields to the threshold input. @nikitaindik said a fix was incoming but I've not yet seen it on this branch.

@vitaliidm
Copy link
Contributor

@vitaliidm I was referring to this comment about passing a wider set of fields to the threshold input. @nikitaindik said a fix was incoming but I've not yet seen it on this branch.

Agree, fields should be filtered, only aggregatable ones should show up in threshold control

@nikitaindik , I also noticed, Suppress alerts checkbox label does not show selected field.
Refer to my screenshots #200323 (comment)

@nikitaindik
Copy link
Contributor Author

@vitaliidm

UI has changed. Width of threshold elements in particularly. Number inputs become very narrow, even on a wide screen.

Thanks for catching this! Actually, the width of the number inputs is similar to what’s on main at 1280px. I’ve attached a screenshot for reference: the left side shows this branch, and the right side shows main. I think that it’s helpful to give more space to field names since they can be quite long, whereas number values are usually short. What do you think about this approach?

Scherm­afbeelding 2024-12-16 om 15 41 37

As side effect of UI change, error message looks very crumbled and >= is not aligned in a middle of input components anymore. but gets dragged lower

Great observation, thanks for pointing this out! I’ve adjusted the margin to ensure that the >= operator stays properly aligned, even when more fields are added or an error message appears.

I also noticed, Suppress alerts checkbox label does not show selected field.
Refer to my screenshots #200323 (comment)

Indeed, there was a bug. Thanks! I've pushed a commit with the fix.

With all your feedback addressed, the PR is ready for another review. 😊

@nikitaindik nikitaindik marked this pull request as ready for review December 16, 2024 14:55
@elasticmachine
Copy link
Contributor

elasticmachine commented Dec 16, 2024

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #6 / AgentBasedPackagePoliciesTable renders the table with package policies
  • [job] [logs] Serverless AI Assistant - Security Solution Cypress Tests / AI Assistant Conversations Changing conversations Correctly creates and titles new conversations, and allows title updates Correctly creates and titles new conversations, and allows title updates
  • [job] [logs] AI Assistant - Security Solution Cypress Tests / AI Assistant Conversations Changing conversations Correctly creates and titles new conversations, and allows title updates Correctly creates and titles new conversations, and allows title updates
  • [job] [logs] FTR Configs #113 / Upgrade Assistant Elasticsearch deprecation logs GET /api/upgrade_assistant/deprecation_logging /count should filter out the deprecation from Elastic products
  • [job] [logs] FTR Configs #113 / Upgrade Assistant Elasticsearch deprecation logs GET /api/upgrade_assistant/deprecation_logging /count should filter out the deprecation from Elastic products

History

cc @nikitaindik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:cloud-deploy Create or update a Cloud deployment ci:project-deploy-security Create a Security Serverless Project Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants