Skip to content

Commit

Permalink
Make all risk score decimal places consistent (#198450)
Browse files Browse the repository at this point in the history
## Summary

This PR updates risk scores to use formatter to 2DP instead of basic
Math.round for consistency and accuracy.


![image](https://github.com/user-attachments/assets/ede600ef-acd3-463b-8f0f-8f527271836e)


![image](https://github.com/user-attachments/assets/a49f2a01-e05a-4077-8397-cff18da7cfa5)



![image](https://github.com/user-attachments/assets/599d3bcb-118f-4e32-94e6-ff4aa0a60fa8)

With reverted alert score, showing user and host risk scores still have
formatting:


![image](https://github.com/user-attachments/assets/94cb4d9e-a468-4cb7-b162-74762b134436)
  • Loading branch information
CAWilson94 authored Nov 8, 2024
1 parent d6f5824 commit 4b6b1c3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;

Expand Down Expand Up @@ -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>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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');
});

Expand Down

0 comments on commit 4b6b1c3

Please sign in to comment.