forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elastic#20 from Elastic-AWP-Platform/entry-leader-…
…table Initial timelines integration with the session_view plugin
- Loading branch information
Showing
32 changed files
with
5,623 additions
and
10 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
136 changes: 136 additions & 0 deletions
136
x-pack/plugins/security_solution/cypress/integration/hosts/session_view.spec.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,136 @@ | ||
/* | ||
* 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 { | ||
SESSION_TABLE, | ||
SESSION_VIEW_EMPTY_STATE, | ||
SESSION_TABLE_HEADER, | ||
SESSION_VIEW_CLOSE_BUTTON, | ||
PROCESS_TREE, | ||
PROCESS_TREE_NODE_ALERT, | ||
SEARCH_BAR, | ||
DETAILS_PANEL, | ||
DETAILS_PANEL_TOGGLE, | ||
DETAILS_PANEL_ALERT, | ||
DETAILS_PANEL_COMMAND, | ||
DETAILS_PANEL_SESSION, | ||
DETAILS_PANEL_SERVER, | ||
getProcessTreeNodeAlertDetailViewRule, | ||
} from '../../screens/session_view'; | ||
import { | ||
loginAndNavigateToHostSessions, | ||
openSessionView, | ||
} from '../../tasks/hosts/open_session_view'; | ||
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver'; | ||
|
||
import { cleanKibana } from '../../tasks/common'; | ||
|
||
const tableHeaders = { | ||
'@timestamp': '@timestamp', | ||
'process.user.name': 'process.user.name', | ||
'event.kind': 'event.kind', | ||
'process.session.pid': 'process.session.pid', | ||
'process.args': 'process.args', | ||
}; | ||
|
||
const TEST_EVENT_ID = 'cDLmwH0BLujk-6QxyflF'; | ||
const LS_TEST_COMMAND = 'ls --color=auto'; | ||
const ALERT_TEST_COMMAND = 'vi cmd/cmd.prj'; | ||
const ALERT_NODE_TEST_ID = getProcessTreeNodeAlertDetailViewRule( | ||
'64940663527c71b1f577df2aa529c42afc1c023108154714b49966e517e395b8' | ||
); | ||
const ALERT_RULE_ID = 'd9f45980-5e10-11ec-b7c6-17150991b0b3'; | ||
|
||
describe('Session view', () => { | ||
context('Rendering table empty state', () => { | ||
before(() => { | ||
cleanKibana(); | ||
}); | ||
|
||
it('shows the empty state', () => { | ||
loginAndNavigateToHostSessions(); | ||
cy.get(SESSION_VIEW_EMPTY_STATE).should('be.visible'); | ||
}); | ||
}); | ||
|
||
context('Rendering with data', () => { | ||
before(() => { | ||
cleanKibana(); | ||
esArchiverLoad('session_view'); | ||
}); | ||
|
||
beforeEach(() => { | ||
loginAndNavigateToHostSessions(); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('session_view'); | ||
}); | ||
|
||
it('renders the session table', () => { | ||
// Check all columns expected exist | ||
Object.keys(tableHeaders).forEach((header: string) => { | ||
cy.get(SESSION_TABLE_HEADER(header)).should('be.visible'); | ||
}); | ||
|
||
openSessionView(TEST_EVENT_ID); | ||
|
||
// Check session view exists and come back to session leader table | ||
cy.get(PROCESS_TREE).should('be.visible'); | ||
const closeSessionViewButton = cy.get(SESSION_VIEW_CLOSE_BUTTON); | ||
closeSessionViewButton.should('be.visible'); | ||
closeSessionViewButton.click(); | ||
|
||
cy.get(SESSION_TABLE).should('be.visible'); | ||
}); | ||
|
||
it('renders the session view', () => { | ||
openSessionView(TEST_EVENT_ID); | ||
|
||
// Checking Search bar exist | ||
cy.get(SEARCH_BAR).should('be.visible'); | ||
|
||
// Check detail panel and its toggle work correctly | ||
cy.get(DETAILS_PANEL).should('not.exist'); | ||
// Checking Details panel exist | ||
cy.get(DETAILS_PANEL_TOGGLE).click(); | ||
cy.get(DETAILS_PANEL).should('be.visible'); | ||
|
||
// Only Session, Server Detail exist when no commands selected when detail panel is open | ||
cy.get(DETAILS_PANEL_ALERT).should('not.exist'); | ||
cy.get(DETAILS_PANEL_COMMAND).should('not.exist'); | ||
cy.get(DETAILS_PANEL_SESSION).should('be.visible'); | ||
cy.get(DETAILS_PANEL_SERVER).should('exist'); | ||
|
||
const lsCommandNode = cy.contains(LS_TEST_COMMAND); | ||
lsCommandNode.should('exist'); | ||
lsCommandNode.click(); | ||
// Checking Command, Session, Server Detail exist for a command without alert | ||
cy.get(DETAILS_PANEL_ALERT).should('not.exist'); | ||
cy.get(DETAILS_PANEL_COMMAND).should('be.visible'); | ||
cy.get(DETAILS_PANEL_SESSION).should('exist'); | ||
cy.get(DETAILS_PANEL_SERVER).should('exist'); | ||
|
||
const viCommand = cy.contains(ALERT_TEST_COMMAND); | ||
viCommand.should('be.visible'); | ||
viCommand.click(); | ||
// Checking Command, Session, Server, Alert Detail exist | ||
cy.get(DETAILS_PANEL_ALERT).should('exist'); | ||
cy.get(DETAILS_PANEL_COMMAND).should('be.visible'); | ||
cy.get(DETAILS_PANEL_SESSION).should('exist'); | ||
cy.get(DETAILS_PANEL_SERVER).should('exist'); | ||
}); | ||
|
||
it('renders alert details correctly', () => { | ||
openSessionView(TEST_EVENT_ID); | ||
|
||
cy.get(PROCESS_TREE_NODE_ALERT).first().click(); | ||
cy.get(ALERT_NODE_TEST_ID).first().click(); | ||
cy.location('pathname').should('contain', `app/security/rules/id/${ALERT_RULE_ID}`); | ||
}); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/security_solution/cypress/screens/session_view.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,36 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// Session leader table elements | ||
export const SESSION_VIEW_TAB = '[data-test-subj="navigation-sessions"]'; | ||
export const SESSION_TABLE = '[data-test-subj="session-leader-table"]'; | ||
export const SESSION_VIEW_EMPTY_STATE = `${SESSION_TABLE} [data-test-subj="tGridEmptyState"]`; | ||
export const SESSION_TABLE_HEADER = (column: string) => | ||
`${SESSION_TABLE} [data-test-subj="dataGridHeaderCell-${column}"]`; | ||
export const SESSION_TABLE_HEADER_ACTIONS = (column: string) => | ||
`[data-test-subj="dataGridHeaderCellActionGroup-${column}"]`; | ||
export const SESSION_TABLE_ROW_CONTROL = `${SESSION_TABLE} [data-test-subj="dataGridRowCell"].euiDataGridRowCell--firstColumn`; | ||
export const SESSION_TABLE_ROW_MORE_BUTTON = (eventId: string) => | ||
`[data-test-subj="session-leader-table-more-actions-${eventId}"]`; | ||
export const SESSION_TABLE_OPEN_SESSION_VIEW_TEXT = 'Open in session viewer'; | ||
export const SESSION_VIEW_CLOSE_BUTTON = '[data-test-subj="session-view-close-button"]'; | ||
|
||
// Process tree elements | ||
export const PROCESS_TREE = '[data-test-subj="sessionViewProcessTree"]'; | ||
export const PROCESS_TREE_NODE_ALERT = '[data-test-subj="processTreeNodeAlertButton"]'; | ||
export const SEARCH_BAR = '[data-test-subj="sessionViewProcessEventsSearch"]'; | ||
|
||
// Details panel elements | ||
export const DETAILS_PANEL = '[data-test-subj="sessionViewDetailPanel"]'; | ||
export const DETAILS_PANEL_TOGGLE = '[data-test-subj="sessionViewDetailPanelToggle"]'; | ||
export const DETAILS_PANEL_ALERT = '[data-test-subj="sessionViewDetailPanelAlertDetail"]'; | ||
export const DETAILS_PANEL_COMMAND = '[data-test-subj="sessionViewDetailPanelCommandDetail"]'; | ||
export const DETAILS_PANEL_SESSION = '[data-test-subj="sessionViewDetailPanelSessionDetail"]'; | ||
export const DETAILS_PANEL_SERVER = '[data-test-subj="sessionViewDetailPanelServerDetail"]'; | ||
|
||
export const getProcessTreeNodeAlertDetailViewRule = (alertUUID: string) => | ||
`[data-test-subj="sessionViewAlertDetailViewRule-${alertUUID}"]`; |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/security_solution/cypress/tasks/hosts/open_session_view.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,25 @@ | ||
/* | ||
* 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 { | ||
SESSION_VIEW_TAB, | ||
SESSION_TABLE_ROW_MORE_BUTTON, | ||
SESSION_TABLE_OPEN_SESSION_VIEW_TEXT, | ||
} from '../../screens/session_view'; | ||
import { loginAndWaitForPage } from '../login'; | ||
import { HOSTS_URL } from '../../urls/navigation'; | ||
|
||
export const loginAndNavigateToHostSessions = () => { | ||
loginAndWaitForPage(HOSTS_URL); | ||
cy.get(SESSION_VIEW_TAB).click(); | ||
}; | ||
|
||
// Picks a session by eventId from session leader table and open session view | ||
export const openSessionView = (eventId: string) => { | ||
// Open session view | ||
cy.get(SESSION_TABLE_ROW_MORE_BUTTON(eventId)).click(); | ||
cy.contains(SESSION_TABLE_OPEN_SESSION_VIEW_TEXT).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
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
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.