Skip to content

Commit

Permalink
[Rules migration] Allow sorting by risk_score field (#207207)
Browse files Browse the repository at this point in the history
## Summary

[Internal link](elastic/security-team#10820)
to the feature details

This PR adds possibility to sort migration rules by `risk_score` field.


https://github.com/user-attachments/assets/97a2bb5b-fc19-45db-ab93-c7f9676aa81c

> [!NOTE]  
> This feature needs `siemMigrationsEnabled` experimental flag enabled
to work.
  • Loading branch information
e40pud authored Jan 21, 2025
1 parent fb8a17b commit f21500b
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const sortingOptions = {
},
];
},
riskScore(direction: estypes.SortOrder = 'asc'): estypes.SortCombinations[] {
return [{ 'elastic_rule.risk_score': direction }];
},
status(direction: estypes.SortOrder = 'asc'): estypes.SortCombinations[] {
const field = 'translation_result';
const installedRuleField = 'elastic_rule.id';
Expand Down Expand Up @@ -101,6 +104,7 @@ const DEFAULT_SORTING: estypes.Sort = [
...sortingOptions.status('desc'),
...sortingOptions.matchedPrebuiltRule('desc'),
...sortingOptions.severity(),
...sortingOptions.riskScore('desc'),
...sortingOptions.updated(),
];

Expand All @@ -109,6 +113,13 @@ const sortingOptionsMap: {
} = {
'elastic_rule.title': sortingOptions.name,
'elastic_rule.severity': (direction?: estypes.SortOrder) => [
...sortingOptions.severity(direction),
...sortingOptions.riskScore(direction),
...sortingOptions.status('desc'),
...sortingOptions.matchedPrebuiltRule('desc'),
],
'elastic_rule.risk_score': (direction?: estypes.SortOrder) => [
...sortingOptions.riskScore(direction),
...sortingOptions.severity(direction),
...sortingOptions.status('desc'),
...sortingOptions.matchedPrebuiltRule('desc'),
Expand All @@ -117,11 +128,13 @@ const sortingOptionsMap: {
...sortingOptions.matchedPrebuiltRule(direction),
...sortingOptions.status('desc'),
...sortingOptions.severity('desc'),
...sortingOptions.riskScore(direction),
],
translation_result: (direction?: estypes.SortOrder) => [
...sortingOptions.status(direction),
...sortingOptions.matchedPrebuiltRule('desc'),
...sortingOptions.severity('desc'),
...sortingOptions.riskScore(direction),
],
updated_at: sortingOptions.updated,
};
Expand Down

0 comments on commit f21500b

Please sign in to comment.