From 04049609f8e07d9cd95b6be9f998b06627bf14bb Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Tue, 28 Jan 2020 13:01:24 -0500 Subject: [PATCH 01/16] Add lockfile symlinks check for correct path (#56043) Scanning tools may not be able to follow symlinks of symlinks. This adds an additional check to make sure the lockfile symlink points directly to the project root's lockfile. --- src/dev/run_check_lockfile_symlinks.js | 42 ++++++++++++++++++++++++-- x-pack/plugins/endpoint/yarn.lock | 2 +- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/dev/run_check_lockfile_symlinks.js b/src/dev/run_check_lockfile_symlinks.js index c1ba22d3a7a44f..e7fd7e8831405d 100644 --- a/src/dev/run_check_lockfile_symlinks.js +++ b/src/dev/run_check_lockfile_symlinks.js @@ -17,7 +17,7 @@ * under the License. */ -import { existsSync, lstatSync, readFileSync } from 'fs'; +import { existsSync, lstatSync, readFileSync, readlinkSync } from 'fs'; import globby from 'globby'; import { dirname } from 'path'; @@ -63,6 +63,7 @@ async function checkLockfileSymlinks(log, files) { await checkOnlyLockfileAtProjectRoot(filtered); await checkSuperfluousSymlinks(log, filtered); await checkMissingSymlinks(log, filtered); + await checkIncorrectSymlinks(log, filtered); } async function checkOnlyLockfileAtProjectRoot(files) { @@ -157,8 +158,9 @@ async function checkMissingSymlinks(log, files) { try { const json = JSON.parse(manifest); if (json.dependencies && Object.keys(json.dependencies).length) { + const correctSymlink = getCorrectSymlink(lockfilePath); log.warning( - `Manifest at '${path}' has dependencies, but did not find an adjacent 'yarn.lock' symlink.` + `Manifest at '${path}' has dependencies, but did not find an adjacent 'yarn.lock' symlink to '${correctSymlink}'.` ); errorPaths.push(`${parent}/yarn.lock`); } @@ -177,6 +179,42 @@ async function checkMissingSymlinks(log, files) { } } +async function checkIncorrectSymlinks(log, files) { + const errorPaths = []; + + files + .filter(file => matchesAnyGlob(file.getRelativePath(), LOCKFILE_GLOBS)) + .forEach(file => { + const path = file.getRelativePath(); + const stats = lstatSync(path); + if (!stats.isSymbolicLink()) { + return; + } + + const symlink = readlinkSync(path); + const correctSymlink = getCorrectSymlink(path); + if (symlink !== correctSymlink) { + log.warning( + `Symlink at '${path}' points to '${symlink}', but it should point to '${correctSymlink}'.` + ); + errorPaths.push(path); + } + }); + + if (errorPaths.length) { + throw createFailError( + `These symlinks do NOT point to the 'yarn.lock' file in the project root:\n${listPaths( + errorPaths + )}` + ); + } +} + +function getCorrectSymlink(path) { + const count = path.split('/').length - 1; + return `${'../'.repeat(count)}yarn.lock`; +} + function listPaths(paths) { return paths.map(path => ` - ${path}`).join('\n'); } diff --git a/x-pack/plugins/endpoint/yarn.lock b/x-pack/plugins/endpoint/yarn.lock index 3f82ebc9cdbae3..6e09764ec763b0 120000 --- a/x-pack/plugins/endpoint/yarn.lock +++ b/x-pack/plugins/endpoint/yarn.lock @@ -1 +1 @@ -../../yarn.lock \ No newline at end of file +../../../yarn.lock \ No newline at end of file From 5108eb378d3e08e58b72cebfb804998409b0fd6b Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 28 Jan 2020 11:14:28 -0700 Subject: [PATCH 02/16] [SIEM][Detection Engine] critical blocker bug fixes ancestor mapping ## Summary * Fixes critical bug with ancestor mapping being object and not correct mappings. Testing you should now be able to do operations and it will show up on KQL Screen Shot 2020-01-28 at 9 33 59 AM Screen Shot 2020-01-28 at 9 33 22 AM ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ~~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ --- .../routes/index/signals_mapping.json | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json index 4986c100f1b0b5..714b39d1557a16 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json @@ -23,7 +23,20 @@ } }, "ancestors": { - "type": "object" + "properties": { + "rule": { + "type": "keyword" + }, + "id": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "depth": { + "type": "long" + } + } }, "rule": { "properties": { From 54d40e36701fb4a06d13521d2c86c64c073d8261 Mon Sep 17 00:00:00 2001 From: cachedout Date: Tue, 28 Jan 2020 18:28:45 +0000 Subject: [PATCH 03/16] =?UTF-8?q?[Stack=20Monitoring]=20Prefer=20units=20i?= =?UTF-8?q?f=20they=20are=20defined=20when=20rende=E2=80=A6=20(#43709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Prefer units if they are defined when rendering cells * Jest snapshot update * Lint recommendations Co-authored-by: Elastic Machine --- .../nodes/__tests__/__snapshots__/cells.test.js.snap | 4 ++-- .../public/components/elasticsearch/nodes/cells.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/__snapshots__/cells.test.js.snap b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/__snapshots__/cells.test.js.snap index 789e2a5756b48a..c7081dc439085c 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/__snapshots__/cells.test.js.snap +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/__snapshots__/cells.test.js.snap @@ -28,12 +28,12 @@ exports[`Node Listing Metric Cell should format a non-percentage metric 1`] = `
- 206.5 GB max + 206.5 GB max
- 206.3 GB min + 206.3 GB min
diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/cells.js b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/cells.js index fe925b337a31c6..c5407864e8f81c 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/cells.js +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/cells.js @@ -21,11 +21,11 @@ const getSlopeArrow = slope => { return null; }; -const metricVal = (metric, format, isPercent) => { +const metricVal = (metric, format, isPercent, units) => { if (isPercent) { return formatMetric(metric, format, '%', { prependSpace: false }); } - return formatMetric(metric, format); + return formatMetric(metric, format, units); }; const noWrapStyle = { overflowX: 'hidden', whiteSpace: 'nowrap' }; @@ -34,6 +34,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) { if (isOnline) { const { lastVal, maxVal, minVal, slope } = get(metric, 'summary', {}); const format = get(metric, 'metric.format'); + const units = get(metric, 'metric.units'); return ( @@ -49,7 +50,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) { {i18n.translate('xpack.monitoring.elasticsearch.nodes.cells.maxText', { defaultMessage: '{metric} max', values: { - metric: metricVal(maxVal, format, isPercent), + metric: metricVal(maxVal, format, isPercent, units), }, })} @@ -57,7 +58,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) { {i18n.translate('xpack.monitoring.elasticsearch.nodes.cells.minText', { defaultMessage: '{metric} min', values: { - metric: metricVal(minVal, format, isPercent), + metric: metricVal(minVal, format, isPercent, units), }, })} From f97bc898bb827a9c98f7ccb280f2b2e6d01c904b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Tue, 28 Jan 2020 13:33:43 -0500 Subject: [PATCH 04/16] Migrate UI capabilities to use new platform APIs (#56070) --- .../np_ready/public/application/app.tsx | 8 +- .../np_ready/public/application/home.tsx | 7 +- .../action_connector_form.test.tsx | 27 +++-- .../action_connector_form.tsx | 9 +- .../action_type_menu.test.tsx | 27 +++-- .../connector_add_flyout.test.tsx | 27 +++-- .../connector_edit_flyout.test.tsx | 27 +++-- .../actions_connectors_list.test.tsx | 108 ++++++++++-------- .../components/actions_connectors_list.tsx | 10 +- .../components/alerts_list.test.tsx | 108 ++++++++++-------- .../alerts_list/components/alerts_list.tsx | 11 +- .../components/collapsed_item_actions.tsx | 9 +- .../np_ready/public/plugin.ts | 25 ++-- .../np_ready/public/types.ts | 2 - .../triggers_actions_ui/public/legacy.ts | 2 - 15 files changed, 215 insertions(+), 192 deletions(-) diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx index 3ad6b5b7c697de..57e6fc4a9e18b1 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx @@ -11,6 +11,7 @@ import { ToastsSetup, HttpSetup, IUiSettingsClient, + ApplicationStart, } from 'kibana/public'; import { BASE_PATH, Section } from './constants'; import { TriggersActionsUIHome } from './home'; @@ -27,6 +28,7 @@ export interface AppDeps { http: HttpSetup; uiSettings: IUiSettingsClient; legacy: LegacyDependencies; + capabilities: ApplicationStart['capabilities']; actionTypeRegistry: TypeRegistry; alertTypeRegistry: TypeRegistry; } @@ -46,10 +48,8 @@ export const App = (appDeps: AppDeps) => { }; export const AppWithoutRouter = ({ sectionsRegex }: any) => { - const { - legacy: { capabilities }, - } = useAppDependencies(); - const canShowAlerts = hasShowAlertsCapability(capabilities.get()); + const { capabilities } = useAppDependencies(); + const canShowAlerts = hasShowAlertsCapability(capabilities); const DEFAULT_SECTION: Section = canShowAlerts ? 'alerts' : 'connectors'; return ( diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/home.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/home.tsx index 3312f1a103b29a..5d518bce569e44 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/home.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/home.tsx @@ -39,11 +39,12 @@ export const TriggersActionsUIHome: React.FunctionComponent { const { chrome, - legacy: { MANAGEMENT_BREADCRUMB, capabilities }, + capabilities, + legacy: { MANAGEMENT_BREADCRUMB }, } = useAppDependencies(); - const canShowActions = hasShowActionsCapability(capabilities.get()); - const canShowAlerts = hasShowAlertsCapability(capabilities.get()); + const canShowActions = hasShowActionsCapability(capabilities); + const canShowAlerts = hasShowAlertsCapability(capabilities); const tabs: Array<{ id: Section; name: React.ReactNode; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx index c129ce73c7176e..6896ac954bb068 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx @@ -20,7 +20,13 @@ describe('action_connector_form', () => { beforeAll(async () => { const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -28,18 +34,15 @@ describe('action_connector_form', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + actions: { + delete: true, + save: true, + show: true, + }, + }, legacy: { - capabilities: { - get() { - return { - actions: { - delete: true, - save: true, - show: true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx index 682c1fbb54b67e..852e713b38ed74 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx @@ -39,15 +39,10 @@ export const ActionConnectorForm = ({ actionTypeName, setFlyoutVisibility, }: ActionConnectorProps) => { - const { - http, - toastNotifications, - legacy: { capabilities }, - actionTypeRegistry, - } = useAppDependencies(); + const { http, toastNotifications, capabilities, actionTypeRegistry } = useAppDependencies(); const { reloadConnectors } = useActionsConnectorsContext(); - const canSave = hasSaveActionsCapability(capabilities.get()); + const canSave = hasSaveActionsCapability(capabilities); // hooks const [{ connector }, dispatch] = useReducer(connectorReducer, { connector: initialConnector }); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.test.tsx index a9e2afb0617207..6ef2f62315d9a4 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.test.tsx @@ -18,7 +18,13 @@ describe('connector_add_flyout', () => { beforeAll(async () => { const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); deps = { chrome, docLinks, @@ -26,18 +32,15 @@ describe('connector_add_flyout', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + actions: { + delete: true, + save: true, + show: true, + }, + }, legacy: { - capabilities: { - get() { - return { - actions: { - delete: true, - save: true, - show: true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx index 5095cc140f9c98..71ba52f047d617 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx @@ -20,7 +20,13 @@ describe('connector_add_flyout', () => { beforeAll(async () => { const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -28,18 +34,15 @@ describe('connector_add_flyout', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + actions: { + delete: true, + save: true, + show: true, + }, + }, legacy: { - capabilities: { - get() { - return { - actions: { - delete: true, - save: true, - show: true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx index d01539d7232fae..57e950a98eb2ae 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx @@ -17,7 +17,13 @@ let deps: any; describe('connector_edit_flyout', () => { beforeAll(async () => { const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); deps = { chrome, docLinks, @@ -25,18 +31,15 @@ describe('connector_edit_flyout', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + actions: { + delete: true, + save: true, + show: true, + }, + }, legacy: { - capabilities: { - get() { - return { - actions: { - delete: true, - save: true, - show: true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx index 511deb8cf3b0d7..da502fb86521bd 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx @@ -42,7 +42,13 @@ describe('actions_connectors_list component empty', () => { }, ]); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -50,18 +56,15 @@ describe('actions_connectors_list component empty', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'actions:show': true, + 'actions:save': true, + 'actions:delete': true, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'actions:show': true, - 'actions:save': true, - 'actions:delete': true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, @@ -136,7 +139,13 @@ describe('actions_connectors_list component with items', () => { ]); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -144,18 +153,15 @@ describe('actions_connectors_list component with items', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'actions:show': true, + 'actions:save': true, + 'actions:delete': true, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'actions:show': true, - 'actions:save': true, - 'actions:delete': true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: { @@ -217,7 +223,13 @@ describe('actions_connectors_list component empty with show only capability', () }, ]); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -225,18 +237,15 @@ describe('actions_connectors_list component empty with show only capability', () injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'actions:show': true, + 'actions:save': false, + 'actions:delete': false, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'actions:show': true, - 'actions:save': false, - 'actions:delete': false, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: { @@ -303,7 +312,13 @@ describe('actions_connectors_list with show only capability', () => { }, ]); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -311,18 +326,15 @@ describe('actions_connectors_list with show only capability', () => { injectedMetadata: mockes.injectedMetadata, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'actions:show': true, + 'actions:save': false, + 'actions:delete': false, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'actions:show': true, - 'actions:save': false, - 'actions:delete': false, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx index 1990ffefdf84e2..e98c3b2c08749d 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx @@ -26,13 +26,9 @@ import { hasDeleteActionsCapability, hasSaveActionsCapability } from '../../../l import { DeleteConnectorsModal } from '../../../components/delete_connectors_modal'; export const ActionsConnectorsList: React.FunctionComponent = () => { - const { - http, - toastNotifications, - legacy: { capabilities }, - } = useAppDependencies(); - const canDelete = hasDeleteActionsCapability(capabilities.get()); - const canSave = hasSaveActionsCapability(capabilities.get()); + const { http, toastNotifications, capabilities } = useAppDependencies(); + const canDelete = hasDeleteActionsCapability(capabilities); + const canSave = hasSaveActionsCapability(capabilities); const [actionTypesIndex, setActionTypesIndex] = useState(undefined); const [actions, setActions] = useState([]); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx index 9f77bfb3f8760f..ff1510ea873d3b 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx @@ -70,7 +70,13 @@ describe('alerts_list component empty', () => { }); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -84,18 +90,15 @@ describe('alerts_list component empty', () => { } as any, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'alerting:show': true, + 'alerting:save': true, + 'alerting:delete': true, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'alerting:show': true, - 'alerting:save': true, - 'alerting:delete': true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, @@ -193,7 +196,13 @@ describe('alerts_list component with items', () => { data: [], }); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -207,18 +216,15 @@ describe('alerts_list component with items', () => { } as any, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'alerting:show': true, + 'alerting:save': true, + 'alerting:delete': true, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'alerting:show': true, - 'alerting:save': true, - 'alerting:delete': true, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, @@ -277,7 +283,13 @@ describe('alerts_list component empty with show only capability', () => { data: [], }); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -291,18 +303,15 @@ describe('alerts_list component empty with show only capability', () => { } as any, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'alerting:show': true, + 'alerting:save': false, + 'alerting:delete': false, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'alerting:show': true, - 'alerting:save': false, - 'alerting:delete': false, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: { @@ -396,7 +405,13 @@ describe('alerts_list with show only capability', () => { data: [], }); const mockes = coreMock.createSetup(); - const [{ chrome, docLinks }] = await mockes.getStartServices(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); const deps = { chrome, docLinks, @@ -410,18 +425,15 @@ describe('alerts_list with show only capability', () => { } as any, http: mockes.http, uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'alerting:show': true, + 'alerting:save': false, + 'alerting:delete': false, + }, + }, legacy: { - capabilities: { - get() { - return { - siem: { - 'alerting:show': true, - 'alerting:save': false, - 'alerting:delete': false, - }, - }; - }, - } as any, MANAGEMENT_BREADCRUMB: { set: () => {} } as any, }, actionTypeRegistry: actionTypeRegistry as any, diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx index 4b5e0d1948bfb6..12122983161bd8 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx @@ -43,14 +43,9 @@ interface AlertState { } export const AlertsList: React.FunctionComponent = () => { - const { - http, - injectedMetadata, - toastNotifications, - legacy: { capabilities }, - } = useAppDependencies(); - const canDelete = hasDeleteAlertsCapability(capabilities.get()); - const canSave = hasSaveAlertsCapability(capabilities.get()); + const { http, injectedMetadata, toastNotifications, capabilities } = useAppDependencies(); + const canDelete = hasDeleteAlertsCapability(capabilities); + const canSave = hasSaveAlertsCapability(capabilities); const createAlertUiEnabled = injectedMetadata.getInjectedVar('createAlertUiEnabled'); const [actionTypes, setActionTypes] = useState([]); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/collapsed_item_actions.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/collapsed_item_actions.tsx index dc6fb15f0f2366..aa1c6dd7c5b9ac 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/collapsed_item_actions.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/collapsed_item_actions.tsx @@ -36,13 +36,10 @@ export const CollapsedItemActions: React.FunctionComponent = ({ item, onAlertChanged, }: ComponentOpts) => { - const { - http, - legacy: { capabilities }, - } = useAppDependencies(); + const { http, capabilities } = useAppDependencies(); - const canDelete = hasDeleteAlertsCapability(capabilities.get()); - const canSave = hasSaveAlertsCapability(capabilities.get()); + const canDelete = hasDeleteAlertsCapability(capabilities); + const canSave = hasSaveAlertsCapability(capabilities); const [isPopoverOpen, setIsPopoverOpen] = useState(false); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/plugin.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/plugin.ts index 0b0f8a4ee67907..00dd2f51feaee3 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/plugin.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/plugin.ts @@ -42,12 +42,6 @@ export class Plugin implements CorePlugin { { application, notifications, http, uiSettings, injectedMetadata }: CoreSetup, { __LEGACY }: LegacyPlugins ): Setup { - const canShowActions = hasShowActionsCapability(__LEGACY.capabilities.get()); - const canShowAlerts = hasShowAlertsCapability(__LEGACY.capabilities.get()); - - if (!canShowActions && !canShowAlerts) { - return; - } registerBuiltInActionTypes({ actionTypeRegistry: this.actionTypeRegistry, }); @@ -61,6 +55,7 @@ export class Plugin implements CorePlugin { mount: async ( { core: { + application: applicationStart, docLinks, chrome, // Waiting for types to be updated. @@ -71,6 +66,16 @@ export class Plugin implements CorePlugin { }, { element } ) => { + const { capabilities } = applicationStart; + + const canShowActions = hasShowActionsCapability(capabilities); + const canShowAlerts = hasShowAlertsCapability(capabilities); + + if (!canShowActions && !canShowAlerts) { + // Render nothing + return () => {}; + } + const { boot } = await import('./application/boot'); return boot({ element, @@ -85,6 +90,7 @@ export class Plugin implements CorePlugin { legacy: { ...__LEGACY, }, + capabilities, actionTypeRegistry: this.actionTypeRegistry, alertTypeRegistry: this.alertTypeRegistry, }); @@ -93,9 +99,10 @@ export class Plugin implements CorePlugin { } public start(core: CoreStart, { __LEGACY }: LegacyPlugins) { - const { capabilities } = __LEGACY; - const canShowActions = hasShowActionsCapability(capabilities.get()); - const canShowAlerts = hasShowAlertsCapability(capabilities.get()); + const { capabilities } = core.application; + + const canShowActions = hasShowActionsCapability(capabilities); + const canShowAlerts = hasShowAlertsCapability(capabilities); // Don't register routes when user doesn't have access to the application if (!canShowActions && !canShowAlerts) { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts index 7a8a0ead5e8c51..ed63ade903104c 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts @@ -3,7 +3,6 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { capabilities } from 'ui/capabilities'; import { TypeRegistry } from './application/type_registry'; import { SanitizedAlert as Alert } from '../../../alerting/common'; export { SanitizedAlert as Alert, AlertAction } from '../../../alerting/common'; @@ -94,5 +93,4 @@ export interface IErrorObject { export interface LegacyDependencies { MANAGEMENT_BREADCRUMB: { text: string; href?: string }; - capabilities: typeof capabilities; } diff --git a/x-pack/legacy/plugins/triggers_actions_ui/public/legacy.ts b/x-pack/legacy/plugins/triggers_actions_ui/public/legacy.ts index bae91040812671..95cac99630fb41 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/public/legacy.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/public/legacy.ts @@ -67,7 +67,6 @@ routes.when(`${BASE_PATH}:section?/:subsection?/:view?/:id?`, { ...(npSetup.plugins as typeof npSetup.plugins), __LEGACY: { MANAGEMENT_BREADCRUMB, - capabilities, }, }); @@ -75,7 +74,6 @@ routes.when(`${BASE_PATH}:section?/:subsection?/:view?/:id?`, { ...(npSetup.plugins as typeof npSetup.plugins), __LEGACY: { MANAGEMENT_BREADCRUMB, - capabilities, }, }); From febb8405709a952609a65b27fe4709968bb60428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Tue, 28 Jan 2020 13:35:39 -0500 Subject: [PATCH 05/16] Remove alerts and actions from feature catalogue (#56140) --- .../plugins/triggers_actions_ui/index.ts | 1 - .../public/hacks/register.ts | 25 ------------------- 2 files changed, 26 deletions(-) delete mode 100644 x-pack/legacy/plugins/triggers_actions_ui/public/hacks/register.ts diff --git a/x-pack/legacy/plugins/triggers_actions_ui/index.ts b/x-pack/legacy/plugins/triggers_actions_ui/index.ts index c6ac3649a14775..19930363d30bf9 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/index.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/index.ts @@ -29,7 +29,6 @@ export function triggersActionsUI(kibana: any) { .default(); }, uiExports: { - home: ['plugins/triggers_actions_ui/hacks/register'], managementSections: ['plugins/triggers_actions_ui/legacy'], styleSheetPaths: resolve(__dirname, 'public/index.scss'), injectDefaultVars(server: Legacy.Server) { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/public/hacks/register.ts b/x-pack/legacy/plugins/triggers_actions_ui/public/hacks/register.ts deleted file mode 100644 index 7991604fcc6674..00000000000000 --- a/x-pack/legacy/plugins/triggers_actions_ui/public/hacks/register.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; -import { - FeatureCatalogueRegistryProvider, - FeatureCatalogueCategory, -} from 'ui/registry/feature_catalogue'; - -FeatureCatalogueRegistryProvider.register(() => { - return { - id: 'triggersActions', - title: 'Alerts and Actions', // This is a product name so we don't translate it. - description: i18n.translate('xpack.triggersActionsUI.triggersActionsDescription', { - defaultMessage: 'Data by creating, managing, and monitoring triggers and actions.', - }), - icon: 'triggersActionsApp', - path: '/app/kibana#/management/kibana/triggersActions', - showOnHomePage: true, - category: FeatureCatalogueCategory.ADMIN, - }; -}); From 06acf2f42ad71f14cd233d3bdeb31f8a1be96115 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 28 Jan 2020 19:57:44 +0100 Subject: [PATCH 06/16] add owners for es_archiver (#56184) --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ba468c5a2d9896..eff8c58a48b0d4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -87,6 +87,7 @@ /src/dev/ @elastic/kibana-operations /src/setup_node_env/ @elastic/kibana-operations /src/optimize/ @elastic/kibana-operations +/src/es_archiver/ @elastic/kibana-operations /packages/*eslint*/ @elastic/kibana-operations /packages/*babel*/ @elastic/kibana-operations /packages/kbn-dev-utils*/ @elastic/kibana-operations @@ -112,6 +113,7 @@ /src/legacy/server/logging/ @elastic/kibana-platform /src/legacy/server/saved_objects/ @elastic/kibana-platform /src/legacy/server/status/ @elastic/kibana-platform +/src/dev/run_check_core_api_changes.ts @elastic/kibana-platform # Security /src/core/server/csp/ @elastic/kibana-security @elastic/kibana-platform From bd08eb7efcd0df87581d91b6c69e270f4fe5670d Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Tue, 28 Jan 2020 14:05:23 -0500 Subject: [PATCH 07/16] Revert "[Monitoring] Change all configs to `monitoring.*`" (#56214) This reverts commit 04ad88cd77d077d71d4ec75182850681c862344e. --- .../config/deprecation/core_deprecations.ts | 50 ---------- x-pack/legacy/plugins/monitoring/config.js | 96 +++++++++---------- x-pack/legacy/plugins/monitoring/index.js | 34 +++---- .../cluster_alerts/alerts_cluster_search.js | 2 +- .../verify_monitoring_license.js | 2 +- .../es_client/__tests__/instantiate_client.js | 6 +- .../parse_elasticsearch_config.test.ts | 4 +- .../es_client/parse_elasticsearch_config.ts | 2 +- .../server/init_monitoring_xpack_info.js | 2 +- .../__tests__/get_default_admin_email.js | 12 ++- .../collectors/get_settings_collector.js | 4 +- .../collectors/ops_buffer/ops_buffer.js | 2 +- .../server/kibana_monitoring/init.js | 2 +- .../server/lib/__tests__/ccs_utils.js | 8 +- .../monitoring/server/lib/apm/get_apms.js | 2 +- .../server/lib/apm/get_apms_for_clusters.js | 2 +- .../monitoring/server/lib/apm/get_stats.js | 2 +- .../monitoring/server/lib/beats/get_beats.js | 2 +- .../lib/beats/get_beats_for_clusters.js | 2 +- .../server/lib/beats/get_latest_stats.js | 2 +- .../monitoring/server/lib/beats/get_stats.js | 2 +- .../monitoring/server/lib/ccs_utils.js | 2 +- .../server/lib/cluster/get_clusters_stats.js | 2 +- .../lib/details/__test__/get_metrics.test.js | 2 +- .../server/lib/details/get_metrics.js | 2 +- .../server/lib/elasticsearch/get_ml_jobs.js | 2 +- .../lib/elasticsearch/indices/get_indices.js | 2 +- .../nodes/get_nodes/get_nodes.js | 6 +- .../nodes/get_nodes/get_paginated_nodes.js | 4 +- .../get_indices_unassigned_shard_stats.js | 2 +- .../shards/get_nodes_shard_count.js | 2 +- .../shards/get_shard_allocation.js | 2 +- .../shards/get_shard_stat_aggs.js | 2 +- .../server/lib/kibana/get_kibanas.js | 2 +- .../lib/kibana/get_kibanas_for_clusters.js | 2 +- .../monitoring/server/lib/logs/get_logs.js | 2 +- .../lib/logstash/get_logstash_for_clusters.js | 6 +- .../server/lib/logstash/get_nodes.js | 2 +- .../lib/logstash/get_paginated_pipelines.js | 2 +- .../server/lib/logstash/get_pipeline.js | 2 +- .../get_pipeline_stats_aggregation.js | 2 +- .../lib/logstash/get_pipeline_versions.js | 2 +- .../lib/logstash/get_pipeline_vertex.js | 2 +- .../get_pipeline_vertex_stats_aggregation.js | 2 +- .../plugins/monitoring/server/plugin.js | 16 ++-- .../server/routes/api/v1/elasticsearch/ccr.js | 2 +- .../api/v1/elasticsearch/node_detail.js | 2 +- .../server/routes/api/v1/logstash/node.js | 4 +- .../pipelines/cluster_pipeline_ids.js | 2 +- .../telemetry_collection/get_cluster_uuids.ts | 2 +- .../telemetry_collection/get_es_stats.js | 2 +- .../get_high_level_stats.js | 2 +- .../legacy/plugins/monitoring/ui_exports.js | 2 +- 53 files changed, 144 insertions(+), 186 deletions(-) diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 3aa7f9e2aa8ad2..c63c9384da9d83 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -119,56 +119,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ renameFromRoot('xpack.telemetry.config', 'telemetry.config'), renameFromRoot('xpack.telemetry.banner', 'telemetry.banner'), renameFromRoot('xpack.telemetry.url', 'telemetry.url'), - // Monitoring renames - // TODO: Remove these from here once the monitoring plugin is migrated to NP - renameFromRoot('xpack.monitoring.enabled', 'monitoring.enabled'), - renameFromRoot('xpack.monitoring.ui.enabled', 'monitoring.ui.enabled'), - renameFromRoot( - 'xpack.monitoring.kibana.collection.enabled', - 'monitoring.kibana.collection.enabled' - ), - renameFromRoot('xpack.monitoring.max_bucket_size', 'monitoring.ui.max_bucket_size'), - renameFromRoot('xpack.monitoring.min_interval_seconds', 'monitoring.ui.min_interval_seconds'), - renameFromRoot( - 'xpack.monitoring.show_license_expiration', - 'monitoring.ui.show_license_expiration' - ), - renameFromRoot( - 'xpack.monitoring.ui.container.elasticsearch.enabled', - 'monitoring.ui.container.elasticsearch.enabled' - ), - renameFromRoot( - 'xpack.monitoring.ui.container.logstash.enabled', - 'monitoring.ui.container.logstash.enabled' - ), - renameFromRoot( - 'xpack.monitoring.tests.cloud_detector.enabled', - 'monitoring.tests.cloud_detector.enabled' - ), - renameFromRoot( - 'xpack.monitoring.kibana.collection.interval', - 'monitoring.kibana.collection.interval' - ), - renameFromRoot('xpack.monitoring.elasticsearch.hosts', 'monitoring.ui.elasticsearch.hosts'), - renameFromRoot('xpack.monitoring.elasticsearch.username', 'monitoring.ui.elasticsearch.username'), - renameFromRoot('xpack.monitoring.elasticsearch.password', 'monitoring.ui.elasticsearch.password'), - renameFromRoot( - 'xpack.monitoring.xpack_api_polling_frequency_millis', - 'monitoring.xpack_api_polling_frequency_millis' - ), - renameFromRoot( - 'xpack.monitoring.cluster_alerts.email_notifications.enabled', - 'monitoring.cluster_alerts.email_notifications.enabled' - ), - renameFromRoot( - 'xpack.monitoring.cluster_alerts.email_notifications.email_address', - 'monitoring.cluster_alerts.email_notifications.email_address' - ), - renameFromRoot('xpack.monitoring.ccs.enabled', 'monitoring.ui.ccs.enabled'), - renameFromRoot( - 'xpack.monitoring.elasticsearch.logFetchCount', - 'monitoring.ui.elasticsearch.logFetchCount' - ), configPathDeprecation, dataPathDeprecation, rewriteBasePathDeprecation, diff --git a/x-pack/legacy/plugins/monitoring/config.js b/x-pack/legacy/plugins/monitoring/config.js index 778b656c056f20..91c1ee99a0b2e4 100644 --- a/x-pack/legacy/plugins/monitoring/config.js +++ b/x-pack/legacy/plugins/monitoring/config.js @@ -15,12 +15,12 @@ export const config = Joi => { const DEFAULT_REQUEST_HEADERS = ['authorization']; return Joi.object({ + ccs: Joi.object({ + enabled: Joi.boolean().default(true), + }).default(), enabled: Joi.boolean().default(true), ui: Joi.object({ enabled: Joi.boolean().default(true), - ccs: Joi.object({ - enabled: Joi.boolean().default(true), - }).default(), container: Joi.object({ elasticsearch: Joi.object({ enabled: Joi.boolean().default(false), @@ -29,51 +29,6 @@ export const config = Joi => { enabled: Joi.boolean().default(false), }).default(), }).default(), - max_bucket_size: Joi.number().default(10000), - min_interval_seconds: Joi.number().default(10), - show_license_expiration: Joi.boolean().default(true), - elasticsearch: Joi.object({ - customHeaders: Joi.object().default({}), - logQueries: Joi.boolean().default(false), - requestHeadersWhitelist: Joi.array() - .items() - .single() - .default(DEFAULT_REQUEST_HEADERS), - sniffOnStart: Joi.boolean().default(false), - sniffInterval: Joi.number() - .allow(false) - .default(false), - sniffOnConnectionFault: Joi.boolean().default(false), - hosts: Joi.array() - .items(Joi.string().uri({ scheme: ['http', 'https'] })) - .single(), // if empty, use Kibana's connection config - username: Joi.string(), - password: Joi.string(), - requestTimeout: Joi.number().default(30000), - pingTimeout: Joi.number().default(30000), - ssl: Joi.object({ - verificationMode: Joi.string() - .valid('none', 'certificate', 'full') - .default('full'), - certificateAuthorities: Joi.array() - .single() - .items(Joi.string()), - certificate: Joi.string(), - key: Joi.string(), - keyPassphrase: Joi.string(), - keystore: Joi.object({ - path: Joi.string(), - password: Joi.string(), - }).default(), - truststore: Joi.object({ - path: Joi.string(), - password: Joi.string(), - }).default(), - alwaysPresentCertificate: Joi.boolean().default(false), - }).default(), - apiVersion: Joi.string().default('master'), - logFetchCount: Joi.number().default(10), - }).default(), }).default(), kibana: Joi.object({ collection: Joi.object({ @@ -91,11 +46,56 @@ export const config = Joi => { xpack_api_polling_frequency_millis: Joi.number().default( XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS ), + max_bucket_size: Joi.number().default(10000), + min_interval_seconds: Joi.number().default(10), + show_license_expiration: Joi.boolean().default(true), agent: Joi.object({ interval: Joi.string() .regex(/[\d\.]+[yMwdhms]/) .default('10s'), }).default(), + elasticsearch: Joi.object({ + customHeaders: Joi.object().default({}), + logQueries: Joi.boolean().default(false), + requestHeadersWhitelist: Joi.array() + .items() + .single() + .default(DEFAULT_REQUEST_HEADERS), + sniffOnStart: Joi.boolean().default(false), + sniffInterval: Joi.number() + .allow(false) + .default(false), + sniffOnConnectionFault: Joi.boolean().default(false), + hosts: Joi.array() + .items(Joi.string().uri({ scheme: ['http', 'https'] })) + .single(), // if empty, use Kibana's connection config + username: Joi.string(), + password: Joi.string(), + requestTimeout: Joi.number().default(30000), + pingTimeout: Joi.number().default(30000), + ssl: Joi.object({ + verificationMode: Joi.string() + .valid('none', 'certificate', 'full') + .default('full'), + certificateAuthorities: Joi.array() + .single() + .items(Joi.string()), + certificate: Joi.string(), + key: Joi.string(), + keyPassphrase: Joi.string(), + keystore: Joi.object({ + path: Joi.string(), + password: Joi.string(), + }).default(), + truststore: Joi.object({ + path: Joi.string(), + password: Joi.string(), + }).default(), + alwaysPresentCertificate: Joi.boolean().default(false), + }).default(), + apiVersion: Joi.string().default('master'), + logFetchCount: Joi.number().default(10), + }).default(), tests: Joi.object({ cloud_detector: Joi.object({ enabled: Joi.boolean().default(true), diff --git a/x-pack/legacy/plugins/monitoring/index.js b/x-pack/legacy/plugins/monitoring/index.js index ca595836133c2c..8e0201bea710bc 100644 --- a/x-pack/legacy/plugins/monitoring/index.js +++ b/x-pack/legacy/plugins/monitoring/index.js @@ -20,31 +20,31 @@ export const monitoring = kibana => new kibana.Plugin({ require: ['kibana', 'elasticsearch', 'xpack_main'], id: 'monitoring', - configPrefix: 'monitoring', + configPrefix: 'xpack.monitoring', publicDir: resolve(__dirname, 'public'), init(server) { const configs = [ - 'monitoring.ui.enabled', - 'monitoring.kibana.collection.enabled', - 'monitoring.ui.max_bucket_size', - 'monitoring.ui.min_interval_seconds', + 'xpack.monitoring.ui.enabled', + 'xpack.monitoring.kibana.collection.enabled', + 'xpack.monitoring.max_bucket_size', + 'xpack.monitoring.min_interval_seconds', 'kibana.index', - 'monitoring.ui.show_license_expiration', - 'monitoring.ui.container.elasticsearch.enabled', - 'monitoring.ui.container.logstash.enabled', - 'monitoring.tests.cloud_detector.enabled', - 'monitoring.kibana.collection.interval', - 'monitoring.ui.elasticsearch.hosts', - 'monitoring.ui.elasticsearch', - 'monitoring.xpack_api_polling_frequency_millis', + 'xpack.monitoring.show_license_expiration', + 'xpack.monitoring.ui.container.elasticsearch.enabled', + 'xpack.monitoring.ui.container.logstash.enabled', + 'xpack.monitoring.tests.cloud_detector.enabled', + 'xpack.monitoring.kibana.collection.interval', + 'xpack.monitoring.elasticsearch.hosts', + 'xpack.monitoring.elasticsearch', + 'xpack.monitoring.xpack_api_polling_frequency_millis', 'server.uuid', 'server.name', 'server.host', 'server.port', - 'monitoring.cluster_alerts.email_notifications.enabled', - 'monitoring.cluster_alerts.email_notifications.email_address', - 'monitoring.ui.ccs.enabled', - 'monitoring.ui.elasticsearch.logFetchCount', + 'xpack.monitoring.cluster_alerts.email_notifications.enabled', + 'xpack.monitoring.cluster_alerts.email_notifications.email_address', + 'xpack.monitoring.ccs.enabled', + 'xpack.monitoring.elasticsearch.logFetchCount', ]; const serverConfig = server.config(); diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js index eff9875d794adf..0c9fb4bd04ee77 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js @@ -157,7 +157,7 @@ export function alertsClusterSearch(req, alertsIndex, cluster, checkLicense, opt if (prodLicenseInfo.clusterAlerts.enabled) { const config = req.server.config(); - const size = options.size || config.get('monitoring.ui.max_bucket_size'); + const size = options.size || config.get('xpack.monitoring.max_bucket_size'); const params = { index: alertsIndex, diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js index e94f4e08fbdb18..9cc67e11c28d57 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js @@ -19,7 +19,7 @@ export function verifyMonitoringLicense(server) { const config = server.config(); // if cluster alerts are enabled, then ensure that we can use it according to the license - if (config.get('monitoring.cluster_alerts.enabled')) { + if (config.get('xpack.monitoring.cluster_alerts.enabled')) { const xpackInfo = get(server.plugins.monitoring, 'info'); if (xpackInfo) { const monitoringCluster = xpackInfo.feature('monitoring').getLicenseCheckResults(); diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js b/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js index 88cf9734d5f57d..6844bd5febf8ee 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js +++ b/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js @@ -11,8 +11,8 @@ import { exposeClient, hasMonitoringCluster } from '../instantiate_client'; function getMockServerFromConnectionUrl(monitoringClusterUrl) { const server = { - monitoring: { - ui: { + xpack: { + monitoring: { elasticsearch: { hosts: monitoringClusterUrl ? [monitoringClusterUrl] : [], username: 'monitoring-user-internal-test', @@ -27,7 +27,7 @@ function getMockServerFromConnectionUrl(monitoringClusterUrl) { }; return { - elasticsearchConfig: server.monitoring.ui.elasticsearch, + elasticsearchConfig: server.xpack.monitoring.elasticsearch, elasticsearchPlugin: { getCluster: sinon .stub() diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts index 8d9b5335732c0c..c6f4e0fa685045 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts +++ b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts @@ -168,14 +168,14 @@ describe('throws when config is invalid', () => { it('throws if key and keystore.path are both specified', () => { const value = { ssl: { key: 'foo', keystore: { path: 'bar' } } }; expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot( - `"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"` + `"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"` ); }); it('throws if certificate and keystore.path are both specified', () => { const value = { ssl: { certificate: 'foo', keystore: { path: 'bar' } } }; expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot( - `"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"` + `"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"` ); }); }); diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts index 728b3433bf06c0..70e6235602b5b9 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts +++ b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts @@ -7,7 +7,7 @@ import { readFileSync } from 'fs'; import { readPkcs12Truststore, readPkcs12Keystore } from '../../../../../../src/core/utils'; -const KEY = 'monitoring.ui.elasticsearch'; +const KEY = 'xpack.monitoring.elasticsearch'; /* * Parse a config object's Elasticsearch configuration, reading any diff --git a/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js b/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js index ba07f512de896a..b43430ead23b0f 100644 --- a/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js +++ b/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js @@ -15,7 +15,7 @@ export const initMonitoringXpackInfo = async ({ config, xpackMainPlugin, expose, const xpackInfo = hasMonitoringCluster(config) ? xpackMainPlugin.createXPackInfo({ clusterSource: 'monitoring', - pollFrequencyInMillis: config.get('monitoring.xpack_api_polling_frequency_millis'), + pollFrequencyInMillis: config.get('xpack.monitoring.xpack_api_polling_frequency_millis'), }) : xpackMainPlugin.info; diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js index 10f52a82a830cf..96dc461c03fd30 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js @@ -14,10 +14,14 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { function setup({ enabled = true, adminEmail = null } = {}) { const config = { get: sinon.stub() }; - config.get.withArgs('monitoring.cluster_alerts.email_notifications.enabled').returns(enabled); + config.get + .withArgs('xpack.monitoring.cluster_alerts.email_notifications.enabled') + .returns(enabled); if (adminEmail) { - config.get.withArgs(`monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`).returns(adminEmail); + config.get + .withArgs(`xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`) + .returns(adminEmail); } config.get.withArgs('kibana.index').returns('.kibana'); @@ -27,7 +31,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { return config; } - describe('monitoring.cluster_alerts.email_notifications.enabled = false', () => { + describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = false', () => { it('returns null when email is defined', async () => { const config = setup({ enabled: false }); expect(await getDefaultAdminEmail(config)).to.be(null); @@ -39,7 +43,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { }); }); - describe('monitoring.cluster_alerts.email_notifications.enabled = true', () => { + describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = true', () => { it('returns value when email is defined', async () => { const config = setup({ adminEmail: 'hello@world' }); expect(await getDefaultAdminEmail(config)).to.be('hello@world'); diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js index f51e7d22a0c7cf..d0e1d32a2baa4c 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js @@ -11,11 +11,11 @@ import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY, KIBANA_SETTINGS_TYPE } from '../../. * If so, get email from kibana.yml */ export async function getDefaultAdminEmail(config) { - if (!config.get('monitoring.cluster_alerts.email_notifications.enabled')) { + if (!config.get('xpack.monitoring.cluster_alerts.email_notifications.enabled')) { return null; } - const emailAddressConfigKey = `monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`; + const emailAddressConfigKey = `xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`; const configuredEmailAddress = config.get(emailAddressConfigKey); return configuredEmailAddress || null; diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js index 699a364433b3e8..d58f6f3254c762 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js @@ -17,7 +17,7 @@ export function opsBuffer({ config, log, getOSInfo }) { // determine the cloud service in the background const cloudDetector = new CloudDetector(); - if (config.get('monitoring.tests.cloud_detector.enabled')) { + if (config.get('xpack.monitoring.tests.cloud_detector.enabled')) { cloudDetector.detectCloudService(); } diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js index 3c02e2be58dec3..bf79ddc2109029 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js @@ -16,7 +16,7 @@ import { BulkUploader } from './bulk_uploader'; * @param {Object} server HapiJS server instance */ export function initBulkUploader({ config, ...params }) { - const interval = config.get('monitoring.kibana.collection.interval'); + const interval = config.get('xpack.monitoring.kibana.collection.interval'); return new BulkUploader({ interval, config, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js b/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js index 2d310962238fd4..844dfc96bb19b9 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js @@ -17,7 +17,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('monitoring.ui.ccs.enabled').returns(false); + get.withArgs('xpack.monitoring.ccs.enabled').returns(false); // falsy string values should be ignored const allPattern = prefixIndexPattern(config, indexPattern, '*'); @@ -32,7 +32,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('monitoring.ui.ccs.enabled').returns(true); + get.withArgs('xpack.monitoring.ccs.enabled').returns(true); // falsy string values should be ignored const undefinedPattern = prefixIndexPattern(config, indexPattern); @@ -49,7 +49,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('monitoring.ui.ccs.enabled').returns(true); + get.withArgs('xpack.monitoring.ccs.enabled').returns(true); const abcPattern = prefixIndexPattern(config, indexPattern, 'aBc'); const underscorePattern = prefixIndexPattern(config, indexPattern, 'cluster_one'); @@ -67,7 +67,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('monitoring.ui.ccs.enabled').returns(true); + get.withArgs('xpack.monitoring.ccs.enabled').returns(true); const pattern = prefixIndexPattern(config, indexPattern, '*'); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js index 40070a6b0d0f24..ef8db59620f1a5 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js @@ -84,7 +84,7 @@ export async function getApms(req, apmIndexPattern, clusterUuid) { const params = { index: apmIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), // FIXME + size: config.get('xpack.monitoring.max_bucket_size'), // FIXME ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js index a24936dc0f8320..95ccb81f696be1 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js @@ -35,7 +35,7 @@ export function getApmsForClusters(req, apmIndexPattern, clusters) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const config = req.server.config(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); return Promise.all( clusters.map(async cluster => { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js index bfaec4f8a12949..54a0609d945de2 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js @@ -28,7 +28,7 @@ export async function getStats(req, apmIndexPattern, clusterUuid) { const config = req.server.config(); const start = moment.utc(req.payload.timeRange.min).valueOf(); const end = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const params = { index: apmIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js index ef878e48925570..5857ec32b22597 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js @@ -83,7 +83,7 @@ export async function getBeats(req, beatsIndexPattern, clusterUuid) { const params = { index: beatsIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), // FIXME + size: config.get('xpack.monitoring.max_bucket_size'), // FIXME ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js index 624abb894e5087..82a738755931d6 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js @@ -34,7 +34,7 @@ export function getBeatsForClusters(req, beatsIndexPattern, clusters) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const config = req.server.config(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); return Promise.all( clusters.map(async cluster => { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js index 1139489728dbfa..d326c84634e12d 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js @@ -71,7 +71,7 @@ export function getLatestStats(req, beatsIndexPattern, clusterUuid) { uuids: { terms: { field: 'beats_stats.beat.uuid', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, }, }, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js index 0f90750a293fb7..80851a8498c263 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js @@ -28,7 +28,7 @@ export async function getStats(req, beatsIndexPattern, clusterUuid) { const config = req.server.config(); const start = moment.utc(req.payload.timeRange.min).valueOf(); const end = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const params = { index: beatsIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js b/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js index 3409462156a077..5b3980d9619a8a 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js @@ -16,7 +16,7 @@ * @return {String} The index pattern with the {@code cluster} prefix appropriately prepended. */ export function prefixIndexPattern(config, indexPattern, ccs) { - const ccsEnabled = config.get('monitoring.ui.ccs.enabled'); + const ccsEnabled = config.get('xpack.monitoring.ccs.enabled'); if (!ccsEnabled || !ccs) { return indexPattern; diff --git a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js index 54dc58a374c2c8..c323cb381aaf24 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js @@ -46,7 +46,7 @@ function fetchClusterStats(req, esIndexPattern, clusterUuid) { const metric = ElasticsearchMetric.getMetricFields(); const params = { index: esIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, filterPath: [ 'hits.hits._index', diff --git a/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js b/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js index fbe6c8ec4cfa3e..b7c387e74ec968 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js @@ -20,7 +20,7 @@ function getMockReq(metricsBuckets = []) { get: sinon.stub(), }; - config.get.withArgs('monitoring.ui.min_interval_seconds').returns(10); + config.get.withArgs('xpack.monitoring.min_interval_seconds').returns(10); return { server: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js b/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js index 0c4736e91ea109..798a94abbe4849 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js @@ -28,7 +28,7 @@ export async function getMetrics( // TODO: Pass in req parameters as explicit function parameters let min = moment.utc(req.payload.timeRange.min).valueOf(); const max = moment.utc(req.payload.timeRange.max).valueOf(); - const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); + const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); const bucketSize = calculateTimeseriesInterval(min, max, minIntervalSeconds); const timezone = await getTimezone(req); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js index 8aef402f881e81..658ee96c1f0841 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js @@ -23,7 +23,7 @@ export function getMlJobs(req, esIndexPattern) { checkParam(esIndexPattern, 'esIndexPattern in getMlJobs'); const config = req.server.config(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const start = req.payload.timeRange.min; // no wrapping in moment :) const end = req.payload.timeRange.max; const clusterUuid = req.params.clusterUuid; diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js index 938a9b9d55e439..6fe8ccfd890432 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js @@ -97,7 +97,7 @@ export function getIndices(req, esIndexPattern, showSystemIndices = false, shard const params = { index: esIndexPattern, // TODO: composite aggregation - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js index c248ad743e0ec8..7581a325909712 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js @@ -44,7 +44,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n const min = start; const bucketSize = Math.max( - config.get('monitoring.ui.min_interval_seconds'), + config.get('xpack.monitoring.min_interval_seconds'), calculateAuto(100, duration).asSeconds() ); @@ -59,7 +59,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n const params = { index: esIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ @@ -78,7 +78,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n terms: { field: `source_node.uuid`, include: uuidsToInclude, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, aggs: { by_date: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js index e18d328e8725bb..51c61046e9cda2 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js @@ -38,7 +38,7 @@ export async function getPaginatedNodes( { clusterStats, nodesShardCount } ) { const config = req.server.config(); - const size = config.get('monitoring.ui.max_bucket_size'); + const size = config.get('xpack.monitoring.max_bucket_size'); const nodes = await getNodeIds(req, esIndexPattern, { clusterUuid }, size); // Add `isOnline` and shards from the cluster state and shard stats @@ -63,7 +63,7 @@ export async function getPaginatedNodes( const groupBy = { field: `source_node.uuid`, include: nodes.map(node => node.uuid), - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }; const metricSeriesData = await getMetrics( req, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js index c77bcc4f62e611..e8d484e7021f47 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js @@ -12,7 +12,7 @@ import { calculateIndicesTotals } from './calculate_shard_stat_indices_totals'; async function getUnassignedShardData(req, esIndexPattern, cluster) { const config = req.server.config(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const metric = ElasticsearchMetric.getMetricFields(); const params = { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js index 7823884dc749d4..c11bd4aead693f 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js @@ -11,7 +11,7 @@ import { ElasticsearchMetric } from '../../metrics'; async function getShardCountPerNode(req, esIndexPattern, cluster) { const config = req.server.config(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const metric = ElasticsearchMetric.getMetricFields(); const params = { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js index 40412c03b0ef9d..3be5650b7d3bc6 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js @@ -55,7 +55,7 @@ export function getShardAllocation( const metric = ElasticsearchMetric.getMetricFields(); const params = { index: esIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ type: 'shards', clusterUuid, metric, filters }), diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js index 8c4834e5d5e406..eddd50612cdb13 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js @@ -9,7 +9,7 @@ * @param {Boolean} includeNodes - whether to add the aggs for node shards */ export function getShardAggs(config, includeNodes, includeIndices) { - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const aggSize = 10; const indicesAgg = { terms: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js index c272c38f00d552..af6563bae682d5 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js @@ -31,7 +31,7 @@ export function getKibanas(req, kbnIndexPattern, { clusterUuid }) { const params = { index: kbnIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ diff --git a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js index e50e8bda3c907b..dbf1c41dcf4e54 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js @@ -49,7 +49,7 @@ export function getKibanasForClusters(req, kbnIndexPattern, clusters) { kibana_uuids: { terms: { field: 'kibana_stats.kibana.uuid', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, aggs: { latest_report: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js index b876e3ba05d703..7a20d7737c5e89 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js @@ -70,7 +70,7 @@ export async function getLogs( const params = { index: filebeatIndexPattern, - size: Math.min(50, config.get('monitoring.ui.elasticsearch.logFetchCount')), + size: Math.min(50, config.get('xpack.monitoring.elasticsearch.logFetchCount')), filterPath: [ 'hits.hits._source.message', 'hits.hits._source.log.level', diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js index 55baa3cf10b508..d0de2c3f5df3a1 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js @@ -60,7 +60,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { logstash_uuids: { terms: { field: 'logstash_stats.logstash.uuid', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, aggs: { latest_report: { @@ -119,7 +119,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { logstash_versions: { terms: { field: 'logstash_stats.logstash.version', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, }, pipelines_nested: { @@ -135,7 +135,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { queue_types: { terms: { field: 'logstash_stats.pipelines.queue.type', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, aggs: { num_pipelines: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js index 06696abdb031f0..93b70d7b79f0a1 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js @@ -31,7 +31,7 @@ export function getNodes(req, lsIndexPattern, { clusterUuid }) { const params = { index: lsIndexPattern, - size: config.get('monitoring.ui.max_bucket_size'), // FIXME + size: config.get('xpack.monitoring.max_bucket_size'), // FIXME ignoreUnavailable: true, body: { query: createQuery({ diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js index ffc7e9ce1d6c28..ef9ef90e8f3108 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js @@ -37,7 +37,7 @@ export async function getPaginatedPipelines( queryText ) { const config = req.server.config(); - const size = config.get('monitoring.ui.max_bucket_size'); + const size = config.get('xpack.monitoring.max_bucket_size'); const pipelines = await getLogstashPipelineIds( req, lsIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js index 35a4295de298bf..eeeffd74e91f76 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js @@ -111,7 +111,7 @@ export async function getPipeline(req, config, lsIndexPattern, clusterUuid, pipe }; // Determine metrics' timeseries interval based on version's timespan - const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); + const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); const timeseriesInterval = calculateTimeseriesInterval( version.firstSeen, version.lastSeen, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js index d9c03819b0098b..1858674a01b86e 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js @@ -171,7 +171,7 @@ export function getPipelineStatsAggregation( logstashIndexPattern, pipelineId, version, - config.get('monitoring.ui.max_bucket_size'), + config.get('xpack.monitoring.max_bucket_size'), callWithRequest, req ); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js index 7521389c379eae..7dfa8d4a163ce9 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js @@ -37,7 +37,7 @@ function fetchPipelineVersions(...args) { by_pipeline_hash: { terms: { field: 'logstash_stats.pipelines.hash', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), order: { 'path_to_root>first_seen': 'desc' }, }, aggs: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js index 134dd88b36ce64..49c2dff2d6080a 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js @@ -130,7 +130,7 @@ export async function getPipelineVertex( }; // Determine metrics' timeseries interval based on version's timespan - const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); + const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); const timeseriesInterval = calculateTimeseriesInterval( version.firstSeen, version.lastSeen, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js index 425ca5731926c6..c91182188b213e 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js @@ -216,7 +216,7 @@ export function getPipelineVertexStatsAggregation( version, vertexId, timeSeriesIntervalInSeconds, - config.get('monitoring.ui.max_bucket_size'), + config.get('xpack.monitoring.max_bucket_size'), callWithRequest, req ); diff --git a/x-pack/legacy/plugins/monitoring/server/plugin.js b/x-pack/legacy/plugins/monitoring/server/plugin.js index ef346e95ad0757..163bc43945be1c 100644 --- a/x-pack/legacy/plugins/monitoring/server/plugin.js +++ b/x-pack/legacy/plugins/monitoring/server/plugin.js @@ -48,7 +48,7 @@ export class Plugin { /* * End-user-facing services */ - const uiEnabled = config.get('monitoring.ui.enabled'); + const uiEnabled = config.get('xpack.monitoring.ui.enabled'); if (uiEnabled) { await instantiateClient({ @@ -98,7 +98,7 @@ export class Plugin { kbnServerStatus: kbnServer.status, kbnServerVersion: kbnServer.version, }); - const kibanaCollectionEnabled = config.get('monitoring.kibana.collection.enabled'); + const kibanaCollectionEnabled = config.get('xpack.monitoring.kibana.collection.enabled'); if (kibanaCollectionEnabled) { /* @@ -125,12 +125,14 @@ export class Plugin { core.injectUiAppVars('monitoring', () => { const config = core.config(); return { - maxBucketSize: config.get('monitoring.ui.max_bucket_size'), - minIntervalSeconds: config.get('monitoring.ui.min_interval_seconds'), + maxBucketSize: config.get('xpack.monitoring.max_bucket_size'), + minIntervalSeconds: config.get('xpack.monitoring.min_interval_seconds'), kbnIndex: config.get('kibana.index'), - showLicenseExpiration: config.get('monitoring.ui.show_license_expiration'), - showCgroupMetricsElasticsearch: config.get('monitoring.ui.container.elasticsearch.enabled'), - showCgroupMetricsLogstash: config.get('monitoring.ui.container.logstash.enabled'), // Note, not currently used, but see https://github.com/elastic/x-pack-kibana/issues/1559 part 2 + showLicenseExpiration: config.get('xpack.monitoring.show_license_expiration'), + showCgroupMetricsElasticsearch: config.get( + 'xpack.monitoring.ui.container.elasticsearch.enabled' + ), + showCgroupMetricsLogstash: config.get('xpack.monitoring.ui.container.logstash.enabled'), // Note, not currently used, but see https://github.com/elastic/x-pack-kibana/issues/1559 part 2 }; }); } diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js index fcdf4ad8a706c0..2d4bded9fc4c85 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js @@ -26,7 +26,7 @@ function getBucketScript(max, min) { function buildRequest(req, config, esIndexPattern) { const min = moment.utc(req.payload.timeRange.min).valueOf(); const max = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); + const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); const aggs = { ops_synced_max: { max: { diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js index 25ead723e3ddb8..10226d74ed0010 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js @@ -61,7 +61,7 @@ export function esNodeRoute(server) { metricSet = metricSetOverview; // set the cgroup option if needed const showCgroupMetricsElasticsearch = config.get( - 'monitoring.ui.container.elasticsearch.enabled' + 'xpack.monitoring.ui.container.elasticsearch.enabled' ); const metricCpu = metricSet.find(m => m.name === 'node_cpu_metric'); if (showCgroupMetricsElasticsearch) { diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js index bd3ae5f5c2679b..d5ce9d1686f8a8 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js @@ -60,7 +60,9 @@ export function logstashNodeRoute(server) { } else { metricSet = metricSetOverview; // set the cgroup option if needed - const showCgroupMetricsLogstash = config.get('monitoring.ui.container.logstash.enabled'); + const showCgroupMetricsLogstash = config.get( + 'xpack.monitoring.ui.container.logstash.enabled' + ); const metricCpu = metricSet.find(m => m.name === 'logstash_node_cpu_metric'); if (showCgroupMetricsLogstash) { metricCpu.keys = ['logstash_node_cgroup_quota_as_cpu_utilization']; diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js index 93330880babcc7..c5fd76487cca1d 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js @@ -36,7 +36,7 @@ export function logstashClusterPipelineIdsRoute(server) { const { ccs } = req.payload; const clusterUuid = req.params.clusterUuid; const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs); - const size = config.get('monitoring.ui.max_bucket_size'); + const size = config.get('xpack.monitoring.max_bucket_size'); try { const pipelines = await getLogstashPipelineIds(req, lsIndexPattern, { clusterUuid }, size); diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts index 4738ab5b8af83f..fc85cbe442ddff 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts @@ -40,7 +40,7 @@ export function fetchClusterUuids({ server, callCluster, start, end }: StatsColl cluster_uuids: { terms: { field: 'cluster_uuid', - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), }, }, }, diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js index 52d34258b5fa4d..8e5a59361e52f7 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js @@ -31,7 +31,7 @@ export function fetchElasticsearchStats(server, callCluster, clusterUuids) { const config = server.config(); const params = { index: INDEX_PATTERN_ELASTICSEARCH, - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), ignoreUnavailable: true, filterPath: [ 'hits.hits._source.cluster_uuid', diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js index b87f632308e4d6..2632a8f6e041df 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js @@ -217,7 +217,7 @@ export async function fetchHighLevelStats(server, callCluster, clusterUuids, sta const params = { index: getIndexPatternForStackProduct(product), - size: config.get('monitoring.ui.max_bucket_size'), + size: config.get('xpack.monitoring.max_bucket_size'), headers: { 'X-QUERY-SOURCE': TELEMETRY_QUERY_SOURCE, }, diff --git a/x-pack/legacy/plugins/monitoring/ui_exports.js b/x-pack/legacy/plugins/monitoring/ui_exports.js index 9251deb673bd11..2b5ea21a2bb452 100644 --- a/x-pack/legacy/plugins/monitoring/ui_exports.js +++ b/x-pack/legacy/plugins/monitoring/ui_exports.js @@ -32,7 +32,7 @@ export const getUiExports = () => ({ injectDefaultVars(server) { const config = server.config(); return { - monitoringUiEnabled: config.get('monitoring.ui.enabled'), + monitoringUiEnabled: config.get('xpack.monitoring.ui.enabled'), }; }, hacks: ['plugins/monitoring/hacks/toggle_app_link_in_nav'], From 265c079a8a41fa99eb84ba58a703ff2d6916a7ae Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Tue, 28 Jan 2020 12:30:55 -0700 Subject: [PATCH 08/16] [Reporting] Document the 8.0 breaking changes (#56187) --- docs/migration/migrate_8_0.asciidoc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/migration/migrate_8_0.asciidoc b/docs/migration/migrate_8_0.asciidoc index a36a93ce318253..df4d8a0b65ee7f 100644 --- a/docs/migration/migrate_8_0.asciidoc +++ b/docs/migration/migrate_8_0.asciidoc @@ -80,4 +80,15 @@ specified explicitly. *Impact:* Any workflow that involved manually clearing generated bundles will have to be updated with the new path. + +[float] +[[breaking_80_reporting_changes]] +=== Reporting changes + +[float] +==== Legacy job parameters are no longer supported +*Details:* POST URL snippets that were copied in Kibana 6.2 or below are no longer supported. These logs have +been deprecated with warnings that have been logged throughout 7.x. Please use Kibana UI to re-generate the +POST URL snippets if you depend on these for automated PDF reports. + // end::notable-breaking-changes[] From ff37dd1c25ed16ba3abd904cc0d3aa4d6dabca4a Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 28 Jan 2020 11:55:08 -0800 Subject: [PATCH 09/16] Sort server-side in SavedObject export (#55128) Signed-off-by: Tyler Smalley --- .../get_sorted_objects_for_export.test.ts | 79 +++++++++++++++++-- .../export/get_sorted_objects_for_export.ts | 19 +++-- 2 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts b/src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts index 9a3449b65a9412..fafa04447ddfea 100644 --- a/src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts +++ b/src/core/server/saved_objects/export/get_sorted_objects_for_export.test.ts @@ -108,8 +108,6 @@ describe('getSortedObjectsForExport()', () => { "namespace": undefined, "perPage": 500, "search": undefined, - "sortField": "_id", - "sortOrder": "asc", "type": Array [ "index-pattern", "search", @@ -256,8 +254,6 @@ describe('getSortedObjectsForExport()', () => { "namespace": undefined, "perPage": 500, "search": "foo", - "sortField": "_id", - "sortOrder": "asc", "type": Array [ "index-pattern", "search", @@ -345,8 +341,6 @@ describe('getSortedObjectsForExport()', () => { "namespace": "foo", "perPage": 500, "search": undefined, - "sortField": "_id", - "sortOrder": "asc", "type": Array [ "index-pattern", "search", @@ -399,6 +393,79 @@ describe('getSortedObjectsForExport()', () => { ).rejects.toThrowErrorMatchingInlineSnapshot(`"Can't export more than 1 objects"`); }); + test('sorts objects within type', async () => { + savedObjectsClient.find.mockResolvedValueOnce({ + total: 3, + per_page: 10000, + page: 1, + saved_objects: [ + { + id: '3', + type: 'index-pattern', + attributes: { + name: 'baz', + }, + references: [], + }, + { + id: '1', + type: 'index-pattern', + attributes: { + name: 'foo', + }, + references: [], + }, + { + id: '2', + type: 'index-pattern', + attributes: { + name: 'bar', + }, + references: [], + }, + ], + }); + const exportStream = await getSortedObjectsForExport({ + exportSizeLimit: 10000, + savedObjectsClient, + types: ['index-pattern'], + }); + const response = await readStreamToCompletion(exportStream); + expect(response).toMatchInlineSnapshot(` + Array [ + Object { + "attributes": Object { + "name": "foo", + }, + "id": "1", + "references": Array [], + "type": "index-pattern", + }, + Object { + "attributes": Object { + "name": "bar", + }, + "id": "2", + "references": Array [], + "type": "index-pattern", + }, + Object { + "attributes": Object { + "name": "baz", + }, + "id": "3", + "references": Array [], + "type": "index-pattern", + }, + Object { + "exportedCount": 3, + "missingRefCount": 0, + "missingReferences": Array [], + }, + ] + `); + }); + test('exports selected objects and sorts them', async () => { savedObjectsClient.bulkGet.mockResolvedValueOnce({ saved_objects: [ diff --git a/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts b/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts index e1a705a36db75a..a4dfacfd9e34f8 100644 --- a/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts +++ b/src/core/server/saved_objects/export/get_sorted_objects_for_export.ts @@ -19,7 +19,7 @@ import Boom from 'boom'; import { createListStream } from '../../../../legacy/utils/streams'; -import { SavedObjectsClientContract } from '../types'; +import { SavedObjectsClientContract, SavedObject } from '../types'; import { fetchNestedDependencies } from './inject_nested_depdendencies'; import { sortObjects } from './sort_objects'; @@ -105,15 +105,17 @@ async function fetchObjectsToExport({ const findResponse = await savedObjectsClient.find({ type: types, search, - sortField: '_id', - sortOrder: 'asc', perPage: exportSizeLimit, namespace, }); if (findResponse.total > exportSizeLimit) { throw Boom.badRequest(`Can't export more than ${exportSizeLimit} objects`); } - return findResponse.saved_objects; + + // sorts server-side by _id, since it's only available in fielddata + return findResponse.saved_objects.sort((a: SavedObject, b: SavedObject) => + a.id > b.id ? 1 : -1 + ); } else { throw Boom.badRequest('Either `type` or `objects` are required.'); } @@ -137,14 +139,17 @@ export async function getSortedObjectsForExport({ exportSizeLimit, namespace, }); - let exportedObjects = [...rootObjects]; + let exportedObjects = []; let missingReferences: SavedObjectsExportResultDetails['missingReferences'] = []; + if (includeReferencesDeep) { const fetchResult = await fetchNestedDependencies(rootObjects, savedObjectsClient, namespace); - exportedObjects = fetchResult.objects; + exportedObjects = sortObjects(fetchResult.objects); missingReferences = fetchResult.missingRefs; + } else { + exportedObjects = sortObjects(rootObjects); } - exportedObjects = sortObjects(exportedObjects); + const exportDetails: SavedObjectsExportResultDetails = { exportedCount: exportedObjects.length, missingRefCount: missingReferences.length, From 8360faf7bd960b246141a6f6e9b6f8d2afe2e3fc Mon Sep 17 00:00:00 2001 From: "Devin W. Hurley" Date: Tue, 28 Jan 2020 14:56:31 -0500 Subject: [PATCH 10/16] [SIEM] [Detection Engine] Timestamps for rules (#56197) * utilize createdAt and updatedAt from the alerting saved object * revert accidental change to test rule * updatedAt is not a part of savedObject attributes passed back from alerting, it's at the top level --- .../routes/__mocks__/request_responses.ts | 2 -- .../routes/rules/create_rules_bulk_route.ts | 4 ---- .../routes/rules/create_rules_route.ts | 4 ---- .../routes/rules/import_rules_route.ts | 2 -- .../lib/detection_engine/routes/rules/utils.ts | 4 ++-- .../lib/detection_engine/rules/create_rules.ts | 2 -- .../rules/install_prepacked_rules.ts | 2 -- .../lib/detection_engine/rules/update_rules.ts | 1 - .../signals/__mocks__/es_results.ts | 2 -- .../signals/build_bulk_body.test.ts | 8 ++++++++ .../signals/build_bulk_body.ts | 6 ++++++ .../signals/build_rule.test.ts | 6 ++++++ .../lib/detection_engine/signals/build_rule.ts | 8 ++++++-- .../signals/search_after_bulk_create.test.ts | 16 ++++++++++++++++ .../signals/search_after_bulk_create.ts | 8 ++++++++ .../signals/signal_rule_alert_type.ts | 6 ++++-- .../signals/single_bulk_create.test.ts | 10 ++++++++++ .../signals/single_bulk_create.ts | 18 +++++++++++++++++- .../siem/server/lib/detection_engine/types.ts | 8 ++------ 19 files changed, 85 insertions(+), 32 deletions(-) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts index d950d89eb22a68..eea25a1e89cc84 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -269,8 +269,6 @@ export const getResult = (): RuleAlertType => ({ alertTypeId: 'siem.signals', consumer: 'siem', params: { - createdAt: '2019-12-13T16:40:33.400Z', - updatedAt: '2019-12-13T16:40:33.400Z', description: 'Detecting root and admin users', ruleId: 'rule-1', index: ['auditbeat-*', 'filebeat-*', 'packetbeat-*', 'winlogbeat-*'], diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts index 68375043070f89..0ffa61e2e2bedf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts @@ -51,7 +51,6 @@ export const createCreateRulesBulkRoute = (server: ServerFacade): Hapi.ServerRou const rules = await Promise.all( request.payload.map(async payloadRule => { const { - created_at: createdAt, description, enabled, false_positives: falsePositives, @@ -73,7 +72,6 @@ export const createCreateRulesBulkRoute = (server: ServerFacade): Hapi.ServerRou threat, to, type, - updated_at: updatedAt, references, timeline_id: timelineId, timeline_title: timelineTitle, @@ -104,7 +102,6 @@ export const createCreateRulesBulkRoute = (server: ServerFacade): Hapi.ServerRou const createdRule = await createRules({ alertsClient, actionsClient, - createdAt, description, enabled, falsePositives, @@ -129,7 +126,6 @@ export const createCreateRulesBulkRoute = (server: ServerFacade): Hapi.ServerRou to, type, threat, - updatedAt, references, version, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts index c631ed8f784abc..ec1df238f94838 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts @@ -35,7 +35,6 @@ export const createCreateRulesRoute = (server: ServerFacade): Hapi.ServerRoute = }, async handler(request: RulesRequest, headers) { const { - created_at: createdAt, description, enabled, false_positives: falsePositives, @@ -59,7 +58,6 @@ export const createCreateRulesRoute = (server: ServerFacade): Hapi.ServerRoute = threat, to, type, - updated_at: updatedAt, references, } = request.payload; const alertsClient = isFunction(request.getAlertsClient) ? request.getAlertsClient() : null; @@ -91,7 +89,6 @@ export const createCreateRulesRoute = (server: ServerFacade): Hapi.ServerRoute = const createdRule = await createRules({ alertsClient, actionsClient, - createdAt, description, enabled, falsePositives, @@ -116,7 +113,6 @@ export const createCreateRulesRoute = (server: ServerFacade): Hapi.ServerRoute = to, type, threat, - updatedAt, references, version: 1, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts index 88a31c36a87fcf..71fdef3623bc71 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts @@ -130,7 +130,6 @@ export const createImportRulesRoute = (server: ServerFacade): Hapi.ServerRoute = const createdRule = await createRules({ alertsClient, actionsClient, - createdAt: new Date().toISOString(), description, enabled, falsePositives, @@ -155,7 +154,6 @@ export const createImportRulesRoute = (server: ServerFacade): Hapi.ServerRoute = to, type, threat, - updatedAt: new Date().toISOString(), references, version, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts index 663ddf3a835a60..b45db53c13d883 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts @@ -81,8 +81,8 @@ export const transformAlertToRule = ( ruleStatus?: SavedObject ): Partial => { return pickBy((value: unknown) => value != null, { - created_at: alert.params.createdAt, - updated_at: alert.params.updatedAt, + created_at: alert.createdAt.toISOString(), + updated_at: alert.updatedAt.toISOString(), created_by: alert.createdBy, description: alert.params.description, enabled: alert.enabled, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts index 30e8c4dbf9d88c..82fe16882882e5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts @@ -45,7 +45,6 @@ export const createRules = ({ alertTypeId: SIGNALS_ID, consumer: APP_ID, params: { - createdAt: new Date().toISOString(), description, ruleId, index, @@ -66,7 +65,6 @@ export const createRules = ({ threat, to, type, - updatedAt: new Date().toISOString(), references, version, }, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts index 7e8ed62baf1cff..07e8c6940e7476 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts @@ -75,8 +75,6 @@ export const installPrepackagedRules = ( threat, references, version, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), }), ]; }, []); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts index 8234b931ad89a1..304cd1962afed5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts @@ -164,7 +164,6 @@ export const updateRules = async ({ threat, to, type, - updatedAt: new Date().toISOString(), references, version: calculatedVersion, } diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts index 6507e6ca73edeb..fded0696ff8bf7 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts @@ -35,8 +35,6 @@ export const sampleRuleAlertParams = ( meta: undefined, threat: undefined, version: 1, - updatedAt: '2019-12-17T15:04:25.343Z', - createdAt: '2019-12-17T15:04:37.105Z', }); export const sampleDocNoSortId = (someUuid: string = sampleIdGuid): SignalSourceHit => ({ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts index de11bf6fcc3c15..b71a7080f41479 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts @@ -25,6 +25,8 @@ describe('buildBulkBody', () => { ruleParams: sampleParams, id: sampleRuleGuid, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -103,6 +105,8 @@ describe('buildBulkBody', () => { ruleParams: sampleParams, id: sampleRuleGuid, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -189,6 +193,8 @@ describe('buildBulkBody', () => { ruleParams: sampleParams, id: sampleRuleGuid, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -272,6 +278,8 @@ describe('buildBulkBody', () => { ruleParams: sampleParams, id: sampleRuleGuid, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts index 6d9f442515b2a3..e77755073b374b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts @@ -15,7 +15,9 @@ interface BuildBulkBodyParams { ruleParams: RuleTypeParams; id: string; name: string; + createdAt: string; createdBy: string; + updatedAt: string; updatedBy: string; interval: string; enabled: boolean; @@ -28,7 +30,9 @@ export const buildBulkBody = ({ ruleParams, id, name, + createdAt, createdBy, + updatedAt, updatedBy, interval, enabled, @@ -39,7 +43,9 @@ export const buildBulkBody = ({ id, name, enabled, + createdAt, createdBy, + updatedAt, updatedBy, interval, tags, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts index 451e493f3ed8ad..af0883f4ce6b5b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts @@ -31,6 +31,8 @@ describe('buildRule', () => { name: 'some-name', id: sampleRuleGuid, enabled: false, + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: 'some interval', @@ -85,6 +87,8 @@ describe('buildRule', () => { name: 'some-name', id: sampleRuleGuid, enabled: true, + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: 'some interval', @@ -128,6 +132,8 @@ describe('buildRule', () => { name: 'some-name', id: sampleRuleGuid, enabled: true, + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: 'some interval', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts index ba1b2f695156bc..70465bf1d9201b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts @@ -12,7 +12,9 @@ interface BuildRuleParams { name: string; id: string; enabled: boolean; + createdAt: string; createdBy: string; + updatedAt: string; updatedBy: string; interval: string; tags: string[]; @@ -23,7 +25,9 @@ export const buildRule = ({ name, id, enabled, + createdAt, createdBy, + updatedAt, updatedBy, interval, tags, @@ -58,7 +62,7 @@ export const buildRule = ({ updated_by: updatedBy, threat: ruleParams.threat, version: ruleParams.version, - created_at: ruleParams.createdAt, - updated_at: ruleParams.updatedAt, + created_at: createdAt, + updated_at: updatedAt, }); }; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts index 0644d5e467a5a0..bf7a97a29aef32 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts @@ -40,6 +40,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -93,6 +95,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -117,6 +121,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -148,6 +154,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -179,6 +187,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -212,6 +222,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -245,6 +257,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -280,6 +294,8 @@ describe('searchAfterAndBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts index fb314e62ba9439..8c8cef5dd36695 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts @@ -19,8 +19,10 @@ interface SearchAfterAndBulkCreateParams { id: string; signalsIndex: string; name: string; + createdAt: string; createdBy: string; updatedBy: string; + updatedAt: string; interval: string; enabled: boolean; pageSize: number; @@ -38,8 +40,10 @@ export const searchAfterAndBulkCreate = async ({ signalsIndex, filter, name, + createdAt, createdBy, updatedBy, + updatedAt, interval, enabled, pageSize, @@ -58,7 +62,9 @@ export const searchAfterAndBulkCreate = async ({ id, signalsIndex, name, + createdAt, createdBy, + updatedAt, updatedBy, interval, enabled, @@ -118,7 +124,9 @@ export const searchAfterAndBulkCreate = async ({ id, signalsIndex, name, + createdAt, createdBy, + updatedAt, updatedBy, interval, enabled, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts index 370ed652808499..cd28f348a27c34 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts @@ -35,7 +35,6 @@ export const signalRulesAlertType = ({ actionGroups: ['default'], validate: { params: schema.object({ - createdAt: schema.string(), description: schema.string(), falsePositives: schema.arrayOf(schema.string(), { defaultValue: [] }), from: schema.string(), @@ -56,7 +55,6 @@ export const signalRulesAlertType = ({ threat: schema.nullable(schema.arrayOf(schema.object({}, { allowUnknowns: true }))), to: schema.string(), type: schema.string(), - updatedAt: schema.string(), references: schema.arrayOf(schema.string(), { defaultValue: [] }), version: schema.number({ defaultValue: 1 }), }), @@ -121,7 +119,9 @@ export const signalRulesAlertType = ({ const tags: string[] = savedObject.attributes.tags; const createdBy: string = savedObject.attributes.createdBy; + const createdAt: string = savedObject.attributes.createdAt; const updatedBy: string = savedObject.attributes.updatedBy; + const updatedAt: string = savedObject.updated_at ?? ''; const interval: string = savedObject.attributes.schedule.interval; const enabled: boolean = savedObject.attributes.enabled; const gap = getGapBetweenRuns({ @@ -210,7 +210,9 @@ export const signalRulesAlertType = ({ filter: esFilter, name, createdBy, + createdAt, updatedBy, + updatedAt, interval, enabled, pageSize: searchAfterSize, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts index d5f11c91a2b7cd..09e2c6b4fd586a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts @@ -152,6 +152,8 @@ describe('singleBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -180,6 +182,8 @@ describe('singleBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -200,6 +204,8 @@ describe('singleBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -221,6 +227,8 @@ describe('singleBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', @@ -244,6 +252,8 @@ describe('singleBulkCreate', () => { id: sampleRuleGuid, signalsIndex: DEFAULT_SIGNALS_INDEX, name: 'rule-name', + createdAt: '2020-01-28T15:58:34.810Z', + updatedAt: '2020-01-28T15:59:14.004Z', createdBy: 'elastic', updatedBy: 'elastic', interval: '5m', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts index cb5de4c974927e..adc7919a09758a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts @@ -21,7 +21,9 @@ interface SingleBulkCreateParams { id: string; signalsIndex: string; name: string; + createdAt: string; createdBy: string; + updatedAt: string; updatedBy: string; interval: string; enabled: boolean; @@ -59,7 +61,9 @@ export const singleBulkCreate = async ({ id, signalsIndex, name, + createdAt, createdBy, + updatedAt, updatedBy, interval, enabled, @@ -91,7 +95,19 @@ export const singleBulkCreate = async ({ ), }, }, - buildBulkBody({ doc, ruleParams, id, name, createdBy, updatedBy, interval, enabled, tags }), + buildBulkBody({ + doc, + ruleParams, + id, + name, + createdAt, + createdBy, + updatedAt, + updatedBy, + interval, + enabled, + tags, + }), ]); const start = performance.now(); const response: BulkResponse = await services.callCluster('bulk', { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts index d1c9845dbbcfcc..e1069db98c8fc5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts @@ -22,7 +22,6 @@ export interface ThreatParams { } export interface RuleAlertParams { - createdAt: string; description: string; enabled: boolean; falsePositives: string[]; @@ -49,7 +48,6 @@ export interface RuleAlertParams { threat: ThreatParams[] | undefined | null; type: 'query' | 'saved_query'; version: number; - updatedAt: string; } export type RuleTypeParams = Omit; @@ -65,8 +63,6 @@ export type RuleAlertParamsRest = Omit< | 'timelineId' | 'timelineTitle' | 'outputIndex' - | 'updatedAt' - | 'createdAt' > & Omit< IRuleStatusAttributes, @@ -86,8 +82,8 @@ export type RuleAlertParamsRest = Omit< max_signals: RuleAlertParams['maxSignals']; risk_score: RuleAlertParams['riskScore']; output_index: RuleAlertParams['outputIndex']; - created_at: RuleAlertParams['createdAt']; - updated_at: RuleAlertParams['updatedAt']; + created_at: string; + updated_at: string; status?: IRuleStatusAttributes['status'] | undefined; status_date?: IRuleStatusAttributes['statusDate'] | undefined; last_failure_at?: IRuleStatusAttributes['lastFailureAt'] | undefined; From b8c81019a1d861fe3cd59777da2623df478a1f15 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 28 Jan 2020 15:13:07 -0500 Subject: [PATCH 11/16] Skip tests that depend on other skipped test --- .../visualize/feature_controls/visualize_security.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts index 5f8b3f38436f6c..bdcdc4b7cd3ec2 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts @@ -124,7 +124,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await savedQueryManagementComponent.closeSavedQueryManagementComponent(); }); - it('allow saving a currently loaded saved query as a new query via the saved query management component ', async () => { + // Depends on skipped test above + it.skip('allow saving a currently loaded saved query as a new query via the saved query management component ', async () => { await savedQueryManagementComponent.saveCurrentlyLoadedAsNewQuery( 'foo2', 'bar2', @@ -135,7 +136,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await savedQueryManagementComponent.closeSavedQueryManagementComponent(); }); - it('allow saving changes to a currently loaded query via the saved query management component', async () => { + // Depends on skipped test above + it.skip('allow saving changes to a currently loaded query via the saved query management component', async () => { await savedQueryManagementComponent.loadSavedQuery('foo2'); await queryBar.setQuery('response:404'); await savedQueryManagementComponent.updateCurrentlyLoadedQuery('bar2', false, false); @@ -145,7 +147,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(queryString).to.eql('response:404'); }); - it('allows deleting saved queries in the saved query management component ', async () => { + // Depends on skipped test above + it.skip('allows deleting saved queries in the saved query management component ', async () => { await savedQueryManagementComponent.deleteSavedQuery('foo2'); await savedQueryManagementComponent.savedQueryMissingOrFail('foo2'); }); From 597e7ea64b75b0a77b9968aa4fde0c8be0075546 Mon Sep 17 00:00:00 2001 From: Brandon Kobel Date: Tue, 28 Jan 2020 12:59:13 -0800 Subject: [PATCH 12/16] Consistent timeouts for the Space onPostAuth interceptor tests (#56158) * Consistent timeouts for the Space onPostAuth interceptor tests * Run 100 times * Revert "Run 100 times" This reverts commit 6054ac462e68643e453585e60b22d476d671f4a9. --- .../on_post_auth_interceptor.test.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts index c1f557f164ad65..776275715921be 100644 --- a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts +++ b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts @@ -32,6 +32,7 @@ import { securityMock } from '../../../../security/server/mocks'; describe('onPostAuthInterceptor', () => { let root: ReturnType; + jest.setTimeout(30000); const headers = { authorization: `Basic ${Buffer.from( @@ -41,7 +42,7 @@ describe('onPostAuthInterceptor', () => { beforeEach(async () => { root = kbnTestServer.createRoot(); - }, 30000); + }); afterEach(async () => await root.shutdown()); @@ -241,7 +242,7 @@ describe('onPostAuthInterceptor', () => { expect(response.status).toEqual(302); expect(response.header.location).toEqual(`/spaces/space_selector`); - }, 30000); + }); it('when accessing the kibana app it always allows the request to continue', async () => { const spaces = [ @@ -258,7 +259,7 @@ describe('onPostAuthInterceptor', () => { const { response } = await request('/s/a-space/app/kibana', spaces); expect(response.status).toEqual(200); - }, 30000); + }); it('allows the request to continue when accessing an API endpoint within a non-existent space', async () => { const spaces = [ @@ -274,7 +275,7 @@ describe('onPostAuthInterceptor', () => { const { response } = await request('/s/not-found/api/test/foo', spaces); expect(response.status).toEqual(200); - }, 30000); + }); }); describe('requests handled completely in the new platform', () => { @@ -293,7 +294,7 @@ describe('onPostAuthInterceptor', () => { expect(response.status).toEqual(302); expect(response.header.location).toEqual(`/spaces/space_selector`); - }, 30000); + }); it('allows the request to continue when accessing an API endpoint within a non-existent space', async () => { const spaces = [ @@ -309,7 +310,7 @@ describe('onPostAuthInterceptor', () => { const { response } = await request('/s/not-found/api/np_test/foo', spaces); expect(response.status).toEqual(200); - }, 30000); + }); }); it('handles space retrieval errors gracefully when requesting the root, responding with headers returned from ES', async () => { @@ -421,7 +422,7 @@ describe('onPostAuthInterceptor', () => { }), }) ); - }, 30000); + }); it('redirects to the "enter space" endpoint when accessing the root of a non-default space', async () => { const spaces = [ @@ -454,7 +455,7 @@ describe('onPostAuthInterceptor', () => { }), }) ); - }, 30000); + }); describe('with a single available space', () => { it('it redirects to the "enter space" endpoint within the context of the single Space when navigating to Kibana root', async () => { From 57f5d77a408d2ed613353ef08ec4b40bd7cde31a Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 28 Jan 2020 15:07:24 -0700 Subject: [PATCH 13/16] [SIEM][Detection Engine] critical blocker with the UI crashing ## Summary If you have filters which do not have a $app and state it blows up which isn't what we want to happen. This adds a function which default adds it on the UI if it does not exist Screen Shot 2020-01-28 at 10 07 39 AM Test: Post query with everything ```ts ./post_rule.sh ./rules/queries/query_with_everything.json ``` Then visit in the details section of the UI and it should no longer blow up. ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ - [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) --- .../description_step/index.test.tsx | 185 ++++++++++++++++++ .../components/description_step/index.tsx | 12 +- 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.test.tsx diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.test.tsx new file mode 100644 index 00000000000000..fab689f7d821f2 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.test.tsx @@ -0,0 +1,185 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { addFilterStateIfNotThere } from './'; + +import { esFilters } from '../../../../../../../../../../src/plugins/data/public'; + +describe('description_step', () => { + describe('addFilterStateIfNotThere', () => { + test('it does not change the state if it is global', () => { + const filters: esFilters.Filter[] = [ + { + $state: { + store: esFilters.FilterStateStore.GLOBAL_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + { + $state: { + store: esFilters.FilterStateStore.GLOBAL_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + ]; + const output = addFilterStateIfNotThere(filters); + const expected: esFilters.Filter[] = [ + { + $state: { + store: esFilters.FilterStateStore.GLOBAL_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + { + $state: { + store: esFilters.FilterStateStore.GLOBAL_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + ]; + expect(output).toEqual(expected); + }); + + test('it adds the state if it does not exist as local', () => { + const filters: esFilters.Filter[] = [ + { + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + { + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + ]; + const output = addFilterStateIfNotThere(filters); + const expected: esFilters.Filter[] = [ + { + $state: { + store: esFilters.FilterStateStore.APP_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + { + $state: { + store: esFilters.FilterStateStore.APP_STATE, + }, + meta: { + alias: null, + disabled: false, + key: 'event.category', + negate: false, + params: { + query: 'file', + }, + type: 'phrase', + }, + query: { + match_phrase: { + 'event.category': 'file', + }, + }, + }, + ]; + expect(output).toEqual(expected); + }); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx index f1d2609cde8fe5..96c98a67b76627 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx @@ -97,6 +97,16 @@ const buildListItems = ( [] ); +export const addFilterStateIfNotThere = (filters: esFilters.Filter[]): esFilters.Filter[] => { + return filters.map(filter => { + if (filter.$state == null) { + return { $state: { store: esFilters.FilterStateStore.APP_STATE }, ...filter }; + } else { + return filter; + } + }); +}; + const getDescriptionItem = ( field: string, label: string, @@ -105,7 +115,7 @@ const getDescriptionItem = ( indexPatterns?: IIndexPattern ): ListItems[] => { if (field === 'queryBar') { - const filters = get('queryBar.filters', value) as esFilters.Filter[]; + const filters = addFilterStateIfNotThere(get('queryBar.filters', value)); const query = get('queryBar.query', value) as Query; const savedId = get('queryBar.saved_id', value); return buildQueryBarDescription({ From 6826be2927abfa0b84455f258b1671a039ecf1e4 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Tue, 28 Jan 2020 23:10:15 +0100 Subject: [PATCH 14/16] [SIEM] Put the notice for rules in comment block (#56123) * Put the notice for rules in comment block This comment block marked by `@notice` is picked up by automation and included in the Kibana NOTICE.txt that we ship with the tar.gz. Follow up for #56090. --- NOTICE.txt | 34 ++++++++++++++++++ .../rules/prepackaged_rules/NOTICE.txt | 20 ----------- .../rules/prepackaged_rules/notice.ts | 36 +++++++++++++++++++ 3 files changed, 70 insertions(+), 20 deletions(-) delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/NOTICE.txt create mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts diff --git a/NOTICE.txt b/NOTICE.txt index 955c3127fa9559..e0c5d94eff6b3d 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -153,6 +153,40 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +--- +This product bundles rules based on https://github.com/BlueTeamLabs/sentinel-attack +which is available under a "MIT" license. The files based on this license are: + +- windows_defense_evasion_via_filter_manager.json +- windows_process_discovery_via_tasklist_command.json +- windows_priv_escalation_via_accessibility_features.json +- windows_persistence_via_application_shimming.json +- windows_execution_via_trusted_developer_utilities.json +- windows_execution_via_net_com_assemblies.json +- windows_execution_via_connection_manager.json + +MIT License + +Copyright (c) 2019 Edoardo Gerosa, Olaf Hartong + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + --- This product includes code that is adapted from mapbox-gl-js, which is available under a "BSD-3-Clause" license. diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/NOTICE.txt b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/NOTICE.txt deleted file mode 100644 index cd5f1cc6f886cf..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/NOTICE.txt +++ /dev/null @@ -1,20 +0,0 @@ -This product bundles rules based on https://github.com/BlueTeamLabs/sentinel-attack -which is available under a "MIT" license. The files based on this license are: - -- windows_defense_evasion_via_filter_manager.json -- windows_process_discovery_via_tasklist_command.json -- windows_priv_escalation_via_accessibility_features.json -- windows_persistence_via_application_shimming.json -- windows_execution_via_trusted_developer_utilities.json -- windows_execution_via_net_com_assemblies.json -- windows_execution_via_connection_manager.json - -MIT License - -Copyright (c) 2019 Edoardo Gerosa, Olaf Hartong - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts new file mode 100644 index 00000000000000..cd24d823b8cd62 --- /dev/null +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts @@ -0,0 +1,36 @@ +/* eslint-disable @kbn/eslint/require-license-header */ + +/* @notice + * This product bundles rules based on https://github.com/BlueTeamLabs/sentinel-attack + * which is available under a "MIT" license. The files based on this license are: + * + * - windows_defense_evasion_via_filter_manager.json + * - windows_process_discovery_via_tasklist_command.json + * - windows_priv_escalation_via_accessibility_features.json + * - windows_persistence_via_application_shimming.json + * - windows_execution_via_trusted_developer_utilities.json + * - windows_execution_via_net_com_assemblies.json + * - windows_execution_via_connection_manager.json + * + * MIT License + * + * Copyright (c) 2019 Edoardo Gerosa, Olaf Hartong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ From 76628cd3cdcab54e336c0db23ca183a5d0005b17 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Tue, 28 Jan 2020 16:46:11 -0600 Subject: [PATCH 15/16] [Metrics UI] Fixing title truncation in Metrics Explorer (#55917) Co-authored-by: Elastic Machine --- .../infra/public/components/metrics_explorer/chart.tsx | 4 ++-- x-pack/legacy/plugins/infra/public/index.scss | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx b/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx index 6153ebce5e0da8..f66ae867eef5af 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx +++ b/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx @@ -86,7 +86,7 @@ export const MetricsExplorerChart = ({ - + {title} @@ -159,7 +159,7 @@ export const MetricsExplorerChart = ({ }; const ChartTitle = euiStyled.div` - width: 100% + width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/x-pack/legacy/plugins/infra/public/index.scss b/x-pack/legacy/plugins/infra/public/index.scss index 4cef6d6baa9155..afee4ab8b03897 100644 --- a/x-pack/legacy/plugins/infra/public/index.scss +++ b/x-pack/legacy/plugins/infra/public/index.scss @@ -36,6 +36,12 @@ .infrastructureChart .echTooltip__label { overflow-x: hidden; - white-space: no-wrap; + white-space: nowrap; text-overflow: ellipsis; } + +.metricsExplorerTitleAnchor { + white-space: nowrap; + text-overflow: ellipsis; + display: inline; +} From fe037bb28e3347849cc6eff4a1c0fdfca831a181 Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> Date: Tue, 28 Jan 2020 17:47:42 -0500 Subject: [PATCH 16/16] [SIEM] Add link to endpoint app through reference.url (#56211) * add rule.reference * Fix Load more * Fix spacing * Fix loading on hist graph detections * add tooltip --- .../alerts_viewer/default_headers.ts | 1 + .../timeline/body/renderers/constants.tsx | 2 + .../body/renderers/formatted_field.tsx | 31 ++-- .../renderers/formatted_field_helpers.tsx | 155 ++++++++++++++++++ .../timeline/body/renderers/translations.ts | 7 + .../components/timeline/footer/index.test.tsx | 2 +- .../timeline/footer/translations.ts | 2 +- .../detection_engine/signals/use_query.tsx | 2 +- .../containers/timeline/index.gql_query.ts | 3 + .../siem/public/graphql/introspection.json | 27 +++ .../plugins/siem/public/graphql/types.ts | 18 +- .../components/signals/default_config.tsx | 16 +- .../detection_engine/rules/details/index.tsx | 12 +- .../public/utils/logo_endpoint/64_color.svg | 7 + .../siem/server/graphql/ecs/schema.gql.ts | 5 + .../plugins/siem/server/graphql/types.ts | 26 +++ .../siem/server/lib/ecs_fields/index.ts | 5 + 17 files changed, 287 insertions(+), 34 deletions(-) create mode 100644 x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field_helpers.tsx create mode 100644 x-pack/legacy/plugins/siem/public/utils/logo_endpoint/64_color.svg diff --git a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts index 936d43fff0b481..af9a5ab765571b 100644 --- a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts +++ b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts @@ -19,6 +19,7 @@ export const alertsHeaders: ColumnHeader[] = [ columnHeaderType: defaultColumnHeaderType, id: 'event.module', width: DEFAULT_COLUMN_MIN_WIDTH, + linkField: 'rule.reference', }, { columnHeaderType: defaultColumnHeaderType, diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/constants.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/constants.tsx index 0330fb458e3640..e8074c2f6f3813 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/constants.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/constants.tsx @@ -8,4 +8,6 @@ export const DATE_FIELD_TYPE = 'date'; export const HOST_NAME_FIELD_NAME = 'host.name'; export const IP_FIELD_TYPE = 'ip'; export const MESSAGE_FIELD_NAME = 'message'; +export const EVENT_MODULE_FIELD_NAME = 'event.module'; +export const RULE_REFERENCE_FIELD_NAME = 'rule.reference'; export const SIGNAL_RULE_NAME_FIELD_NAME = 'signal.rule.name'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.tsx index 010a328d2993dd..0f650d6386194b 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiLink } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; import { isNumber, isString, isEmpty } from 'lodash/fp'; import React from 'react'; @@ -15,7 +15,7 @@ import { getOrEmptyTagFromValue, getEmptyTagValue } from '../../../empty_value'; import { FormattedDate } from '../../../formatted_date'; import { FormattedIp } from '../../../formatted_ip'; import { HostDetailsLink } from '../../../links'; -import { getRuleDetailsUrl } from '../../../link_to/redirect_to_detection_engine'; + import { Port, PORT_NAMES } from '../../../port'; import { TruncatableText } from '../../../truncatable_text'; import { @@ -23,8 +23,11 @@ import { HOST_NAME_FIELD_NAME, IP_FIELD_TYPE, MESSAGE_FIELD_NAME, + EVENT_MODULE_FIELD_NAME, + RULE_REFERENCE_FIELD_NAME, SIGNAL_RULE_NAME_FIELD_NAME, } from './constants'; +import { renderRuleName, renderEventModule, renderRulReference } from './formatted_field_helpers'; // simple black-list to prevent dragging and dropping fields such as message name const columnNamesNotDraggable = [MESSAGE_FIELD_NAME]; @@ -88,6 +91,12 @@ const FormattedFieldValueComponent: React.FC<{ return ( ); + } else if (fieldName === SIGNAL_RULE_NAME_FIELD_NAME) { + return renderRuleName({ contextId, eventId, fieldName, linkValue, truncate, value }); + } else if (fieldName === EVENT_MODULE_FIELD_NAME) { + return renderEventModule({ contextId, eventId, fieldName, linkValue, truncate, value }); + } else if (fieldName === RULE_REFERENCE_FIELD_NAME) { + return renderRulReference({ contextId, eventId, fieldName, linkValue, truncate, value }); } else if (columnNamesNotDraggable.includes(fieldName)) { return truncate && !isEmpty(value) ? ( @@ -110,24 +119,6 @@ const FormattedFieldValueComponent: React.FC<{ ) : ( <>{value} ); - } else if (fieldName === SIGNAL_RULE_NAME_FIELD_NAME) { - const ruleName = `${value}`; - const ruleId = linkValue; - - return isString(value) && ruleName.length > 0 && ruleId != null ? ( - - - {value} - - - ) : ( - getEmptyTagValue() - ); } else { const contentValue = getOrEmptyTagFromValue(value); const content = truncate ? {contentValue} : contentValue; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field_helpers.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field_helpers.tsx new file mode 100644 index 00000000000000..dc21cf03d04458 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field_helpers.tsx @@ -0,0 +1,155 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiLink, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiToolTip } from '@elastic/eui'; +import { isString, isEmpty } from 'lodash/fp'; +import React from 'react'; + +import { DefaultDraggable } from '../../../draggables'; +import { getEmptyTagValue } from '../../../empty_value'; +import { getRuleDetailsUrl } from '../../../link_to/redirect_to_detection_engine'; +import { TruncatableText } from '../../../truncatable_text'; + +import { isUrlInvalid } from '../../../../pages/detection_engine/rules/components/step_about_rule/helpers'; +import endPointSvg from '../../../../utils/logo_endpoint/64_color.svg'; + +import * as i18n from './translations'; + +export const renderRuleName = ({ + contextId, + eventId, + fieldName, + linkValue, + truncate, + value, +}: { + contextId: string; + eventId: string; + fieldName: string; + linkValue: string | null | undefined; + truncate?: boolean; + value: string | number | null | undefined; +}) => { + const ruleName = `${value}`; + const ruleId = linkValue; + + const content = truncate ? {value} : value; + + return isString(value) && ruleName.length > 0 && ruleId != null ? ( + + {content} + + ) : ( + getEmptyTagValue() + ); +}; + +export const renderEventModule = ({ + contextId, + eventId, + fieldName, + linkValue, + truncate, + value, +}: { + contextId: string; + eventId: string; + fieldName: string; + linkValue: string | null | undefined; + truncate?: boolean; + value: string | number | null | undefined; +}) => { + const moduleName = `${value}`; + const endpointRefUrl = linkValue; + + const content = truncate ? {value} : value; + + return isString(value) && moduleName.length > 0 ? ( + + + + {content} + + + {endpointRefUrl != null && + !isEmpty(endpointRefUrl) && + !isUrlInvalid(endpointRefUrl) && + endpointRefUrl.includes('/alerts/') && ( + + +

{i18n.LINK_ELASTIC_ENDPOINT_SECURITY}

+

{endpointRefUrl}

+ + } + > + + + +
+
+ )} +
+ ) : ( + getEmptyTagValue() + ); +}; + +export const renderRulReference = ({ + contextId, + eventId, + fieldName, + linkValue, + truncate, + value, +}: { + contextId: string; + eventId: string; + fieldName: string; + linkValue: string | null | undefined; + truncate?: boolean; + value: string | number | null | undefined; +}) => { + const referenceUrlName = `${value}`; + + const content = truncate ? {value} : value; + + return isString(value) && referenceUrlName.length > 0 ? ( + + {!isUrlInvalid(referenceUrlName) && ( + + {content} + + )} + {isUrlInvalid(referenceUrlName) && <>{content}} + + ) : ( + getEmptyTagValue() + ); +}; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/translations.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/translations.ts index 2c3c3efdb29935..5bdeccbd0f4ba4 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/translations.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/translations.ts @@ -29,3 +29,10 @@ export const IN = i18n.translate('xpack.siem.auditd.inDescription', { export const NON_EXISTENT = i18n.translate('xpack.siem.auditd.nonExistentDescription', { defaultMessage: 'an unknown process', }); + +export const LINK_ELASTIC_ENDPOINT_SECURITY = i18n.translate( + 'xpack.siem.event.module.linkToElasticEndpointSecurityDescription', + { + defaultMessage: 'Open in Elastic Endpoint Security', + } +); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/footer/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/footer/index.test.tsx index b6ca4fe125c696..cbad2d42cf8af1 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/footer/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/footer/index.test.tsx @@ -121,7 +121,7 @@ describe('Footer Timeline Component', () => { .find('[data-test-subj="TimelineMoreButton"]') .dive() .text(); - expect(loadButton).toContain('Load More'); + expect(loadButton).toContain('Load more'); }); test('it does NOT render the loadMore button because there is nothing else to fetch', () => { diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/footer/translations.ts b/x-pack/legacy/plugins/siem/public/components/timeline/footer/translations.ts index 886866ce1b0c2b..814311d4e14de3 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/footer/translations.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/footer/translations.ts @@ -27,7 +27,7 @@ export const LOADING = i18n.translate('xpack.siem.footer.loadingLabel', { }); export const LOAD_MORE = i18n.translate('xpack.siem.footer.loadMoreLabel', { - defaultMessage: 'Load More', + defaultMessage: 'Load more', }); export const TOTAL_COUNT_OF_EVENTS = i18n.translate('xpack.siem.footer.totalCountOfEvents', { diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx index 3dc6bac07be341..45f191f4a6fe5e 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx @@ -45,10 +45,10 @@ export const useQuerySignals = ( useEffect(() => { let isSubscribed = true; const abortCtrl = new AbortController(); - setLoading(true); async function fetchData() { try { + setLoading(true); const signalResponse = await fetchQuerySignals({ query, signal: abortCtrl.signal, diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/index.gql_query.ts b/x-pack/legacy/plugins/siem/public/containers/timeline/index.gql_query.ts index 9bd580f8322303..c54238c5d86872 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/index.gql_query.ts +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/index.gql_query.ts @@ -134,6 +134,9 @@ export const timelineQuery = gql` name ip } + rule { + reference + } source { bytes ip diff --git a/x-pack/legacy/plugins/siem/public/graphql/introspection.json b/x-pack/legacy/plugins/siem/public/graphql/introspection.json index a9247403bf22c3..b356b67b75c7bb 100644 --- a/x-pack/legacy/plugins/siem/public/graphql/introspection.json +++ b/x-pack/legacy/plugins/siem/public/graphql/introspection.json @@ -3985,6 +3985,14 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "rule", + "description": "", + "args": [], + "type": { "kind": "OBJECT", "name": "RuleEcsField", "ofType": null }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "signal", "description": "", @@ -4743,6 +4751,25 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "RuleEcsField", + "description": "", + "fields": [ + { + "name": "reference", + "description": "", + "args": [], + "type": { "kind": "SCALAR", "name": "ToStringArray", "ofType": null }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "SignalField", diff --git a/x-pack/legacy/plugins/siem/public/graphql/types.ts b/x-pack/legacy/plugins/siem/public/graphql/types.ts index 6a24ffcc130204..0103713a8c8a2d 100644 --- a/x-pack/legacy/plugins/siem/public/graphql/types.ts +++ b/x-pack/legacy/plugins/siem/public/graphql/types.ts @@ -791,6 +791,8 @@ export interface Ecs { network?: Maybe; + rule?: Maybe; + signal?: Maybe; source?: Maybe; @@ -970,6 +972,10 @@ export interface NetworkEcsField { transport?: Maybe; } +export interface RuleEcsField { + reference?: Maybe; +} + export interface SignalField { rule?: Maybe; @@ -4456,6 +4462,8 @@ export namespace GetTimelineQuery { host: Maybe; + rule: Maybe; + source: Maybe<_Source>; destination: Maybe; @@ -4671,6 +4679,12 @@ export namespace GetTimelineQuery { ip: Maybe; }; + export type Rule = { + __typename?: 'RuleEcsField'; + + reference: Maybe; + }; + export type _Source = { __typename?: 'SourceEcsFields'; @@ -4792,10 +4806,10 @@ export namespace GetTimelineQuery { original_time: Maybe; - rule: Maybe; + rule: Maybe<_Rule>; }; - export type Rule = { + export type _Rule = { __typename?: 'RuleField'; id: Maybe; diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx index f5d138a3afcb8c..e6bbffa4fd9271 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx @@ -86,6 +86,11 @@ export const buildSignalsRuleIdFilter = (ruleId: string): esFilters.Filter[] => ]; export const signalsHeaders: ColumnHeader[] = [ + { + columnHeaderType: defaultColumnHeaderType, + id: '@timestamp', + width: DEFAULT_DATE_COLUMN_MIN_WIDTH, + }, { columnHeaderType: defaultColumnHeaderType, id: 'signal.rule.name', @@ -117,6 +122,12 @@ export const signalsHeaders: ColumnHeader[] = [ label: i18n.SIGNALS_HEADERS_RISK_SCORE, width: 120, }, + { + columnHeaderType: defaultColumnHeaderType, + id: 'event.module', + linkField: 'rule.reference', + width: DEFAULT_COLUMN_MIN_WIDTH, + }, { category: 'event', columnHeaderType: defaultColumnHeaderType, @@ -150,11 +161,6 @@ export const signalsHeaders: ColumnHeader[] = [ id: 'destination.ip', width: 140, }, - { - columnHeaderType: defaultColumnHeaderType, - id: '@timestamp', - width: DEFAULT_DATE_COLUMN_MIN_WIDTH, - }, ]; export const signalsDefaultModel: SubsetTimelineModel = { diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/details/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/details/index.tsx index 1914f967813a15..7b615d5f159c2d 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/details/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/details/index.tsx @@ -24,7 +24,11 @@ import { ActionCreator } from 'typescript-fsa'; import { connect } from 'react-redux'; import { FiltersGlobal } from '../../../../components/filters_global'; import { FormattedDate } from '../../../../components/formatted_date'; -import { DETECTION_ENGINE_PAGE_NAME } from '../../../../components/link_to/redirect_to_detection_engine'; +import { + getDetectionEngineUrl, + getEditRuleUrl, + getRulesUrl, +} from '../../../../components/link_to/redirect_to_detection_engine'; import { SiemSearchBar } from '../../../../components/search_bar'; import { WrapperPage } from '../../../../components/wrapper_page'; import { useRule } from '../../../../containers/detection_engine/rules'; @@ -237,7 +241,7 @@ const RuleDetailsPageComponent: FC = ({ isAuthenticated != null && (!isSignalIndexExists || !isAuthenticated) ) { - return ; + return ; } return ( @@ -257,7 +261,7 @@ const RuleDetailsPageComponent: FC = ({ = ({ diff --git a/x-pack/legacy/plugins/siem/public/utils/logo_endpoint/64_color.svg b/x-pack/legacy/plugins/siem/public/utils/logo_endpoint/64_color.svg new file mode 100644 index 00000000000000..b03007a76ffcc5 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/utils/logo_endpoint/64_color.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts b/x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts index 730e6b884a1825..f897236b3470e8 100644 --- a/x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts +++ b/x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts @@ -417,6 +417,10 @@ export const ecsSchema = gql` original_time: ToStringArray } + type RuleEcsField { + reference: ToStringArray + } + type ECS { _id: String! _index: String @@ -428,6 +432,7 @@ export const ecsSchema = gql` geo: GeoEcsFields host: HostEcsFields network: NetworkEcsField + rule: RuleEcsField signal: SignalField source: SourceEcsFields suricata: SuricataEcsFields diff --git a/x-pack/legacy/plugins/siem/server/graphql/types.ts b/x-pack/legacy/plugins/siem/server/graphql/types.ts index 303262ece5c7f1..c3fd6e9dde2865 100644 --- a/x-pack/legacy/plugins/siem/server/graphql/types.ts +++ b/x-pack/legacy/plugins/siem/server/graphql/types.ts @@ -793,6 +793,8 @@ export interface Ecs { network?: Maybe; + rule?: Maybe; + signal?: Maybe; source?: Maybe; @@ -972,6 +974,10 @@ export interface NetworkEcsField { transport?: Maybe; } +export interface RuleEcsField { + reference?: Maybe; +} + export interface SignalField { rule?: Maybe; @@ -4279,6 +4285,8 @@ export namespace EcsResolvers { network?: NetworkResolver, TypeParent, TContext>; + rule?: RuleResolver, TypeParent, TContext>; + signal?: SignalResolver, TypeParent, TContext>; source?: SourceResolver, TypeParent, TContext>; @@ -4358,6 +4366,11 @@ export namespace EcsResolvers { Parent = Ecs, TContext = SiemContext > = Resolver; + export type RuleResolver< + R = Maybe, + Parent = Ecs, + TContext = SiemContext + > = Resolver; export type SignalResolver< R = Maybe, Parent = Ecs, @@ -4935,6 +4948,18 @@ export namespace NetworkEcsFieldResolvers { > = Resolver; } +export namespace RuleEcsFieldResolvers { + export interface Resolvers { + reference?: ReferenceResolver, TypeParent, TContext>; + } + + export type ReferenceResolver< + R = Maybe, + Parent = RuleEcsField, + TContext = SiemContext + > = Resolver; +} + export namespace SignalFieldResolvers { export interface Resolvers { rule?: RuleResolver, TypeParent, TContext>; @@ -9231,6 +9256,7 @@ export type IResolvers = { EndgameEcsFields?: EndgameEcsFieldsResolvers.Resolvers; EventEcsFields?: EventEcsFieldsResolvers.Resolvers; NetworkEcsField?: NetworkEcsFieldResolvers.Resolvers; + RuleEcsField?: RuleEcsFieldResolvers.Resolvers; SignalField?: SignalFieldResolvers.Resolvers; RuleField?: RuleFieldResolvers.Resolvers; SuricataEcsFields?: SuricataEcsFieldsResolvers.Resolvers; diff --git a/x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts b/x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts index f85fb2c9fd7534..eb483de000915a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts +++ b/x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts @@ -318,6 +318,10 @@ export const signalFieldsMap: Readonly> = { 'signal.rule.version': 'signal.rule.version', }; +export const ruleFieldsMap: Readonly> = { + 'rule.reference': 'rule.reference', +}; + export const eventFieldsMap: Readonly> = { timestamp: '@timestamp', '@timestamp': '@timestamp', @@ -331,6 +335,7 @@ export const eventFieldsMap: Readonly> = { ...{ ...geoFieldsMap }, ...{ ...hostFieldsMap }, ...{ ...networkFieldsMap }, + ...{ ...ruleFieldsMap }, ...{ ...signalFieldsMap }, ...{ ...sourceFieldsMap }, ...{ ...suricataFieldsMap },