-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#91788) * WIP add search for siem entities * Remove frontend search provider, use searchDeepLinks from core * Comment and use both functions used to generate subPlugin meta information * Use correct url for timeline templates * Remove case management attibute from saved object type * Remove unused globalSearch plugin from kibana.json * Add comments, use Subject instead of BehaviorSubject for appUpdaters * Unsubscribe from license on plugin stop
- Loading branch information
1 parent
08fc722
commit 24d0e3d
Showing
5 changed files
with
301 additions
and
4 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/security_solution/public/app/search/index.test.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,23 @@ | ||
/* | ||
* 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 { getSearchDeepLinksAndKeywords } from '.'; | ||
import { SecurityPageName } from '../../../common/constants'; | ||
|
||
describe('public search functions', () => { | ||
it('returns a subset of links for basic license, full set for platinum', () => { | ||
const basicLicense = 'basic'; | ||
const platinumLicense = 'platinum'; | ||
for (const pageName of Object.values(SecurityPageName)) { | ||
expect.assertions(Object.values(SecurityPageName).length * 2); | ||
const basicLinkCount = | ||
getSearchDeepLinksAndKeywords(pageName, basicLicense).searchDeepLinks?.length || 0; | ||
const platinumLinks = getSearchDeepLinksAndKeywords(pageName, platinumLicense); | ||
expect(platinumLinks.searchDeepLinks?.length).toBeGreaterThanOrEqual(basicLinkCount); | ||
expect(platinumLinks.keywords?.length).not.toBe(null); | ||
} | ||
}); | ||
}); |
234 changes: 234 additions & 0 deletions
234
x-pack/plugins/security_solution/public/app/search/index.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,234 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { Subject } from 'rxjs'; | ||
|
||
import { AppUpdater } from 'src/core/public'; | ||
import { LicenseType } from '../../../../licensing/common/types'; | ||
import { SecuritySubPluginNames, SecurityDeepLinks } from '../types'; | ||
import { AppMeta } from '../../../../../../src/core/public'; | ||
|
||
const securityDeepLinks: SecurityDeepLinks = { | ||
detections: { | ||
base: [ | ||
{ | ||
id: 'siemDetectionRules', | ||
title: i18n.translate('xpack.securitySolution.search.detections.manage', { | ||
defaultMessage: 'Manage Rules', | ||
}), | ||
keywords: ['rules'], | ||
path: '/rules', | ||
}, | ||
], | ||
}, | ||
hosts: { | ||
base: [ | ||
{ | ||
id: 'authentications', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.authentications', { | ||
defaultMessage: 'Authentications', | ||
}), | ||
path: '/authentications', | ||
}, | ||
{ | ||
id: 'uncommonProcesses', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.uncommonProcesses', { | ||
defaultMessage: 'Uncommon Processes', | ||
}), | ||
path: '/uncommonProcesses', | ||
}, | ||
{ | ||
id: 'events', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.events', { | ||
defaultMessage: 'Events', | ||
}), | ||
path: '/events', | ||
}, | ||
{ | ||
id: 'externalAlerts', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.externalAlerts', { | ||
defaultMessage: 'External Alerts', | ||
}), | ||
path: '/alerts', | ||
}, | ||
], | ||
premium: [ | ||
{ | ||
id: 'anomalies', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.anomalies', { | ||
defaultMessage: 'Anomalies', | ||
}), | ||
path: '/anomalies', | ||
}, | ||
], | ||
}, | ||
network: { | ||
base: [ | ||
{ | ||
id: 'dns', | ||
title: i18n.translate('xpack.securitySolution.search.network.dns', { | ||
defaultMessage: 'DNS', | ||
}), | ||
path: '/dns', | ||
}, | ||
{ | ||
id: 'http', | ||
title: i18n.translate('xpack.securitySolution.search.network.http', { | ||
defaultMessage: 'HTTP', | ||
}), | ||
path: '/http', | ||
}, | ||
{ | ||
id: 'tls', | ||
title: i18n.translate('xpack.securitySolution.search.network.tls', { | ||
defaultMessage: 'TLS', | ||
}), | ||
path: '/tls', | ||
}, | ||
{ | ||
id: 'externalAlertsNetwork', | ||
title: i18n.translate('xpack.securitySolution.search.network.externalAlerts', { | ||
defaultMessage: 'External Alerts', | ||
}), | ||
path: '/external-alerts', | ||
}, | ||
], | ||
premium: [ | ||
{ | ||
id: 'anomalies', | ||
title: i18n.translate('xpack.securitySolution.search.hosts.anomalies', { | ||
defaultMessage: 'Anomalies', | ||
}), | ||
path: '/anomalies', | ||
}, | ||
], | ||
}, | ||
timelines: { | ||
base: [ | ||
{ | ||
id: 'timelineTemplates', | ||
title: i18n.translate('xpack.securitySolution.search.timeline.templates', { | ||
defaultMessage: 'Templates', | ||
}), | ||
path: '/template', | ||
}, | ||
], | ||
}, | ||
overview: { | ||
base: [], | ||
}, | ||
case: { | ||
base: [], | ||
premium: [ | ||
{ | ||
id: 'configure', | ||
title: i18n.translate('xpack.securitySolution.search.cases.configure', { | ||
defaultMessage: 'Configure Cases', | ||
}), | ||
path: '/configure', | ||
}, | ||
], | ||
}, | ||
administration: { | ||
base: [ | ||
{ | ||
id: 'trustApplications', | ||
title: i18n.translate('xpack.securitySolution.search.administration.trustedApps', { | ||
defaultMessage: 'Trusted Applications', | ||
}), | ||
path: '/trusted_apps', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const subpluginKeywords: { [key in SecuritySubPluginNames]: string[] } = { | ||
detections: [ | ||
i18n.translate('xpack.securitySolution.search.detections', { | ||
defaultMessage: 'Detections', | ||
}), | ||
], | ||
hosts: [ | ||
i18n.translate('xpack.securitySolution.search.hosts', { | ||
defaultMessage: 'Hosts', | ||
}), | ||
], | ||
network: [ | ||
i18n.translate('xpack.securitySolution.search.network', { | ||
defaultMessage: 'Network', | ||
}), | ||
], | ||
timelines: [ | ||
i18n.translate('xpack.securitySolution.search.timelines', { | ||
defaultMessage: 'Timelines', | ||
}), | ||
], | ||
overview: [ | ||
i18n.translate('xpack.securitySolution.search.overview', { | ||
defaultMessage: 'Overview', | ||
}), | ||
], | ||
case: [ | ||
i18n.translate('xpack.securitySolution.search.cases', { | ||
defaultMessage: 'Cases', | ||
}), | ||
], | ||
administration: [ | ||
i18n.translate('xpack.securitySolution.search.administration', { | ||
defaultMessage: 'Endpoint Administration', | ||
}), | ||
], | ||
}; | ||
|
||
/** | ||
* A function that generates a subPlugin's meta tag | ||
* @param subPluginName SubPluginName of the app to retrieve meta information for. | ||
* @param licenseType optional string for license level, if not provided basic is assumed. | ||
*/ | ||
export function getSearchDeepLinksAndKeywords( | ||
subPluginName: SecuritySubPluginNames, | ||
licenseType?: LicenseType | ||
): AppMeta { | ||
const baseRoutes = [...securityDeepLinks[subPluginName].base]; | ||
if ( | ||
licenseType === 'gold' || | ||
licenseType === 'platinum' || | ||
licenseType === 'enterprise' || | ||
licenseType === 'trial' | ||
) { | ||
const premiumRoutes = | ||
securityDeepLinks[subPluginName] && securityDeepLinks[subPluginName].premium; | ||
if (premiumRoutes !== undefined) { | ||
return { | ||
keywords: subpluginKeywords[subPluginName], | ||
searchDeepLinks: [...baseRoutes, ...premiumRoutes], | ||
}; | ||
} | ||
} | ||
return { | ||
keywords: subpluginKeywords[subPluginName], | ||
searchDeepLinks: baseRoutes, | ||
}; | ||
} | ||
/** | ||
* A function that updates a subplugin's meta property as appropriate when license level changes. | ||
* @param subPluginName SubPluginName of the app to register searchDeepLinks for | ||
* @param appUpdater an instance of appUpdater$ observable to update search links when needed. | ||
* @param licenseType A string representing the current license level. | ||
*/ | ||
export function registerSearchLinks( | ||
subPluginName: SecuritySubPluginNames, | ||
appUpdater?: Subject<AppUpdater>, | ||
licenseType?: LicenseType | ||
) { | ||
if (appUpdater !== undefined) { | ||
appUpdater.next(() => ({ | ||
meta: getSearchDeepLinksAndKeywords(subPluginName, licenseType), | ||
})); | ||
} | ||
} |
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.