Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ingest-overview-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Harding committed Apr 17, 2020
2 parents 431b8a4 + dc9bfb5 commit 1719c35
Show file tree
Hide file tree
Showing 1,028 changed files with 1,148 additions and 1,009 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ module.exports = {
},
{
// typescript only for front and back end
files: ['x-pack/legacy/plugins/siem/**/*.{ts,tsx}'],
files: ['x-pack/{,legacy/}plugins/siem/**/*.{ts,tsx}'],
rules: {
// This will be turned on after bug fixes are complete
// '@typescript-eslint/explicit-member-accessibility': 'warn',
Expand Down Expand Up @@ -613,7 +613,7 @@ module.exports = {
// },
{
// typescript and javascript for front and back end
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
files: ['x-pack/{,legacy/}plugins/siem/**/*.{js,ts,tsx}'],
plugins: ['eslint-plugin-node', 'react'],
env: {
mocha: true,
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ kibanaPipeline(timeoutMinutes: 135, checkPrChanges: true) {
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'),
'xpack-siemCypress': { processNumber ->
whenChanged(['x-pack/legacy/plugins/siem/', 'x-pack/test/siem_cypress/']) {
whenChanged(['x-pack/plugins/siem/', 'x-pack/legacy/plugins/siem/', 'x-pack/test/siem_cypress/']) {
kibanaPipeline.functionalTestProcess('xpack-siemCypress', './test/scripts/jenkins_siem_cypress.sh')(processNumber)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe('OptimizerConfig::parseOptions()', () => {
<absolute path>/x-pack/plugins,
<absolute path>/plugins,
<absolute path>/examples,
<absolute path>/x-pack/examples,
<absolute path>-extra,
],
"profileWebpack": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/src/optimizer/optimizer_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export class OptimizerConfig {

/**
* BEWARE: this needs to stay roughly synchronized with
* `src/core/server/config/env.ts` which determins which paths
* `src/core/server/config/env.ts` which determines which paths
* should be searched for plugins to load
*/
const pluginScanDirs = options.pluginScanDirs || [
Path.resolve(repoRoot, 'src/plugins'),
...(oss ? [] : [Path.resolve(repoRoot, 'x-pack/plugins')]),
Path.resolve(repoRoot, 'plugins'),
...(examples ? [Path.resolve('examples')] : []),
...(examples ? [Path.resolve('examples'), Path.resolve('x-pack/examples')] : []),
Path.resolve(repoRoot, '../kibana-extra'),
];
if (!pluginScanDirs.every(p => Path.isAbsolute(p))) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cluster/cluster_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class ClusterManager {
...pluginInternalDirsIgnore,
fromRoot('src/legacy/server/sass/__tmp__'),
fromRoot('x-pack/legacy/plugins/reporting/.chromium'),
fromRoot('x-pack/legacy/plugins/siem/cypress'),
fromRoot('x-pack/plugins/siem/cypress'),
fromRoot('x-pack/legacy/plugins/apm/e2e'),
fromRoot('x-pack/legacy/plugins/apm/scripts'),
fromRoot('x-pack/legacy/plugins/canvas/canvas_plugin_src'), // prevents server from restarting twice for Canvas plugin changes,
Expand Down
22 changes: 22 additions & 0 deletions src/core/server/config/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ test('pluginSearchPaths contains examples plugins path if --run-examples flag is
expect(env.pluginSearchPaths).toContain('/some/home/dir/examples');
});

test('pluginSearchPaths contains x-pack/examples plugins path if --run-examples flag is true', () => {
const env = new Env(
'/some/home/dir',
getEnvOptions({
cliArgs: { runExamples: true },
})
);

expect(env.pluginSearchPaths).toContain('/some/home/dir/x-pack/examples');
});

test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => {
const env = new Env(
'/some/home/dir',
Expand All @@ -174,3 +185,14 @@ test('pluginSearchPaths does not contains examples plugins path if --run-example

expect(env.pluginSearchPaths).not.toContain('/some/home/dir/examples');
});

test('pluginSearchPaths does not contains x-pack/examples plugins path if --run-examples flag is false', () => {
const env = new Env(
'/some/home/dir',
getEnvOptions({
cliArgs: { runExamples: false },
})
);

expect(env.pluginSearchPaths).not.toContain('/some/home/dir/x-pack/examples');
});
4 changes: 3 additions & 1 deletion src/core/server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export class Env {
resolve(this.homeDir, 'src', 'plugins'),
...(options.cliArgs.oss ? [] : [resolve(this.homeDir, 'x-pack', 'plugins')]),
resolve(this.homeDir, 'plugins'),
...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []),
...(options.cliArgs.runExamples
? [resolve(this.homeDir, 'examples'), resolve(this.homeDir, 'x-pack', 'examples')]
: []),
resolve(this.homeDir, '..', 'kibana-extra'),
];

Expand Down
2 changes: 1 addition & 1 deletion src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export const storybookAliases = {
drilldowns: 'x-pack/plugins/drilldowns/scripts/storybook.js',
embeddable: 'src/plugins/embeddable/scripts/storybook.js',
infra: 'x-pack/legacy/plugins/infra/scripts/storybook.js',
siem: 'x-pack/legacy/plugins/siem/scripts/storybook.js',
siem: 'x-pack/plugins/siem/scripts/storybook.js',
ui_actions: 'x-pack/plugins/advanced_ui_actions/scripts/storybook.js',
};
5 changes: 4 additions & 1 deletion src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const PROJECTS = [
new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }),
new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }),
new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/siem/cypress/tsconfig.json'), {
new Project(resolve(REPO_ROOT, 'x-pack/plugins/siem/cypress/tsconfig.json'), {
name: 'siem/cypress',
}),
new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/apm/e2e/tsconfig.json'), {
Expand All @@ -44,6 +44,9 @@ export const PROJECTS = [
...glob
.sync('examples/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('x-pack/examples/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('test/plugin_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/server/logging/log_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { LogInterceptor } from './log_interceptor';
// thrown every time we start the server.
// In order to keep using the legacy logger until we remove it I'm just adding
// a new hard limit here.
process.stdout.setMaxListeners(15);
process.stdout.setMaxListeners(25);

export function getLoggerStream({ events, config }) {
const squeeze = new Squeeze(events);
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/jenkins_xpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [[ -z "$CODE_COVERAGE" ]] ; then

echo " -> Running SIEM cyclic dependency test"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "X-Pack SIEM cyclic dependency test" node legacy/plugins/siem/scripts/check_circular_deps
checks-reporter-with-killswitch "X-Pack SIEM cyclic dependency test" node plugins/siem/scripts/check_circular_deps
echo ""
echo ""

Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"xpack.searchProfiler": "plugins/searchprofiler",
"xpack.security": ["legacy/plugins/security", "plugins/security"],
"xpack.server": "legacy/server",
"xpack.siem": "legacy/plugins/siem",
"xpack.siem": ["plugins/siem", "legacy/plugins/siem"],
"xpack.snapshotRestore": "plugins/snapshot_restore",
"xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"],
"xpack.taskManager": "legacy/plugins/task_manager",
Expand Down
7 changes: 7 additions & 0 deletions x-pack/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Example plugins

This folder contains X-Pack example plugins. To run the plugins in this folder, use the `--run-examples` flag, via

```
yarn start --run-examples
```
3 changes: 3 additions & 0 deletions x-pack/examples/ui_actions_enhanced_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Ui actions enhanced examples

To run this example, use the command `yarn start --run-examples`.
10 changes: 10 additions & 0 deletions x-pack/examples/ui_actions_enhanced_examples/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "uiActionsEnhancedExamples",
"version": "0.0.1",
"kibanaVersion": "kibana",
"configPath": ["ui_actions_enhanced_examples"],
"server": false,
"ui": true,
"requiredPlugins": ["uiActions", "data"],
"optionalPlugins": []
}
17 changes: 17 additions & 0 deletions x-pack/examples/ui_actions_enhanced_examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ui_actions_enhanced_examples",
"version": "1.0.0",
"main": "target/examples/ui_actions_enhanced_examples",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
},
"license": "Apache-2.0",
"scripts": {
"kbn": "node ../../scripts/kbn.js",
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginInitializerContext } from '../../../../../src/core/server';
import { Plugin } from './plugin';
import { UiActionsEnhancedExamplesPlugin } from './plugin';

export const plugin = (context: PluginInitializerContext) => {
return new Plugin(context);
};
export const plugin = () => new UiActionsEnhancedExamplesPlugin();
31 changes: 31 additions & 0 deletions x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 { Plugin, CoreSetup, CoreStart } from '../../../../src/core/public';
import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public';
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public';

export interface SetupDependencies {
data: DataPublicPluginSetup;
uiActions: UiActionsSetup;
}

export interface StartDependencies {
data: DataPublicPluginStart;
uiActions: UiActionsStart;
}

export class UiActionsEnhancedExamplesPlugin
implements Plugin<void, void, SetupDependencies, StartDependencies> {
public setup(core: CoreSetup<StartDependencies>, plugins: SetupDependencies) {
// eslint-disable-next-line
console.log('ui_actions_enhanced_examples');
}

public start(core: CoreStart, plugins: StartDependencies) {}

public stop() {}
}
15 changes: 15 additions & 0 deletions x-pack/examples/ui_actions_enhanced_examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./target",
"skipLibCheck": true
},
"include": [
"index.ts",
"public/**/*.ts",
"public/**/*.tsx",
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
}
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/siem/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Auto-collapse generated files in GitHub
# https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github
x-pack/legacy/plugins/siem/public/graphql/types.ts linguist-generated=true
x-pack/legacy/plugins/siem/server/graphql/types.ts linguist-generated=true
x-pack/legacy/plugins/siem/public/graphql/introspection.json linguist-generated=true

8 changes: 0 additions & 8 deletions x-pack/legacy/plugins/siem/cypress.json

This file was deleted.

34 changes: 6 additions & 28 deletions x-pack/legacy/plugins/siem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import { i18n } from '@kbn/i18n';
import { resolve } from 'path';
import { Server } from 'hapi';
import { Root } from 'joi';

import { plugin } from './server';
import { savedObjectMappings } from './server/saved_objects';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { savedObjectMappings } from '../../../plugins/siem/server/saved_objects';

import {
APP_ID,
Expand All @@ -23,15 +22,13 @@ import {
DEFAULT_INTERVAL_VALUE,
DEFAULT_FROM,
DEFAULT_TO,
DEFAULT_SIGNALS_INDEX,
ENABLE_NEWS_FEED_SETTING,
NEWS_FEED_URL_SETTING,
NEWS_FEED_URL_SETTING_DEFAULT,
SIGNALS_INDEX_KEY,
IP_REPUTATION_LINKS_SETTING,
IP_REPUTATION_LINKS_SETTING_DEFAULT,
} from './common/constants';
import { defaultIndexPattern } from './default_index_pattern';
DEFAULT_INDEX_PATTERN,
} from '../../../plugins/siem/common/constants';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -102,7 +99,7 @@ export const siem = (kibana: any) => {
name: i18n.translate('xpack.siem.uiSettings.defaultIndexLabel', {
defaultMessage: 'Elasticsearch indices',
}),
value: defaultIndexPattern,
value: DEFAULT_INDEX_PATTERN,
description: i18n.translate('xpack.siem.uiSettings.defaultIndexDescription', {
defaultMessage:
'<p>Comma-delimited list of Elasticsearch indices from which the SIEM app collects events.</p>',
Expand Down Expand Up @@ -162,31 +159,12 @@ export const siem = (kibana: any) => {
},
mappings: savedObjectMappings,
},
init(server: Server) {
const { coreContext, env, setup, start } = server.newPlatform;
const initializerContext = { ...coreContext, env };
const __legacy = {
config: server.config,
route: server.route.bind(server),
};

// @ts-ignore-next-line: NewPlatform shim is too loosely typed
const pluginInstance = plugin(initializerContext);
// @ts-ignore-next-line: NewPlatform shim is too loosely typed
pluginInstance.setup(setup.core, setup.plugins, __legacy);
// @ts-ignore-next-line: NewPlatform shim is too loosely typed
pluginInstance.start(start.core, start.plugins);
},
config(Joi: Root) {
// See x-pack/plugins/siem/server/config.ts if you're adding another
// value where the configuration has to be duplicated at the moment.
// When we move over to the new platform completely this will be
// removed and only server/config.ts should be used.
return Joi.object()
.keys({
enabled: Joi.boolean().default(true),
[SIGNALS_INDEX_KEY]: Joi.string().default(DEFAULT_SIGNALS_INDEX),
})
.unknown(true)
.default();
},
});
Expand Down
10 changes: 2 additions & 8 deletions x-pack/legacy/plugins/siem/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"author": "Elastic",
"name": "siem",
"name": "siem-legacy-ui",
"version": "8.0.0",
"private": true,
"license": "Elastic-License",
"scripts": {
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js & node ../../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix",
"build-graphql-types": "node scripts/generate_types_from_graphql.js",
"cypress:open": "../../../node_modules/.bin/cypress open",
"cypress:run": "../../../node_modules/.bin/cypress run --spec ./cypress/integration/**/*.spec.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge --reportDir ../../../../target/kibana-siem/cypress/results > ../../../../target/kibana-siem/cypress/results/output.json; ../../../../node_modules/.bin/marge ../../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../../target/kibana-siem/cypress/results; mkdir -p ../../../../target/junit && cp ../../../../target/kibana-siem/cypress/results/*.xml ../../../../target/junit/ && exit $status;",
"cypress:run-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config.ts"
},
"scripts": {},
"devDependencies": {
"@types/lodash": "^4.14.110",
"@types/js-yaml": "^3.12.1",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { pluck } from 'rxjs/operators';
import { KibanaContextProvider, useKibana, useUiSetting$ } from '../lib/kibana';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';

import { DEFAULT_DARK_MODE } from '../../common/constants';
import { DEFAULT_DARK_MODE } from '../../../../../plugins/siem/common/constants';
import { ErrorToastDispatcher } from '../components/error_toast_dispatcher';
import { compose } from '../lib/compose/kibana_compose';
import { AppFrontendLibs, AppApolloClient } from '../lib/lib';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import React, { useEffect, useCallback, useMemo } from 'react';
import numeral from '@elastic/numeral';

import { DEFAULT_NUMBER_FORMAT } from '../../../../../../plugins/siem/common/constants';
import { AlertsComponentsQueryProps } from './types';
import { AlertsTable } from './alerts_table';
import * as i18n from './translations';
import { useUiSetting$ } from '../../lib/kibana';
import { DEFAULT_NUMBER_FORMAT } from '../../../common/constants';
import { MatrixHistogramContainer } from '../matrix_histogram';
import { histogramConfigs } from './histogram_configs';
import { MatrixHisrogramConfigs } from '../matrix_histogram/types';
Expand Down
Loading

0 comments on commit 1719c35

Please sign in to comment.