-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] [Feat] Add Bulk Events to Timeline. (#142737)
This PR implements functionality to add multiple events to the timeline. It is implements : 1. Selected events ( max 4000 ) can be added to the timeline. ## Implementation. 1. At present, it only support adding multiple records in the timeline as `kql Filters`. #142436 is in progress to implement `is-one-of` operator in the data provider. Once that is moved to `main`, we can change value of `prefer` parameter to send the IDs in `dataProvider` rather than filter. If you would like to test it with #142436, please clone : https://github.com/logeekal/kibana/tree/bulk_actions_add_timeline_with_is_one_of 2. Below is the demonstration how it works. https://user-images.githubusercontent.com/7485038/199056731-4287fc61-9d0b-4cf3-ba1f-741f6b66ae97.mov
- Loading branch information
Showing
45 changed files
with
39,230 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
x-pack/plugins/security_solution/cypress/e2e/timelines/bulk_add_to_timeline.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getNewRule } from '../../objects/rule'; | ||
import { SELECTED_ALERTS } from '../../screens/alerts'; | ||
import { SERVER_SIDE_EVENT_COUNT } from '../../screens/timeline'; | ||
import { createCustomRuleEnabled } from '../../tasks/api_calls/rules'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { | ||
bulkInvestigateSelectedEventsInTimeline, | ||
selectAllEvents, | ||
selectFirstPageEvents, | ||
} from '../../tasks/common/event_table'; | ||
import { waitForAlertsToPopulate } from '../../tasks/create_new_rule'; | ||
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver'; | ||
import { waitsForEventsToBeLoaded } from '../../tasks/hosts/events'; | ||
import { openEvents, openSessions } from '../../tasks/hosts/main'; | ||
import { login, visit } from '../../tasks/login'; | ||
import { closeTimelineUsingCloseButton } from '../../tasks/security_main'; | ||
import { ALERTS_URL, HOSTS_URL } from '../../urls/navigation'; | ||
|
||
const assertFirstPageEventsAddToTimeline = () => { | ||
selectFirstPageEvents(); | ||
cy.get(SELECTED_ALERTS).then((sub) => { | ||
const alertCountText = sub.text(); | ||
const alertCount = alertCountText.split(' ')[1]; | ||
bulkInvestigateSelectedEventsInTimeline(); | ||
cy.get('body').should('contain.text', `${alertCount} event IDs`); | ||
cy.get(SERVER_SIDE_EVENT_COUNT).should('contain.text', alertCount); | ||
}); | ||
}; | ||
|
||
const assertAllEventsAddToTimeline = () => { | ||
selectAllEvents(); | ||
cy.get(SELECTED_ALERTS).then((sub) => { | ||
const alertCountText = sub.text(); // Selected 3,654 alerts | ||
const alertCount = alertCountText.split(' ')[1]; | ||
bulkInvestigateSelectedEventsInTimeline(); | ||
cy.get('body').should('contain.text', `${alertCount} event IDs`); | ||
cy.get(SERVER_SIDE_EVENT_COUNT).should('contain.text', alertCount); | ||
}); | ||
}; | ||
|
||
describe('Bulk Investigate in Timeline', () => { | ||
before(() => { | ||
cleanKibana(); | ||
esArchiverLoad('bulk_process'); | ||
login(); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('bulk_process'); | ||
}); | ||
|
||
context('Alerts', () => { | ||
before(() => { | ||
createCustomRuleEnabled(getNewRule()); | ||
visit(ALERTS_URL); | ||
}); | ||
beforeEach(() => { | ||
waitForAlertsToPopulate(); | ||
}); | ||
|
||
afterEach(() => { | ||
closeTimelineUsingCloseButton(); | ||
}); | ||
|
||
it('Adding multiple alerts to the timeline should be successful', () => { | ||
assertFirstPageEventsAddToTimeline(); | ||
}); | ||
|
||
it('When selected all alerts are selected should be successfull', () => { | ||
assertAllEventsAddToTimeline(); | ||
}); | ||
}); | ||
|
||
context('Host -> Events Viewer', () => { | ||
before(() => { | ||
visit(HOSTS_URL); | ||
openEvents(); | ||
waitsForEventsToBeLoaded(); | ||
}); | ||
|
||
afterEach(() => { | ||
closeTimelineUsingCloseButton(); | ||
}); | ||
|
||
it('Adding multiple alerts to the timeline should be successful', () => { | ||
assertFirstPageEventsAddToTimeline(); | ||
}); | ||
|
||
it('When selected all alerts are selected should be successfull', () => { | ||
assertAllEventsAddToTimeline(); | ||
}); | ||
}); | ||
|
||
context('Host -> Sessions Viewer', () => { | ||
before(() => { | ||
visit(HOSTS_URL); | ||
openSessions(); | ||
waitsForEventsToBeLoaded(); | ||
}); | ||
|
||
afterEach(() => { | ||
closeTimelineUsingCloseButton(); | ||
}); | ||
|
||
it('Adding multiple alerts to the timeline should be successful', () => { | ||
assertFirstPageEventsAddToTimeline(); | ||
}); | ||
|
||
it('When selected all alerts are selected should be successfull', () => { | ||
assertAllEventsAddToTimeline(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/security_solution/cypress/tasks/common/event_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SELECTED_ALERTS } from '../../screens/alerts'; | ||
import { | ||
SELECT_ALL_EVENTS, | ||
SELECT_EVENTS_ACTION_ADD_BULK_TO_TIMELINE, | ||
} from '../../screens/common/controls'; | ||
import { EVENT_VIEWER_CHECKBOX } from '../../screens/hosts/events'; | ||
|
||
export const selectFirstPageEvents = () => { | ||
cy.get(EVENT_VIEWER_CHECKBOX).first().scrollIntoView().click(); | ||
}; | ||
|
||
export const selectAllEvents = () => { | ||
cy.get(EVENT_VIEWER_CHECKBOX).first().scrollIntoView().click(); | ||
cy.get(SELECT_ALL_EVENTS).click(); | ||
}; | ||
|
||
export const bulkInvestigateSelectedEventsInTimeline = () => { | ||
cy.get(SELECTED_ALERTS).trigger('click'); | ||
cy.get(SELECT_EVENTS_ACTION_ADD_BULK_TO_TIMELINE).click(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.