Skip to content

Commit

Permalink
[SECURITY] Add endpoint alerts url (#69707) (#69756)
Browse files Browse the repository at this point in the history
* Add back endpoint alerts url

* hack to move on

* fix type

* fix test
  • Loading branch information
XavierM committed Jun 24, 2020
1 parent d082616 commit c6d5d0a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 6 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const APP_TIMELINES_PATH = `${APP_PATH}/timelines`;
export const APP_CASES_PATH = `${APP_PATH}/cases`;
export const APP_MANAGEMENT_PATH = `${APP_PATH}/management`;

export const SHOW_ENDPOINT_ALERTS_NAV = true;
export const APP_ENDPOINT_ALERTS_PATH = `${APP_PATH}/endpoint-alerts`;

/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events */
export const DEFAULT_INDEX_PATTERN = [
'apm-*-transaction*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
APP_TIMELINES_PATH,
APP_CASES_PATH,
APP_MANAGEMENT_PATH,
APP_ENDPOINT_ALERTS_PATH,
} from '../../../common/constants';

export const navTabs: SiemNavTab = {
Expand Down Expand Up @@ -68,4 +69,11 @@ export const navTabs: SiemNavTab = {
disabled: false,
urlKey: SecurityPageName.management,
},
[SecurityPageName.endpointAlerts]: {
id: SecurityPageName.endpointAlerts,
name: 'Endpoint Alerts', // No Need of i18n since, it is just temporary
href: APP_ENDPOINT_ALERTS_PATH,
disabled: false,
urlKey: SecurityPageName.management, // Just to make type happy, this should go away soon
},
};
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/public/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum SecurityPageName {
timelines = 'timelines',
case = 'case',
management = 'management',
endpointAlerts = 'endpointAlerts',
}
export interface SecuritySubPluginStore<K extends SecuritySubPluginKeyStore, T> {
initialState: Record<K, T | undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ describe('SIEM Navigation', () => {
name: 'Timelines',
urlKey: 'timeline',
},
endpointAlerts: {
disabled: false,
href: '/app/security/endpoint-alerts',
id: 'endpointAlerts',
name: 'Endpoint Alerts',
urlKey: 'management',
},
},
pageName: 'hosts',
pathName: '/',
Expand Down Expand Up @@ -185,7 +192,7 @@ describe('SIEM Navigation', () => {
wrapper.setProps({
pageName: 'network',
pathName: '/',
tabName: undefined,
tabName: 'authentications',
});
wrapper.update();
expect(setBreadcrumbs).toHaveBeenNthCalledWith(
Expand All @@ -209,7 +216,13 @@ describe('SIEM Navigation', () => {
name: 'Cases',
urlKey: 'case',
},

endpointAlerts: {
disabled: false,
href: '/app/security/endpoint-alerts',
id: 'endpointAlerts',
name: 'Endpoint Alerts',
urlKey: 'management',
},
hosts: {
disabled: false,
href: '/app/security/hosts',
Expand Down Expand Up @@ -252,7 +265,7 @@ describe('SIEM Navigation', () => {
savedQuery: undefined,
search: '',
state: undefined,
tabName: undefined,
tabName: 'authentications',
timeline: { id: '', isOpen: false },
timerange: {
global: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export type SiemNavTabKey =
| SecurityPageName.alerts
| SecurityPageName.timelines
| SecurityPageName.case
| SecurityPageName.management;
| SecurityPageName.management
| SecurityPageName.endpointAlerts;

export type SiemNavTab = Record<SiemNavTabKey, NavTab>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AlertIndex } from './view';

export const EndpointAlertsRoutes: React.FC = () => (
<Switch>
<Route path="/:pageName(endpoint-alerts)">
<Route path="/">
<AlertIndex />
</Route>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const alertListPagination = createStructuredSelector({
* Returns a boolean based on whether or not the user is on the alerts page
*/
export const isOnAlertPage = (state: Immutable<AlertListState>): boolean => {
return state.location ? state.location.pathname === '/endpoint-alerts' : false;
return state.location
? state.location.pathname === '/endpoint-alerts' ||
window.location.pathname.includes('/endpoint-alerts')
: false;
};

/**
Expand Down
31 changes: 31 additions & 0 deletions x-pack/plugins/security_solution/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import {
APP_TIMELINES_PATH,
APP_MANAGEMENT_PATH,
APP_CASES_PATH,
SHOW_ENDPOINT_ALERTS_NAV,
APP_ENDPOINT_ALERTS_PATH,
} from '../common/constants';
import { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource';

Expand Down Expand Up @@ -290,6 +292,35 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
},
});

if (SHOW_ENDPOINT_ALERTS_NAV) {
core.application.register({
id: `${APP_ID}:${SecurityPageName.endpointAlerts}`,
title: 'Endpoint Alerts',
order: 9002,
euiIconType: APP_ICON,
category: DEFAULT_APP_CATEGORIES.security,
appRoute: APP_ENDPOINT_ALERTS_PATH,
mount: async (params: AppMountParameters) => {
const [
{ coreStart, startPlugins, store, services },
{ renderApp, composeLibs },
{ endpointAlertsSubPlugin },
] = await Promise.all([
mountSecurityFactory(),
this.downloadAssets(),
this.downloadSubPlugins(),
]);
return renderApp({
...composeLibs(coreStart),
...params,
services,
store,
SubPluginRoutes: endpointAlertsSubPlugin.start(coreStart, startPlugins).SubPluginRoutes,
});
},
});
}

core.application.register({
id: 'siem',
appRoute: 'app/siem',
Expand Down

0 comments on commit c6d5d0a

Please sign in to comment.