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][Detections][Threshold Rules][7.12] Threshold summary view #94345

Merged
merged 7 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import {
ALERTS_HEADERS_RISK_SCORE,
ALERTS_HEADERS_RULE,
ALERTS_HEADERS_SEVERITY,
ALERTS_HEADERS_THRESHOLD_COUNT,
ALERTS_HEADERS_THRESHOLD_TERMS,
ALERTS_HEADERS_THRESHOLD_CARDINALITY,
} from '../../../detections/components/alerts_table/translations';
import {
IP_FIELD_TYPE,
Expand Down Expand Up @@ -61,6 +64,9 @@ const fields = [
{ id: 'user.name' },
{ id: SOURCE_IP_FIELD_NAME, fieldType: IP_FIELD_TYPE },
{ id: DESTINATION_IP_FIELD_NAME, fieldType: IP_FIELD_TYPE },
{ id: 'signal.threshold_result.count', label: ALERTS_HEADERS_THRESHOLD_COUNT },
{ id: 'signal.threshold_result.terms', label: ALERTS_HEADERS_THRESHOLD_TERMS },
{ id: 'signal.threshold_result.cardinality', label: ALERTS_HEADERS_THRESHOLD_CARDINALITY },
];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -135,6 +141,45 @@ const getSummary = ({
linkValue: linkValue ?? undefined,
};

if (item.id === 'signal.threshold_result.terms') {
try {
const terms = getOr(null, 'originalValue', field);
const parsedValue = terms.map((term: string) => JSON.parse(term));
banderror marked this conversation as resolved.
Show resolved Hide resolved
const thresholdTerms = (parsedValue ?? []).map(
(entry: { field: string; value: string }) => {
return {
title: `${entry.field} [threshold]`,
description: {
...description,
value: entry.value,
},
};
}
);
return [...acc, ...thresholdTerms];
} catch (err) {
return acc;
}
}

if (item.id === 'signal.threshold_result.cardinality') {
try {
const parsedValue = JSON.parse(value);
return [
...acc,
{
title: ALERTS_HEADERS_THRESHOLD_CARDINALITY,
description: {
...description,
value: `count(${parsedValue.field}) == ${parsedValue.value}`,
},
},
];
} catch (err) {
return acc;
}
}

return [
...acc,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ export const ALERTS_HEADERS_RISK_SCORE = i18n.translate(
}
);

export const ALERTS_HEADERS_THRESHOLD_COUNT = i18n.translate(
'xpack.securitySolution.eventsViewer.alerts.defaultHeaders.thresholdCount',
{
defaultMessage: 'Threshold Count',
}
);

export const ALERTS_HEADERS_THRESHOLD_TERMS = i18n.translate(
'xpack.securitySolution.eventsViewer.alerts.defaultHeaders.thresholdTerms',
{
defaultMessage: 'Threshold Terms',
}
);

export const ALERTS_HEADERS_THRESHOLD_CARDINALITY = i18n.translate(
'xpack.securitySolution.eventsViewer.alerts.defaultHeaders.thresholdCardinality',
{
defaultMessage: 'Threshold Cardinality',
}
);

export const ACTION_OPEN_ALERT = i18n.translate(
'xpack.securitySolution.detectionEngine.alerts.actions.openAlertTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('transformThresholdNormalizedResultsToEcs', () => {
_id,
_index: 'test',
_source: {
'source.ip': '127.0.0.1',
'@timestamp': '2020-04-20T21:27:45+0000',
threshold_result: {
from: new Date('2020-12-17T16:27:00.000Z'),
Expand Down Expand Up @@ -256,6 +257,8 @@ describe('transformThresholdNormalizedResultsToEcs', () => {
_index: 'test',
_source: {
'@timestamp': '2020-04-20T21:27:45+0000',
'host.name': 'garden-gnomes',
'source.ip': '127.0.0.1',
threshold_result: {
from: new Date('2020-12-17T16:28:00.000Z'), // from threshold signal history
terms: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ const getTransformedHits = (

const source = {
'@timestamp': timestamp,
...bucket.terms.reduce<object>((termAcc, term) => {
if (!term.field.startsWith('signal.')) {
madirey marked this conversation as resolved.
Show resolved Hide resolved
return {
...termAcc,
[term.field]: term.value,
};
}
return termAcc;
}, {}),
threshold_result: {
terms: bucket.terms,
cardinality: bucket.cardinality,
Expand Down