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] Fix incorrect detection rules sort order #130105

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

xcrzx
Copy link
Contributor

@xcrzx xcrzx commented Apr 13, 2022

Resolves: #124335

Summary

Added lowercase normalizer to the alert.name.keyword mappings. That makes rules sorting case-insensitive and produces the correct order when rules are sorted in UI.

Before

Screenshot 2022-04-13 at 14 52 42

Screenshot 2022-04-13 at 14 52 57

After

Screenshot 2022-04-13 at 14 45 35

Screenshot 2022-04-13 at 14 45 49

@xcrzx xcrzx added 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 v8.3.0 labels Apr 13, 2022
@xcrzx xcrzx self-assigned this Apr 13, 2022
fields: {
keyword: {
type: 'keyword',
normalizer: 'lowercase',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The addition of a new normalizer to the existing fields creates a mappings conflict:

Mapper for [alert.name.keyword] conflicts with existing mapper:
	Cannot update parameter [normalizer] from [null] to [lowercase]

However, I'm not sure if we should handle conflicts like that in code. I suppose it affects only dev environments but not users.

Copy link
Contributor

Choose a reason for hiding this comment

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

I asked to @rudolf and we are in good shape, I tested locally and were able to move forward by deleting .kibana

Comment on lines 94 to 98
const mappingKey = 'properties.' + key.split('.').join('.properties.');
const field = get(mappings, mappingKey);
const field = get(alertMappings, mappingKey);
if (field != null && field.type === 'nested') {
localNestedKeys = ast.value;
}
Copy link
Contributor Author

@xcrzx xcrzx Apr 14, 2022

Choose a reason for hiding this comment

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

It looks like this condition was always false. field was always undefined because the mappingKey starts with properties. but according to the mappings.json structure, the key should start with alert.properties.. So I fixed that in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!!!

@xcrzx xcrzx marked this pull request as ready for review April 14, 2022 12:38
@xcrzx xcrzx requested a review from a team as a code owner April 14, 2022 12:38
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@xcrzx xcrzx added release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Apr 14, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@xcrzx xcrzx force-pushed the rules-sort-fix branch 4 times, most recently from 7a19913 to 0a6afe8 Compare April 26, 2022 09:00
@banderror banderror added bug Fixes for quality problems that affect the customer experience impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Feature:Rule Management Security Solution Detection Rule Management labels Apr 26, 2022
Copy link
Contributor

@XavierM XavierM left a comment

Choose a reason for hiding this comment

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

LGTM, tested locally and it works as expected. Thanks a lot!!! Our user will like the sorting working the right way

image

@kibana-ci
Copy link
Collaborator

kibana-ci commented Apr 28, 2022

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Jest Tests #2 / HostAlertsTable should render the updated at subtitle

Metrics [docs]

✅ unchanged

History

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

cc @xcrzx

@xcrzx xcrzx merged commit 85c1870 into elastic:main Apr 28, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 28, 2022
@xcrzx xcrzx deleted the rules-sort-fix branch April 28, 2022 13:07
dmlemeshko pushed a commit to dmlemeshko/kibana that referenced this pull request May 5, 2022
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
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 bug Fixes for quality problems that affect the customer experience Feature:Rule Management Security Solution Detection Rule Management impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. release_note:fix Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.3.0
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

[Security Solution] Sorting by rule names produces the wrong order.
6 participants