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] Open alerts with an associated template in the template view #123333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1c6d772
Open alerts with a template, with a template
kqualters-elastic Jan 18, 2022
0e616ba
Add default values back instead of template derived ones
kqualters-elastic Jan 19, 2022
5be2880
Use data providers over filters always, set timeline description to a…
kqualters-elastic Jan 19, 2022
2c32e9f
Remove prepopulated description from non threshold alerts
kqualters-elastic Jan 19, 2022
30fa320
Merge branch 'main' into open-in-timeline-cleanup
kibanamachine Jan 24, 2022
597b4c9
Open any event in timeline, use correct timestamp
kqualters-elastic Jan 24, 2022
6f72615
Remove unneeded @timestamp, make sure alertsEcsData is not empty array
kqualters-elastic Jan 24, 2022
c8a86da
Add basic getField tests
kqualters-elastic Jan 25, 2022
f590124
Explicity check if alertGroupId is an array instead of using length
kqualters-elastic Jan 25, 2022
6fa41a9
Always use a valid date for time range
kqualters-elastic Jan 25, 2022
59ab4aa
Only use filter if more than 1 alert is present
kqualters-elastic Jan 25, 2022
6fd6265
Possibly controversial change to calculate threshold time range with …
kqualters-elastic Jan 25, 2022
9b2b89e
Create threshold timeline in separate function
kqualters-elastic Jan 25, 2022
5e5ab70
Use better type for createTimeline passed to createThresholdTimeline
kqualters-elastic Jan 25, 2022
84dd174
Invert negation as suggested in pr comment
kqualters-elastic Jan 25, 2022
12c42d3
Use template timeline filters/query/data providers for threshold alerts
kqualters-elastic Jan 25, 2022
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 @@ -15,6 +15,7 @@ import {
mockEcsDataWithAlert,
mockTimelineDetails,
mockTimelineResult,
mockAADEcsDataWithAlert,
} from '../../../common/mock/';
import { CreateTimeline, UpdateTimelineLoading } from './types';
import { Ecs } from '../../../../common/ecs';
Expand Down Expand Up @@ -268,6 +269,9 @@ describe('alert actions', () => {
updateTimelineIsLoading,
searchStrategyClient,
});
const defaultTimelinePropsWithoutNote = { ...defaultTimelineProps };

delete defaultTimelinePropsWithoutNote.ruleNote;

expect(updateTimelineIsLoading).toHaveBeenCalledWith({
id: TimelineId.active,
Expand All @@ -278,7 +282,17 @@ describe('alert actions', () => {
isLoading: false,
});
expect(createTimeline).toHaveBeenCalledTimes(1);
expect(createTimeline).toHaveBeenCalledWith(defaultTimelineProps);
expect(createTimeline).toHaveBeenCalledWith({
...defaultTimelinePropsWithoutNote,
timeline: {
...defaultTimelinePropsWithoutNote.timeline,
dataProviders: [],
kqlQuery: {
filterQuery: null,
},
resolveTimelineConfig: undefined,
},
});
});
});

Expand All @@ -289,8 +303,7 @@ describe('alert actions', () => {
signal: {
rule: {
...mockEcsDataWithAlert.signal?.rule,
// @ts-expect-error
timeline_id: null,
timeline_id: [''],
},
},
};
Expand Down Expand Up @@ -362,6 +375,7 @@ describe('alert actions', () => {
...defaultTimelineProps,
timeline: {
...defaultTimelineProps.timeline,
resolveTimelineConfig: undefined,
dataProviders: [
{
and: [],
Expand Down Expand Up @@ -424,14 +438,53 @@ describe('alert actions', () => {
});

test('it uses original_time and threshold_result.from for threshold alerts', async () => {
const ecsDataMock = getThresholdDetectionAlertAADMock();
const ecsDataMockWithNoTemplateTimeline = getThresholdDetectionAlertAADMock({
...mockAADEcsDataWithAlert,
kibana: {
alert: {
...mockAADEcsDataWithAlert.kibana?.alert,
rule: {
...mockAADEcsDataWithAlert.kibana?.alert?.rule,
parameters: {
...mockAADEcsDataWithAlert.kibana?.alert?.rule?.parameters,
threshold: {
field: ['destination.ip'],
value: 1,
},
},
name: ['mock threshold rule'],
saved_id: [],
type: ['threshold'],
uuid: ['c5ba41ab-aaf3-4f43-971b-bdf9434ce0ea'],
timeline_id: undefined,
timeline_title: undefined,
},
threshold_result: {
count: 99,
from: '2021-01-10T21:11:45.839Z',
cardinality: [
{
field: 'source.ip',
value: 1,
},
],
terms: [
{
field: 'destination.ip',
value: 1,
},
],
},
},
},
});

const expectedFrom = '2021-01-10T21:11:45.839Z';
const expectedTo = '2021-01-10T21:12:45.839Z';

await sendAlertToTimelineAction({
createTimeline,
ecsData: ecsDataMock,
ecsData: ecsDataMockWithNoTemplateTimeline,
updateTimelineIsLoading,
searchStrategyClient,
});
Expand Down
Loading