Skip to content

Commit

Permalink
[8.x] Make all risk score decimal places consistent (#198450) (#199515)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [Make all risk score decimal places consistent
(#198450)](#198450)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Charlotte Alexandra
Wilson","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-08T16:33:50Z","message":"Make
all risk score decimal places consistent (#198450)\n\n##
Summary\r\n\r\nThis PR updates risk scores to use formatter to 2DP
instead of basic\r\nMath.round for consistency and
accuracy.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/ede600ef-acd3-463b-8f0f-8f527271836e)\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a49f2a01-e05a-4077-8397-cff18da7cfa5)\r\n\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/599d3bcb-118f-4e32-94e6-ff4aa0a60fa8)\r\n\r\nWith
reverted alert score, showing user and host risk scores still
have\r\nformatting:\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/94cb4d9e-a468-4cb7-b162-74762b134436)","sha":"4b6b1c3effaf9918f8332a21af42409092fd8ed5","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Theme:
entity_analytics","Team:Entity
Analytics","backport:version","v8.17.0"],"title":"Make all risk score
decimal places
consistent","number":198450,"url":"https://github.com/elastic/kibana/pull/198450","mergeCommit":{"message":"Make
all risk score decimal places consistent (#198450)\n\n##
Summary\r\n\r\nThis PR updates risk scores to use formatter to 2DP
instead of basic\r\nMath.round for consistency and
accuracy.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/ede600ef-acd3-463b-8f0f-8f527271836e)\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a49f2a01-e05a-4077-8397-cff18da7cfa5)\r\n\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/599d3bcb-118f-4e32-94e6-ff4aa0a60fa8)\r\n\r\nWith
reverted alert score, showing user and host risk scores still
have\r\nformatting:\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/94cb4d9e-a468-4cb7-b162-74762b134436)","sha":"4b6b1c3effaf9918f8332a21af42409092fd8ed5"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198450","number":198450,"mergeCommit":{"message":"Make
all risk score decimal places consistent (#198450)\n\n##
Summary\r\n\r\nThis PR updates risk scores to use formatter to 2DP
instead of basic\r\nMath.round for consistency and
accuracy.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/ede600ef-acd3-463b-8f0f-8f527271836e)\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a49f2a01-e05a-4077-8397-cff18da7cfa5)\r\n\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/599d3bcb-118f-4e32-94e6-ff4aa0a60fa8)\r\n\r\nWith
reverted alert score, showing user and host risk scores still
have\r\nformatting:\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/94cb4d9e-a468-4cb7-b162-74762b134436)","sha":"4b6b1c3effaf9918f8332a21af42409092fd8ed5"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Charlotte Alexandra Wilson <[email protected]>
kibanamachine and CAWilson94 authored Nov 8, 2024
1 parent 856019e commit 41a814c
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ import {
SecurityCellActionType,
} from '../../../common/components/cell_actions';
import { FormattedRelativePreferenceDate } from '../../../common/components/formatted_date';
import { formatRiskScore } from '../../common';

type HostRiskScoreColumns = Array<EuiBasicTableColumn<HostRiskScore & UserRiskScore>>;

@@ -128,7 +129,7 @@ export const getRiskScoreColumns = (
if (riskScore != null) {
return (
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
{Math.round(riskScore)}
{formatRiskScore(riskScore)}
</span>
);
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import { type CriticalityLevels } from '../../../../../common/constants';
import { ENTITIES_LIST_TABLE_ID } from '../constants';
import { isUserEntity, sourceFieldToText } from '../helpers';
import { CRITICALITY_LEVEL_TITLE } from '../../asset_criticality/translations';
import { formatRiskScore } from '../../../common';

export type EntitiesListColumns = [
Columns<Entity>,
@@ -149,7 +150,7 @@ export const useEntitiesListColumns = (): EntitiesListColumns => {
if (riskScore != null) {
return (
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
{Math.round(riskScore)}
{formatRiskScore(riskScore)}
</span>
);
}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import { RiskScoreLevel } from '../severity/common';
import { ENTITY_RISK_LEVEL } from '../risk_score/translations';
import { CELL_ACTIONS_TELEMETRY } from '../risk_score/constants';
import { FormattedRelativePreferenceDate } from '../../../common/components/formatted_date';
import { formatRiskScore } from '../../common';

export const getHostRiskScoreColumns = ({
dispatchSeverityUpdate,
@@ -82,7 +83,7 @@ export const getHostRiskScoreColumns = ({
if (riskScore != null) {
return (
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
{Math.round(riskScore)}
{formatRiskScore(riskScore)}
</span>
);
}
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import { UsersTableType } from '../../../explore/users/store/model';
import { ENTITY_RISK_LEVEL } from '../risk_score/translations';
import { CELL_ACTIONS_TELEMETRY } from '../risk_score/constants';
import { FormattedRelativePreferenceDate } from '../../../common/components/formatted_date';
import { formatRiskScore } from '../../common';

export const getUserRiskScoreColumns = ({
dispatchSeverityUpdate,
@@ -85,7 +86,7 @@ export const getUserRiskScoreColumns = ({
if (riskScore != null) {
return (
<span data-test-subj="risk-score-truncate" title={`${riskScore}`}>
{Math.round(riskScore)}
{formatRiskScore(riskScore)}
</span>
);
}
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ describe('risk tab', { tags: ['@ess'] }, () => {
kqlSearch('host.name: "siem-kibana" {enter}');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(4).should('have.text', 'siem-kibana');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(5).should('have.text', 'Mar 10, 2021 @ 14:51:05.766');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(6).should('have.text', '21');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(6).should('have.text', '21.00');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(7).should('have.text', 'Low');
});

@@ -93,7 +93,7 @@ describe('risk tab', { tags: ['@ess'] }, () => {
kqlSearch('host.name: "siem-kibana" {enter}');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(4).should('have.text', 'siem-kibana');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(5).should('have.text', 'Mar 10, 2021 @ 14:51:05.766');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(6).should('have.text', '90');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(6).should('have.text', '90.00');
cy.get(HOST_BY_RISK_TABLE_CELL).eq(7).should('have.text', 'Critical');
});

0 comments on commit 41a814c

Please sign in to comment.