Skip to content

Commit c4cb1b7

Browse files
PR comments
1 parent a68ec92 commit c4cb1b7

7 files changed

Lines changed: 50 additions & 54 deletions

File tree

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/table/group_stats_aggregations.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ export const groupStatsAggregations = (field: string): NamedAggregation[] => {
3535

3636
switch (field) {
3737
case 'signal.rule.id':
38-
aggMetrics.push(...[SEVERITY_SUB_AGGREGATION, RULE_COUNT_AGGREGATION]);
38+
aggMetrics.push(SEVERITY_SUB_AGGREGATION, RULE_COUNT_AGGREGATION);
3939
break;
4040
case 'kibana.alert.severity':
41-
aggMetrics.push(...[RULE_SIGNAL_ID_SUB_AGGREGATION, RULE_COUNT_AGGREGATION]);
41+
aggMetrics.push(RULE_SIGNAL_ID_SUB_AGGREGATION, RULE_COUNT_AGGREGATION);
4242
break;
4343
case 'kibana.alert.rule.name':
44-
aggMetrics.push(...[RULE_SIGNAL_ID_SUB_AGGREGATION, SEVERITY_SUB_AGGREGATION]);
44+
aggMetrics.push(RULE_SIGNAL_ID_SUB_AGGREGATION, SEVERITY_SUB_AGGREGATION);
4545
break;
4646
default:
4747
aggMetrics.push(
48-
...[RULE_SIGNAL_ID_SUB_AGGREGATION, SEVERITY_SUB_AGGREGATION, RULE_COUNT_AGGREGATION]
48+
RULE_SIGNAL_ID_SUB_AGGREGATION,
49+
SEVERITY_SUB_AGGREGATION,
50+
RULE_COUNT_AGGREGATION
4951
);
5052
}
5153
return aggMetrics;

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/table/group_stats_renderers.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('getIntegrationComponent', () => {
109109
expect(groupStatsItems.length).toBe(1);
110110
expect(groupStatsItems[0].component).toMatchInlineSnapshot(`
111111
<React.Fragment>
112-
Multi
112+
Multi
113113
</React.Fragment>
114114
`);
115115
});

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/table/group_stats_renderers.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const STATS_GROUP_SIGNAL_RULE_ID = i18n.translate(
2525
const STATS_GROUP_SIGNAL_RULE_ID_MULTI = i18n.translate(
2626
'xpack.securitySolution.alertSummary.groups.integrations.multi',
2727
{
28-
defaultMessage: 'Multi',
28+
defaultMessage: ' Multi',
2929
}
3030
);
3131

@@ -110,20 +110,16 @@ export const groupStatsRenderer = (
110110
const defaultBadges: GroupStatsItem[] = DEFAULT_GROUP_STATS_RENDERER(selectedGroup, bucket);
111111
const severityComponent: GroupStatsItem[] = getSeverityComponent(bucket);
112112
const integrationComponent: GroupStatsItem[] = getIntegrationComponent(bucket);
113+
const rulesBadge: GroupStatsItem = getRulesBadge(bucket);
113114

114115
switch (selectedGroup) {
115116
case 'signal.rule.id':
116-
return [...severityComponent, getRulesBadge(bucket), ...defaultBadges];
117+
return [...severityComponent, rulesBadge, ...defaultBadges];
117118
case 'kibana.alert.severity':
118-
return [...integrationComponent, getRulesBadge(bucket), ...defaultBadges];
119+
return [...integrationComponent, rulesBadge, ...defaultBadges];
119120
case 'kibana.alert.rule.name':
120121
return [...integrationComponent, ...severityComponent, ...defaultBadges];
121122
default:
122-
return [
123-
...integrationComponent,
124-
...severityComponent,
125-
getRulesBadge(bucket),
126-
...defaultBadges,
127-
];
123+
return [...integrationComponent, ...severityComponent, rulesBadge, ...defaultBadges];
128124
}
129125
};

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/table/render_cell.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import type { Alert } from '@kbn/alerting-types';
1010
import type { JsonValue } from '@kbn/utility-types';
1111
import { getOrEmptyTagFromValue } from '../../../../common/components/empty_value';
1212

13+
const styles = { display: 'flex', alignItems: 'center', height: '100%' };
14+
1315
export interface CellValueProps {
1416
/**
1517
* Alert data passed from the renderCellValue callback via the AlertWithLegacyFormats interface
@@ -54,11 +56,7 @@ export const CellValue = memo(({ alert, columnId }: CellValueProps) => {
5456
}
5557
}, [alert, columnId]);
5658

57-
return (
58-
<div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
59-
{getOrEmptyTagFromValue(displayValue)}
60-
</div>
61-
);
59+
return <div style={styles}>{getOrEmptyTagFromValue(displayValue)}</div>;
6260
});
6361

6462
CellValue.displayName = 'CellValue';

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/table/table.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ export const Table = memo(({ dataView, groupingFilters }: TableProps) => {
161161
if (combinedQuery?.kqlError || !combinedQuery?.filterQuery) {
162162
return { bool: {} };
163163
}
164-
return { bool: { filter: JSON.parse(combinedQuery?.filterQuery) } };
164+
165+
try {
166+
const filter = JSON.parse(combinedQuery?.filterQuery);
167+
return { bool: { filter } };
168+
} catch {
169+
return { bool: {} };
170+
}
165171
}, [browserFields, dataViewSpec, filters, globalQuery, uiSettings]);
166172

167173
const renderAdditionalToolbarControls = useCallback(

x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/grouping_settings/default_group_stats_aggregations.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,42 +54,34 @@ export const defaultGroupStatsAggregations = (field: string): NamedAggregation[]
5454
switch (field) {
5555
case 'kibana.alert.rule.name':
5656
aggMetrics.push(
57-
...[
58-
{
59-
description: {
60-
terms: {
61-
field: 'kibana.alert.rule.description',
62-
size: 1,
63-
},
57+
{
58+
description: {
59+
terms: {
60+
field: 'kibana.alert.rule.description',
61+
size: 1,
6462
},
6563
},
66-
SEVERITY_SUB_AGGREGATION,
67-
USER_COUNT_AGGREGATION,
68-
HOST_COUNT_AGGREGATION,
69-
{
70-
ruleTags: {
71-
terms: {
72-
field: 'kibana.alert.rule.tags',
73-
},
64+
},
65+
SEVERITY_SUB_AGGREGATION,
66+
USER_COUNT_AGGREGATION,
67+
HOST_COUNT_AGGREGATION,
68+
{
69+
ruleTags: {
70+
terms: {
71+
field: 'kibana.alert.rule.tags',
7472
},
7573
},
76-
]
74+
}
7775
);
7876
break;
7977
case 'host.name':
80-
aggMetrics.push(
81-
...[RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, USER_COUNT_AGGREGATION]
82-
);
78+
aggMetrics.push(RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, USER_COUNT_AGGREGATION);
8379
break;
8480
case 'user.name':
85-
aggMetrics.push(
86-
...[RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, HOST_COUNT_AGGREGATION]
87-
);
81+
aggMetrics.push(RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, HOST_COUNT_AGGREGATION);
8882
break;
8983
case 'source.ip':
90-
aggMetrics.push(
91-
...[RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, HOST_COUNT_AGGREGATION]
92-
);
84+
aggMetrics.push(RULE_COUNT_AGGREGATION, SEVERITY_SUB_AGGREGATION, HOST_COUNT_AGGREGATION);
9385
break;
9486
default:
9587
aggMetrics.push(RULE_COUNT_AGGREGATION);

x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/grouping_settings/default_group_stats_renderers.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ import { DEFAULT_GROUP_STATS_RENDERER } from '../alerts_grouping';
1313
import type { AlertsGroupingAggregation } from './types';
1414
import * as i18n from '../translations';
1515

16-
export const getUsersBadge = (bucket: RawBucket<AlertsGroupingAggregation>) => ({
16+
export const getUsersBadge = (bucket: RawBucket<AlertsGroupingAggregation>): GroupStatsItem => ({
1717
title: i18n.STATS_GROUP_USERS,
1818
badge: {
1919
value: bucket.usersCountAggregation?.value ?? 0,
2020
},
2121
});
22-
export const getHostsBadge = (bucket: RawBucket<AlertsGroupingAggregation>) => ({
22+
export const getHostsBadge = (bucket: RawBucket<AlertsGroupingAggregation>): GroupStatsItem => ({
2323
title: i18n.STATS_GROUP_HOSTS,
2424
badge: {
2525
value: bucket.hostsCountAggregation?.value ?? 0,
2626
},
2727
});
28-
export const getRulesBadge = (bucket: RawBucket<AlertsGroupingAggregation>) => ({
28+
export const getRulesBadge = (bucket: RawBucket<AlertsGroupingAggregation>): GroupStatsItem => ({
2929
title: i18n.STATS_GROUP_RULES,
3030
badge: {
3131
value: bucket.rulesCountAggregation?.value ?? 0,
@@ -57,7 +57,6 @@ export const Severity = memo(({ severities }: SingleSeverityProps) => {
5757
<span className="smallDot">
5858
<EuiIcon type="dot" color="#da8b45" />
5959
</span>
60-
6160
<span>
6261
<EuiIcon type="dot" color="#e7664c" />
6362
</span>
@@ -137,17 +136,20 @@ export const defaultGroupStatsRenderer = (
137136
selectedGroup: string,
138137
bucket: RawBucket<AlertsGroupingAggregation>
139138
): GroupStatsItem[] => {
140-
const severityStat: GroupStatsItem[] = getSeverityComponent(bucket);
139+
const severityComponent: GroupStatsItem[] = getSeverityComponent(bucket);
141140
const defaultBadges: GroupStatsItem[] = DEFAULT_GROUP_STATS_RENDERER(selectedGroup, bucket);
141+
const usersBadge: GroupStatsItem = getUsersBadge(bucket);
142+
const hostsBadge: GroupStatsItem = getHostsBadge(bucket);
143+
const rulesBadge: GroupStatsItem = getRulesBadge(bucket);
142144

143145
switch (selectedGroup) {
144146
case 'kibana.alert.rule.name':
145-
return [...severityStat, getUsersBadge(bucket), getHostsBadge(bucket), ...defaultBadges];
147+
return [...severityComponent, usersBadge, hostsBadge, ...defaultBadges];
146148
case 'host.name':
147-
return [...severityStat, getUsersBadge(bucket), getRulesBadge(bucket), ...defaultBadges];
149+
return [...severityComponent, usersBadge, rulesBadge, ...defaultBadges];
148150
case 'user.name':
149151
case 'source.ip':
150-
return [...severityStat, getHostsBadge(bucket), getRulesBadge(bucket), ...defaultBadges];
152+
return [...severityComponent, hostsBadge, rulesBadge, ...defaultBadges];
151153
}
152-
return [...severityStat, getRulesBadge(bucket), ...defaultBadges];
154+
return [...severityComponent, rulesBadge, ...defaultBadges];
153155
};

0 commit comments

Comments
 (0)