From 051c93a6bef8ae6dd0b4367161b6b59907b49c52 Mon Sep 17 00:00:00 2001 From: Spencer Date: Thu, 18 Jun 2020 15:24:16 -0700 Subject: [PATCH 1/3] [ftr] add support for docker servers (#68173) Co-authored-by: spalger --- packages/kbn-dev-utils/src/index.ts | 1 + .../kbn-dev-utils/src/proc_runner/proc.ts | 2 +- packages/kbn-dev-utils/src/stdio/index.ts | 21 ++ .../{proc_runner => stdio}/observe_lines.ts | 0 .../observe_readable.ts | 0 packages/kbn-test/package.json | 9 +- .../src/functional_test_runner/cli.ts | 6 +- .../functional_test_runner.ts | 8 + .../src/functional_test_runner/index.ts | 1 + .../lib/config/schema.ts | 23 ++ .../lib/docker_servers/README.md | 113 +++++++++ .../lib/docker_servers/container_logs.ts | 43 ++++ .../lib/docker_servers/container_running.ts | 65 +++++ .../define_docker_servers_config.ts | 45 ++++ .../docker_servers/docker_servers_service.ts | 224 ++++++++++++++++++ .../lib/docker_servers/index.ts | 21 ++ .../src/functional_test_runner/lib/index.ts | 1 + .../lib/lifecycle_phase.ts | 32 ++- packages/kbn-test/src/index.ts | 1 + packages/kbn-test/types/ftr.d.ts | 12 +- test/functional/config.js | 1 + vars/workers.groovy | 10 +- x-pack/test/functional/config.js | 2 - 23 files changed, 616 insertions(+), 25 deletions(-) create mode 100644 packages/kbn-dev-utils/src/stdio/index.ts rename packages/kbn-dev-utils/src/{proc_runner => stdio}/observe_lines.ts (100%) rename packages/kbn-dev-utils/src/{proc_runner => stdio}/observe_readable.ts (100%) create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts create mode 100644 packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts diff --git a/packages/kbn-dev-utils/src/index.ts b/packages/kbn-dev-utils/src/index.ts index 40ee72d94729f..fad5f85ab5890 100644 --- a/packages/kbn-dev-utils/src/index.ts +++ b/packages/kbn-dev-utils/src/index.ts @@ -37,4 +37,5 @@ export { run, createFailError, createFlagError, combineErrors, isFailError, Flag export { REPO_ROOT } from './repo_root'; export { KbnClient } from './kbn_client'; export * from './axios'; +export * from './stdio'; export * from './ci_stats_reporter'; diff --git a/packages/kbn-dev-utils/src/proc_runner/proc.ts b/packages/kbn-dev-utils/src/proc_runner/proc.ts index 59512cbb133b3..bd2368defd7e0 100644 --- a/packages/kbn-dev-utils/src/proc_runner/proc.ts +++ b/packages/kbn-dev-utils/src/proc_runner/proc.ts @@ -29,7 +29,7 @@ import { promisify } from 'util'; const treeKillAsync = promisify((...args: [number, string, any]) => treeKill(...args)); import { ToolingLog } from '../tooling_log'; -import { observeLines } from './observe_lines'; +import { observeLines } from '../stdio'; import { createCliError } from './errors'; const SECOND = 1000; diff --git a/packages/kbn-dev-utils/src/stdio/index.ts b/packages/kbn-dev-utils/src/stdio/index.ts new file mode 100644 index 0000000000000..3436d971b879a --- /dev/null +++ b/packages/kbn-dev-utils/src/stdio/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './observe_lines'; +export * from './observe_readable'; diff --git a/packages/kbn-dev-utils/src/proc_runner/observe_lines.ts b/packages/kbn-dev-utils/src/stdio/observe_lines.ts similarity index 100% rename from packages/kbn-dev-utils/src/proc_runner/observe_lines.ts rename to packages/kbn-dev-utils/src/stdio/observe_lines.ts diff --git a/packages/kbn-dev-utils/src/proc_runner/observe_readable.ts b/packages/kbn-dev-utils/src/stdio/observe_readable.ts similarity index 100% rename from packages/kbn-dev-utils/src/proc_runner/observe_readable.ts rename to packages/kbn-dev-utils/src/stdio/observe_readable.ts diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json index c74dba8a34c9d..fa30a88b79b08 100644 --- a/packages/kbn-test/package.json +++ b/packages/kbn-test/package.json @@ -1,9 +1,9 @@ { "name": "@kbn/test", - "main": "./target/index.js", "version": "1.0.0", - "license": "Apache-2.0", "private": true, + "license": "Apache-2.0", + "main": "./target/index.js", "scripts": { "build": "babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx --ignore *.test.js,**/__tests__/** --source-maps=inline", "kbn:bootstrap": "yarn build", @@ -13,6 +13,7 @@ "@babel/cli": "^7.10.1", "@kbn/babel-preset": "1.0.0", "@kbn/dev-utils": "1.0.0", + "@types/joi": "^13.4.2", "@types/parse-link-header": "^1.0.0", "@types/puppeteer": "^3.0.0", "@types/strip-ansi": "^5.2.1", @@ -23,12 +24,14 @@ "chalk": "^2.4.2", "dedent": "^0.7.0", "del": "^5.1.0", + "exit-hook": "^2.2.0", "getopts": "^2.2.4", "glob": "^7.1.2", + "joi": "^13.5.2", "parse-link-header": "^1.0.1", "puppeteer": "^3.3.0", - "strip-ansi": "^5.2.0", "rxjs": "^6.5.3", + "strip-ansi": "^5.2.0", "tar-fs": "^1.16.3", "tmp": "^0.1.0", "xml2js": "^0.4.22", diff --git a/packages/kbn-test/src/functional_test_runner/cli.ts b/packages/kbn-test/src/functional_test_runner/cli.ts index fd5ee5ad3ae44..2a8e0c3d7de9a 100644 --- a/packages/kbn-test/src/functional_test_runner/cli.ts +++ b/packages/kbn-test/src/functional_test_runner/cli.ts @@ -19,7 +19,10 @@ import { resolve } from 'path'; import { inspect } from 'util'; + import { run, createFlagError, Flags } from '@kbn/dev-utils'; +import exitHook from 'exit-hook'; + import { FunctionalTestRunner } from './functional_test_runner'; const makeAbsolutePath = (v: string) => resolve(process.cwd(), v); @@ -92,8 +95,7 @@ export function runFtrCli() { err instanceof Error ? err : new Error(`non-Error type rejection value: ${inspect(err)}`) ) ); - process.on('SIGTERM', () => teardown()); - process.on('SIGINT', () => teardown()); + exitHook(teardown); try { if (flags['test-stats']) { diff --git a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts index 03d4d7643607f..24f5cdceac95b 100644 --- a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts @@ -29,6 +29,7 @@ import { readProviderSpec, setupMocha, runTests, + DockerServersService, Config, SuiteTracker, } from './lib'; @@ -130,12 +131,19 @@ export class FunctionalTestRunner { throw new Error('No tests defined.'); } + const dockerServers = new DockerServersService( + config.get('dockerServers'), + this.log, + this.lifecycle + ); + // base level services that functional_test_runner exposes const coreProviders = readProviderSpec('Service', { lifecycle: () => this.lifecycle, log: () => this.log, failureMetadata: () => this.failureMetadata, config: () => config, + dockerServers: () => dockerServers, }); return await handler(config, coreProviders); diff --git a/packages/kbn-test/src/functional_test_runner/index.ts b/packages/kbn-test/src/functional_test_runner/index.ts index c783117a0ba42..cf65ceb51df8e 100644 --- a/packages/kbn-test/src/functional_test_runner/index.ts +++ b/packages/kbn-test/src/functional_test_runner/index.ts @@ -20,3 +20,4 @@ export { FunctionalTestRunner } from './functional_test_runner'; export { readConfigFile } from './lib'; export { runFtrCli } from './cli'; +export * from './lib/docker_servers'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts index e9aeee87f1a3b..6cbdc5ec7fc20 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts @@ -57,6 +57,27 @@ const appUrlPartsSchema = () => }) .default(); +const requiredWhenEnabled = (schema: Joi.Schema) => { + return Joi.when('enabled', { + is: true, + then: schema.required(), + otherwise: schema.optional(), + }); +}; + +const dockerServerSchema = () => + Joi.object() + .keys({ + enabled: Joi.boolean().required(), + image: requiredWhenEnabled(Joi.string()), + port: requiredWhenEnabled(Joi.number()), + portInContainer: requiredWhenEnabled(Joi.number()), + waitForLogLine: Joi.alternatives(Joi.object().type(RegExp), Joi.string()).optional(), + waitFor: Joi.func().optional(), + args: Joi.array().items(Joi.string()).optional(), + }) + .default(); + const defaultRelativeToConfigPath = (path: string) => { const makeDefault: any = (_: any, options: any) => resolve(dirname(options.context.path), path); makeDefault.description = `/${path}`; @@ -259,5 +280,7 @@ export const schema = Joi.object() disableTestUser: Joi.boolean(), }) .default(), + + dockerServers: Joi.object().pattern(Joi.string(), dockerServerSchema()).default(), }) .default(); diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md new file mode 100644 index 0000000000000..d75faf4c854aa --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md @@ -0,0 +1,113 @@ +# Functional Test Runner - Docker Servers + +In order to make it simpler to run some services while the functional tests are running, we've added the ability to execute docker containers while the tests execute for the purpose of exposing services to the tests. These containers are expected to expose an application via a single HTTP port and live for the life of the tests. If the application exits for any reason before the tests complete the tests will abort. + +To configure docker servers in your FTR config add the `dockerServers` key to your config like so: + +```ts +// import this helper to get TypeScript support for this section of the config +import { defineDockerServersConfig } from '@kbn/test'; + +export default function () { + return { + ... + + dockerServers: defineDockerServersConfig({ + // unique names are used in logging and to get the details of this server in the tests + helloWorld: { + /** disable this docker server unless the user sets some flag/env var */ + enabled: !!process.env.HELLO_WORLD_PORT, + /** the docker image to pull and run */ + image: 'vad1mo/hello-world-rest', + /** The port that this application will be accessible via locally */ + port: process.env.HELLO_WORLD_PORT, + /** The port that the container binds to in the container */ + portInContainer: 5050, + /** + * OPTIONAL: string/regex to look for in the log, when specified the + * tests won't start until a line containing this string, or matching + * this expression is found. + */ + waitForLogLine: /hello/, + /** + * OPTIONAL: function that is called when server is started, when defined + * it is called to give the configuration an option to write custom delay + * logic. The function is passed a DockerServer object, which is described + * below, and an observable of the log lines produced by the application + */ + async waitFor(server, logLine$) { + await logLine$.pipe( + filter(line => line.includes('...')), + tap((line) => { + console.log('marking server ready because this line was logged:', line); + console.log('server accessible from url', server.url); + }) + ).toPromise() + } + } + }) + } +} +``` + +To consume the test server, use can use something like supertest to send request. Just make sure that you disable your test suite if the user doesn't choose to enable your docker server: + +```ts +import makeSupertest from 'supertest-as-promised'; +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const dockerServers = getService('dockerServers'); + const log = getService('log'); + + const server = dockerServers.get('helloWorld'); + const supertest = makeSupertest(server.url); + + describe('test suite name', function () { + if (!server.enabled) { + log.warning( + 'disabling tests because server is not enabled, set HELLO_WORLD_PORT to run them' + ); + this.pending = true; + } + + it('test name', async () => { + await supertest.get('/foo/bar').expect(200); + }); + }); +} +``` + +## `DockerServersService` + +The docker servers service is a core service that is always available in functional test runner tests. When you call `getService('dockerServers')` you will receive an instance of the `DockerServersService` class which has to methods: + +### `has(name: string): boolean` + +Determine if a name resolves to a known docker server. + +### `isEnabled(name: string): boolean` + +Determine if a named server is enabled. + +### `get(name: string): DockerServer` + +Get a `DockerServer` object for the server with the given name. + + +## `DockerServer` + +The object passed to the `waitFor()` config function and returned by `DockerServersService#get()` + +```ts +{ + url: string; + name: string; + + portInContainer: number; + port: number; + image: string; + waitForLogLine?: RegExp | string; + waitFor?: (server: DockerServer, logLine$: Rx.Observable) => Promise; +} +``` diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts new file mode 100644 index 0000000000000..f8e8137ce40a2 --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_logs.ts @@ -0,0 +1,43 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import execa from 'execa'; +import * as Rx from 'rxjs'; +import { tap } from 'rxjs/operators'; +import { ToolingLog, observeLines } from '@kbn/dev-utils'; + +/** + * Observe the logs for a container, reflecting the log lines + * to the ToolingLog and the returned Observable + */ +export function observeContainerLogs(name: string, containerId: string, log: ToolingLog) { + log.debug(`[docker:${name}] streaming logs from container [id=${containerId}]`); + const logsProc = execa('docker', ['logs', '--follow', containerId], { + stdio: ['ignore', 'pipe', 'pipe'], + }); + + const logLine$ = new Rx.Subject(); + + Rx.merge( + observeLines(logsProc.stdout).pipe(tap((line) => log.info(`[docker:${name}] ${line}`))), + observeLines(logsProc.stderr).pipe(tap((line) => log.error(`[docker:${name}] ${line}`))) + ).subscribe(logLine$); + + return logLine$.asObservable(); +} diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts new file mode 100644 index 0000000000000..3e3247a6ae3bb --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/container_running.ts @@ -0,0 +1,65 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import execa from 'execa'; +import * as Rx from 'rxjs'; +import { ToolingLog } from '@kbn/dev-utils'; + +/** + * Create an observable that errors if a docker + * container exits before being unsubscribed + */ +export function observeContainerRunning(name: string, containerId: string, log: ToolingLog) { + return new Rx.Observable((subscriber) => { + log.debug(`[docker:${name}] watching container for exit status [${containerId}]`); + + const exitCodeProc = execa('docker', ['wait', containerId]); + + let exitCode: Error | number | null = null; + exitCodeProc + .then(({ stdout }) => { + exitCode = Number.parseInt(stdout.trim(), 10); + + if (Number.isFinite(exitCode)) { + subscriber.error( + new Error(`container [id=${containerId}] unexpectedly exitted with code ${exitCode}`) + ); + } else { + subscriber.error( + new Error(`unable to parse exit code from output of "docker wait": ${stdout}`) + ); + } + }) + .catch((error) => { + if (error?.killed) { + // ignore errors thrown because the process was killed + subscriber.complete(); + return; + } + + subscriber.error( + new Error(`failed to monitor process with "docker wait": ${error.message}`) + ); + }); + + return () => { + exitCodeProc.kill('SIGKILL'); + }; + }); +} diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts new file mode 100644 index 0000000000000..bb91ddbacf039 --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/define_docker_servers_config.ts @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as Rx from 'rxjs'; + +export interface DockerServerSpec { + enabled: boolean; + portInContainer: number; + port: number; + image: string; + waitForLogLine?: RegExp | string; + /** a function that should return an observable that will allow the tests to execute as soon as it emits anything */ + waitFor?: (server: DockerServer, logLine$: Rx.Observable) => Rx.Observable; + /* additional command line arguments passed to docker run */ + args?: string[]; +} + +export interface DockerServer extends DockerServerSpec { + name: string; + url: string; +} + +/** + * Helper that helps authors use the type definitions for the section of the FTR config + * under the `dockerServers` key. + */ +export function defineDockerServersConfig(config: { [name: string]: DockerServerSpec } | {}) { + return config; +} diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts new file mode 100644 index 0000000000000..606902228e1b7 --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts @@ -0,0 +1,224 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import Url from 'url'; +import execa from 'execa'; +import * as Rx from 'rxjs'; +import { filter, take, map } from 'rxjs/operators'; +import { ToolingLog } from '@kbn/dev-utils'; + +import { Lifecycle } from '../lifecycle'; +import { observeContainerRunning } from './container_running'; +import { observeContainerLogs } from './container_logs'; +import { DockerServer, DockerServerSpec } from './define_docker_servers_config'; + +const SECOND = 1000; + +export class DockerServersService { + private servers: DockerServer[]; + + constructor( + configs: { + [name: string]: DockerServerSpec; + }, + private log: ToolingLog, + private lifecycle: Lifecycle + ) { + this.servers = Object.entries(configs).map(([name, config]) => ({ + ...config, + name, + url: Url.format({ + protocol: 'http:', + hostname: 'localhost', + port: config.port, + }), + })); + + this.lifecycle.beforeTests.add(async () => { + await this.startServers(); + }); + } + + isEnabled(name: string) { + return this.get(name).enabled; + } + + has(name: string) { + return this.servers.some((s) => s.name === name); + } + + get(name: string) { + const server = this.servers.find((s) => s.name === name); + if (!server) { + throw new Error(`no server with name "${name}"`); + } + return { ...server }; + } + + private async dockerRun(server: DockerServer) { + const { args } = server; + try { + this.log.info(`[docker:${server.name}] running image "${server.image}"`); + + const dockerArgs = [ + 'run', + '-dit', + args || [], + '-p', + `${server.port}:${server.portInContainer}`, + server.image, + ].flat(); + const res = await execa('docker', dockerArgs); + + return res.stdout.trim(); + } catch (error) { + if (error?.exitCode === 125 && error?.message.includes('port is already allocated')) { + throw new Error(` + [docker:${server.name}] Another process is already listening on port ${server.port}. + + When this happens on CI it is usually because the port number isn't taking into + account parallel workers running on the same machine. + + When this happens locally it is usually because the functional test runner didn't + have a chance to cleanup the running docker containers before being killed. + + To see if this is the case: + + 1. make sure that there aren't other instances of the functional test runner running + 2. run \`docker ps\` to see the containers running + 3. if one of them lists that it is using port ${server.port} then kill it with \`docker kill "container ID"\` + `); + } + + throw error; + } + } + + private async startServer(server: DockerServer) { + const { log, lifecycle } = this; + const { image, name, waitFor, waitForLogLine } = server; + + // pull image from registry + log.info(`[docker:${name}] pulling docker image "${image}"`); + await execa('docker', ['pull', image]); + + // run the image that we just pulled + const containerId = await this.dockerRun(server); + + lifecycle.cleanup.add(() => { + try { + execa.sync('docker', ['kill', containerId]); + execa.sync('docker', ['rm', containerId]); + } catch (error) { + if ( + error.message.includes(`Container ${containerId} is not running`) || + error.message.includes(`No such container: ${containerId}`) + ) { + return; + } + + throw error; + } + }); + + // push the logs from the container to our logger, and expose an observable of those lines for testing + const logLine$ = observeContainerLogs(name, containerId, log); + lifecycle.cleanup.add(async () => { + await logLine$.toPromise(); + }); + + // ensure container stays running, error if it exits + lifecycle.cleanup.addSub( + observeContainerRunning(name, containerId, log).subscribe({ + error: (error) => { + lifecycle.cleanup.after$.subscribe(() => { + log.error(`[docker:${name}] Error ensuring that the container is running`); + log.error(error); + process.exit(1); + }); + + if (!lifecycle.cleanup.triggered) { + lifecycle.cleanup.trigger(); + } + }, + }) + ); + + // wait for conditions before completing + if (waitForLogLine instanceof RegExp) { + log.info(`[docker:${name}] Waiting for log line matching /${waitForLogLine.source}/`); + } + if (typeof waitForLogLine === 'string') { + log.info(`[docker:${name}] Waiting for log line containing "${waitForLogLine}"`); + } + if (waitFor !== undefined) { + log.info(`[docker:${name}] Waiting for waitFor() promise to resolve`); + } + if (waitForLogLine === undefined && waitFor === undefined) { + log.warning(` + [docker:${name}] No "waitFor*" condition defined, you should always + define a wait condition to avoid race conditions that are more likely + to fail on CI because we're not waiting for the contained server to be ready. + `); + } + + function firstWithTimeout(source$: Rx.Observable, errorMsg: string, ms = 30 * SECOND) { + return Rx.race( + source$.pipe(take(1)), + Rx.timer(ms).pipe( + map(() => { + throw new Error(`[docker:${name}] ${errorMsg} within ${ms / SECOND} seconds`); + }) + ) + ); + } + + await Rx.merge( + waitFor === undefined + ? Rx.EMPTY + : firstWithTimeout( + waitFor(server, logLine$), + `didn't find a line containing "${waitForLogLine}"` + ), + + waitForLogLine === undefined + ? Rx.EMPTY + : firstWithTimeout( + logLine$.pipe( + filter((line) => + waitForLogLine instanceof RegExp + ? waitForLogLine.test(line) + : line.includes(waitForLogLine) + ) + ), + `waitForLogLine didn't emit anything` + ) + ).toPromise(); + } + + private async startServers() { + await Promise.all( + this.servers.map(async (server) => { + if (server.enabled) { + await this.startServer(server); + } + }) + ); + } +} diff --git a/packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts new file mode 100644 index 0000000000000..23df9df0458d7 --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/docker_servers/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './docker_servers_service'; +export * from './define_docker_servers_config'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/index.ts b/packages/kbn-test/src/functional_test_runner/lib/index.ts index 2e534974e1d76..4c34f334a8c25 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/index.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/index.ts @@ -23,4 +23,5 @@ export { readConfigFile, Config } from './config'; export { readProviderSpec, ProviderCollection, Provider } from './providers'; export { runTests, setupMocha } from './mocha'; export { FailureMetadata } from './failure_metadata'; +export * from './docker_servers'; export { SuiteTracker } from './suite_tracker'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts b/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts index 5c7fdb532faa1..70fcd4d217be0 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/lifecycle_phase.ts @@ -28,6 +28,8 @@ export type GetArgsType> = T extends LifecyclePhas export class LifecyclePhase { private readonly handlers: Array<(...args: Args) => Promise | void> = []; + public triggered = false; + private readonly beforeSubj = new Rx.Subject(); public readonly before$ = this.beforeSubj.asObservable(); @@ -46,29 +48,39 @@ export class LifecyclePhase { this.handlers.push(fn); } + public addSub(sub: Rx.Subscription) { + this.handlers.push(() => { + sub.unsubscribe(); + }); + } + public async trigger(...args: Args) { - if (this.beforeSubj.isStopped) { + if (this.options.singular && this.triggered) { throw new Error(`singular lifecycle event can only be triggered once`); } + this.triggered = true; + this.beforeSubj.next(undefined); if (this.options.singular) { this.beforeSubj.complete(); } // catch the first error but still execute all handlers - let error; + let error: Error | undefined; // shuffle the handlers to prevent relying on their order - for (const fn of shuffle(this.handlers)) { - try { - await fn(...args); - } catch (_error) { - if (!error) { - error = _error; + await Promise.all( + shuffle(this.handlers).map(async (fn) => { + try { + await fn(...args); + } catch (_error) { + if (!error) { + error = _error; + } } - } - } + }) + ); this.afterSubj.next(undefined); if (this.options.singular) { diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index 0bc7cc664df68..46f753b909553 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -59,4 +59,5 @@ export { makeJunitReportPath } from './junit_report_path'; export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; +export * from './functional_test_runner'; export * from './page_load_metrics'; diff --git a/packages/kbn-test/types/ftr.d.ts b/packages/kbn-test/types/ftr.d.ts index 8beecab88878d..38eb69d3e6811 100644 --- a/packages/kbn-test/types/ftr.d.ts +++ b/packages/kbn-test/types/ftr.d.ts @@ -18,7 +18,12 @@ */ import { ToolingLog } from '@kbn/dev-utils'; -import { Config, Lifecycle, FailureMetadata } from '../src/functional_test_runner/lib'; +import { + Config, + Lifecycle, + FailureMetadata, + DockerServersService, +} from '../src/functional_test_runner/lib'; export { Lifecycle, Config, FailureMetadata }; @@ -61,7 +66,9 @@ export interface GenericFtrProviderContext< * Determine if a service is avaliable * @param serviceName */ - hasService(serviceName: 'config' | 'log' | 'lifecycle' | 'failureMetadata'): true; + hasService( + serviceName: 'config' | 'log' | 'lifecycle' | 'failureMetadata' | 'dockerServers' + ): true; hasService(serviceName: K): serviceName is K; hasService(serviceName: string): serviceName is Extract; @@ -73,6 +80,7 @@ export interface GenericFtrProviderContext< getService(serviceName: 'config'): Config; getService(serviceName: 'log'): ToolingLog; getService(serviceName: 'lifecycle'): Lifecycle; + getService(serviceName: 'dockerServers'): DockerServersService; getService(serviceName: 'failureMetadata'): FailureMetadata; getService(serviceName: T): ServiceMap[T]; diff --git a/test/functional/config.js b/test/functional/config.js index c377e64f2fc45..95e0c689089ef 100644 --- a/test/functional/config.js +++ b/test/functional/config.js @@ -40,6 +40,7 @@ export default async function ({ readConfigFile }) { ], pageObjects, services, + servers: commonConfig.get('servers'), esTestCluster: commonConfig.get('esTestCluster'), diff --git a/vars/workers.groovy b/vars/workers.groovy index 8034a548285a4..e44df9ef75ad0 100644 --- a/vars/workers.groovy +++ b/vars/workers.groovy @@ -6,15 +6,15 @@ def label(size) { case 'flyweight': return 'flyweight' case 's': - return 'linux && immutable' + return 'docker && linux && immutable' case 's-highmem': - return 'tests-s' + return 'docker && tests-s' case 'l': - return 'tests-l' + return 'docker && tests-l' case 'xl': - return 'tests-xl' + return 'docker && tests-xl' case 'xxl': - return 'tests-xxl' + return 'docker && tests-xxl' } error "unknown size '${size}'" diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index bcc7c978ca237..d5e3f82878d6b 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -4,8 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -/* eslint-disable import/no-default-export */ - import { resolve } from 'path'; import { services } from './services'; From 25b4f34f7ccac9a459ba12969fb6a581b2af7c7d Mon Sep 17 00:00:00 2001 From: Marshall Main <55718608+marshallmain@users.noreply.github.com> Date: Thu, 18 Jun 2020 18:42:27 -0400 Subject: [PATCH 2/3] Remove endpoint alert fields from signal mapping (#68934) Co-authored-by: Elastic Machine --- .../routes/index/ecs_mapping.json | 1705 ++--------------- 1 file changed, 187 insertions(+), 1518 deletions(-) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json index 6a404e390bd14..6126ee462ec20 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json @@ -7,14 +7,6 @@ }, "agent": { "properties": { - "build": { - "properties": { - "original": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "ephemeral_id": { "ignore_above": 1024, "type": "keyword" @@ -37,6 +29,27 @@ } } }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, "client": { "properties": { "address": { @@ -202,10 +215,6 @@ "id": { "ignore_above": 1024, "type": "keyword" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" } } }, @@ -233,18 +242,6 @@ } } }, - "project": { - "properties": { - "id": { - "ignore_above": 1024, - "type": "keyword" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "provider": { "ignore_above": 1024, "type": "keyword" @@ -255,6 +252,27 @@ } } }, + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "ignore_above": 1024, + "type": "keyword" + }, + "subject_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" + } + } + }, "container": { "properties": { "id": { @@ -467,9 +485,6 @@ } } }, - "compile_time": { - "type": "date" - }, "hash": { "properties": { "md5": { @@ -490,53 +505,6 @@ } } }, - "malware_classification": { - "properties": { - "features": { - "properties": { - "data": { - "properties": { - "buffer": { - "ignore_above": 1024, - "type": "keyword" - }, - "decompressed_size": { - "type": "integer" - }, - "encoding": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "identifier": { - "ignore_above": 1024, - "type": "keyword" - }, - "score": { - "type": "double" - }, - "threshold": { - "type": "double" - }, - "upx_packed": { - "type": "boolean" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "mapped_address": { - "ignore_above": 1024, - "type": "keyword" - }, - "mapped_size": { - "type": "long" - }, "name": { "ignore_above": 1024, "type": "keyword" @@ -547,10 +515,6 @@ }, "pe": { "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, "company": { "ignore_above": 1024, "type": "keyword" @@ -563,10 +527,6 @@ "ignore_above": 1024, "type": "keyword" }, - "imphash": { - "ignore_above": 1024, - "type": "keyword" - }, "original_file_name": { "ignore_above": 1024, "type": "keyword" @@ -666,49 +626,6 @@ } } }, - "endpoint": { - "properties": { - "artifact": { - "properties": { - "hash": { - "ignore_above": 1024, - "type": "keyword" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "event": { - "properties": { - "process": { - "properties": { - "ancestry": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "policy": { - "properties": { - "id": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "object" - } - } - }, "error": { "properties": { "code": { @@ -882,9 +799,6 @@ "ignore_above": 1, "type": "keyword" }, - "entry_modified": { - "type": "double" - }, "extension": { "ignore_above": 1024, "type": "keyword" @@ -921,156 +835,6 @@ "ignore_above": 1024, "type": "keyword" }, - "macro": { - "properties": { - "code_page": { - "type": "long" - }, - "collection": { - "properties": { - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - }, - "type": "object" - }, - "errors": { - "properties": { - "count": { - "type": "long" - }, - "error_type": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - }, - "file_extension": { - "ignore_above": 1024, - "type": "keyword" - }, - "project_file": { - "properties": { - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - }, - "type": "object" - }, - "stream": { - "properties": { - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "raw_code": { - "ignore_above": 1024, - "type": "keyword" - }, - "raw_code_size": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - } - } - }, - "malware_classification": { - "properties": { - "features": { - "properties": { - "data": { - "properties": { - "buffer": { - "ignore_above": 1024, - "type": "keyword" - }, - "decompressed_size": { - "type": "integer" - }, - "encoding": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "identifier": { - "ignore_above": 1024, - "type": "keyword" - }, - "score": { - "type": "double" - }, - "threshold": { - "type": "double" - }, - "upx_packed": { - "type": "boolean" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "mime_type": { "ignore_above": 1024, "type": "keyword" @@ -1102,10 +866,6 @@ }, "pe": { "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, "company": { "ignore_above": 1024, "type": "keyword" @@ -1118,10 +878,6 @@ "ignore_above": 1024, "type": "keyword" }, - "imphash": { - "ignore_above": 1024, - "type": "keyword" - }, "original_file_name": { "ignore_above": 1024, "type": "keyword" @@ -1132,13 +888,6 @@ } } }, - "quarantine_path": { - "ignore_above": 1024, - "type": "keyword" - }, - "quarantine_result": { - "type": "boolean" - }, "size": { "type": "long" }, @@ -1152,123 +901,48 @@ "ignore_above": 1024, "type": "keyword" }, - "temp_file_path": { + "type": { "ignore_above": 1024, "type": "keyword" }, - "type": { + "uid": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "geo": { + "properties": { + "city_name": { "ignore_above": 1024, "type": "keyword" }, - "uid": { + "continent_name": { "ignore_above": 1024, "type": "keyword" }, - "x509": { - "properties": { - "alternative_names": { - "ignore_above": 1024, - "type": "keyword" - }, - "issuer": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "not_after": { - "type": "date" - }, - "not_before": { - "type": "date" - }, - "public_key_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_curve": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_exponent": { - "doc_values": false, - "index": false, - "type": "long" - }, - "public_key_size": { - "type": "long" - }, - "serial_number": { - "ignore_above": 1024, - "type": "keyword" - }, - "signature_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "version_number": { - "ignore_above": 1024, - "type": "keyword" - } - } + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" } } }, @@ -1288,6 +962,26 @@ } } }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha512": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "host": { "properties": { "architecture": { @@ -1386,10 +1080,6 @@ "ignore_above": 1024, "type": "keyword" }, - "variant": { - "ignore_above": 1024, - "type": "keyword" - }, "version": { "ignore_above": 1024, "type": "keyword" @@ -1519,10 +1209,6 @@ }, "status_code": { "type": "long" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" } } }, @@ -1532,19 +1218,27 @@ } } }, + "interface": { + "properties": { + "alias": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "labels": { "type": "object" }, "log": { "properties": { - "file": { - "properties": { - "path": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "level": { "ignore_above": 1024, "type": "keyword" @@ -1848,10 +1542,6 @@ "ignore_above": 1024, "type": "keyword" }, - "variant": { - "ignore_above": 1024, - "type": "keyword" - }, "version": { "ignore_above": 1024, "type": "keyword" @@ -1898,6 +1588,46 @@ } } }, + "os": { + "properties": { + "family": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "kernel": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "platform": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "package": { "properties": { "architecture": { @@ -1952,6 +1682,30 @@ } } }, + "pe": { + "properties": { + "company": { + "ignore_above": 1024, + "type": "keyword" + }, + "description": { + "ignore_above": 1024, + "type": "keyword" + }, + "file_version": { + "ignore_above": 1024, + "type": "keyword" + }, + "original_file_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "product": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "process": { "properties": { "args": { @@ -2029,46 +1783,6 @@ } } }, - "malware_classification": { - "properties": { - "features": { - "properties": { - "data": { - "properties": { - "buffer": { - "ignore_above": 1024, - "type": "keyword" - }, - "decompressed_size": { - "type": "integer" - }, - "encoding": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "identifier": { - "ignore_above": 1024, - "type": "keyword" - }, - "score": { - "type": "double" - }, - "threshold": { - "type": "double" - }, - "upx_packed": { - "type": "boolean" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "name": { "fields": { "text": { @@ -2216,10 +1930,6 @@ }, "pe": { "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, "company": { "ignore_above": 1024, "type": "keyword" @@ -2232,10 +1942,6 @@ "ignore_above": 1024, "type": "keyword" }, - "imphash": { - "ignore_above": 1024, - "type": "keyword" - }, "original_file_name": { "ignore_above": 1024, "type": "keyword" @@ -2255,132 +1961,17 @@ "ppid": { "type": "long" }, - "services": { - "ignore_above": 1024, - "type": "keyword" - }, "start": { "type": "date" }, "thread": { "properties": { - "call_stack": { - "properties": { - "instruction_pointer": { - "ignore_above": 1024, - "type": "keyword" - }, - "memory_section": { - "properties": { - "address": { - "ignore_above": 1024, - "type": "keyword" - }, - "protection": { - "ignore_above": 1024, - "type": "keyword" - }, - "size": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "module_path": { - "ignore_above": 1024, - "type": "keyword" - }, - "rva": { - "ignore_above": 1024, - "type": "keyword" - }, - "symbol_info": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "id": { "type": "long" }, "name": { "ignore_above": 1024, "type": "keyword" - }, - "service": { - "ignore_above": 1024, - "type": "keyword" - }, - "start": { - "type": "date" - }, - "start_address": { - "ignore_above": 1024, - "type": "keyword" - }, - "start_address_module": { - "ignore_above": 1024, - "type": "keyword" - }, - "token": { - "properties": { - "domain": { - "ignore_above": 1024, - "type": "keyword" - }, - "elevation": { - "type": "boolean" - }, - "elevation_type": { - "ignore_above": 1024, - "type": "keyword" - }, - "impersonation_level": { - "ignore_above": 1024, - "type": "keyword" - }, - "integrity_level": { - "type": "long" - }, - "integrity_level_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "is_appcontainer": { - "type": "boolean" - }, - "privileges": { - "properties": { - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - }, - "sid": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "user": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "uptime": { - "type": "long" } } }, @@ -2394,70 +1985,9 @@ "ignore_above": 1024, "type": "keyword" }, - "token": { - "properties": { - "domain": { - "ignore_above": 1024, - "type": "keyword" - }, - "elevation": { - "type": "boolean" - }, - "elevation_type": { - "ignore_above": 1024, - "type": "keyword" - }, - "impersonation_level": { - "ignore_above": 1024, - "type": "keyword" - }, - "integrity_level": { - "type": "long" - }, - "integrity_level_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "is_appcontainer": { - "type": "boolean" - }, - "privileges": { - "properties": { - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - }, - "sid": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "user": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, "uptime": { "type": "long" }, - "user": { - "ignore_above": 1024, - "type": "keyword" - }, "working_directory": { "fields": { "text": { @@ -2921,663 +2451,6 @@ "ignore_above": 1024, "type": "keyword" }, - "target": { - "properties": { - "dll": { - "properties": { - "code_signature": { - "properties": { - "exists": { - "type": "boolean" - }, - "status": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "trusted": { - "type": "boolean" - }, - "valid": { - "type": "boolean" - } - } - }, - "compile_time": { - "type": "date" - }, - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "malware_classification": { - "properties": { - "features": { - "properties": { - "data": { - "properties": { - "buffer": { - "ignore_above": 1024, - "type": "keyword" - }, - "decompressed_size": { - "type": "integer" - }, - "encoding": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "identifier": { - "ignore_above": 1024, - "type": "keyword" - }, - "score": { - "type": "double" - }, - "threshold": { - "type": "double" - }, - "upx_packed": { - "type": "boolean" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "mapped_address": { - "ignore_above": 1024, - "type": "keyword" - }, - "mapped_size": { - "type": "long" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "path": { - "ignore_above": 1024, - "type": "keyword" - }, - "pe": { - "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, - "company": { - "ignore_above": 1024, - "type": "keyword" - }, - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "file_version": { - "ignore_above": 1024, - "type": "keyword" - }, - "imphash": { - "ignore_above": 1024, - "type": "keyword" - }, - "original_file_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "product": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "process": { - "properties": { - "args": { - "ignore_above": 1024, - "type": "keyword" - }, - "args_count": { - "type": "long" - }, - "code_signature": { - "properties": { - "exists": { - "type": "boolean" - }, - "status": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "trusted": { - "type": "boolean" - }, - "valid": { - "type": "boolean" - } - } - }, - "command_line": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "entity_id": { - "ignore_above": 1024, - "type": "keyword" - }, - "executable": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "exit_code": { - "type": "long" - }, - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "malware_classification": { - "properties": { - "features": { - "properties": { - "data": { - "properties": { - "buffer": { - "ignore_above": 1024, - "type": "keyword" - }, - "decompressed_size": { - "type": "integer" - }, - "encoding": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, - "identifier": { - "ignore_above": 1024, - "type": "keyword" - }, - "score": { - "type": "double" - }, - "threshold": { - "type": "double" - }, - "upx_packed": { - "type": "boolean" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "name": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "parent": { - "properties": { - "args": { - "ignore_above": 1024, - "type": "keyword" - }, - "args_count": { - "type": "long" - }, - "code_signature": { - "properties": { - "exists": { - "type": "boolean" - }, - "status": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "trusted": { - "type": "boolean" - }, - "valid": { - "type": "boolean" - } - } - }, - "command_line": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "entity_id": { - "ignore_above": 1024, - "type": "keyword" - }, - "executable": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "exit_code": { - "type": "long" - }, - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "name": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "pgid": { - "type": "long" - }, - "pid": { - "type": "long" - }, - "ppid": { - "type": "long" - }, - "start": { - "type": "date" - }, - "thread": { - "properties": { - "id": { - "type": "long" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "title": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "uptime": { - "type": "long" - }, - "working_directory": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "pe": { - "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, - "company": { - "ignore_above": 1024, - "type": "keyword" - }, - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "file_version": { - "ignore_above": 1024, - "type": "keyword" - }, - "imphash": { - "ignore_above": 1024, - "type": "keyword" - }, - "original_file_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "product": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "pgid": { - "type": "long" - }, - "pid": { - "type": "long" - }, - "ppid": { - "type": "long" - }, - "services": { - "ignore_above": 1024, - "type": "keyword" - }, - "start": { - "type": "date" - }, - "thread": { - "properties": { - "call_stack": { - "properties": { - "instruction_pointer": { - "ignore_above": 1024, - "type": "keyword" - }, - "memory_section": { - "properties": { - "address": { - "ignore_above": 1024, - "type": "keyword" - }, - "protection": { - "ignore_above": 1024, - "type": "keyword" - }, - "size": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "module_path": { - "ignore_above": 1024, - "type": "keyword" - }, - "rva": { - "ignore_above": 1024, - "type": "keyword" - }, - "symbol_info": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "id": { - "type": "long" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "service": { - "ignore_above": 1024, - "type": "keyword" - }, - "start": { - "type": "date" - }, - "start_address": { - "ignore_above": 1024, - "type": "keyword" - }, - "start_address_module": { - "ignore_above": 1024, - "type": "keyword" - }, - "token": { - "properties": { - "domain": { - "ignore_above": 1024, - "type": "keyword" - }, - "elevation": { - "type": "boolean" - }, - "elevation_type": { - "ignore_above": 1024, - "type": "keyword" - }, - "impersonation_level": { - "ignore_above": 1024, - "type": "keyword" - }, - "integrity_level": { - "type": "long" - }, - "integrity_level_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "is_appcontainer": { - "type": "boolean" - }, - "privileges": { - "properties": { - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - }, - "sid": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "user": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "uptime": { - "type": "long" - } - } - }, - "title": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "token": { - "properties": { - "domain": { - "ignore_above": 1024, - "type": "keyword" - }, - "elevation": { - "type": "boolean" - }, - "elevation_type": { - "ignore_above": 1024, - "type": "keyword" - }, - "impersonation_level": { - "ignore_above": 1024, - "type": "keyword" - }, - "integrity_level": { - "type": "long" - }, - "integrity_level_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "is_appcontainer": { - "type": "boolean" - }, - "privileges": { - "properties": { - "description": { - "ignore_above": 1024, - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } - }, - "type": "nested" - }, - "sid": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "user": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "uptime": { - "type": "long" - }, - "user": { - "ignore_above": 1024, - "type": "keyword" - }, - "working_directory": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - }, "threat": { "properties": { "framework": { @@ -3681,112 +2554,6 @@ "supported_ciphers": { "ignore_above": 1024, "type": "keyword" - }, - "x509": { - "properties": { - "alternative_names": { - "ignore_above": 1024, - "type": "keyword" - }, - "issuer": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "not_after": { - "type": "date" - }, - "not_before": { - "type": "date" - }, - "public_key_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_curve": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_exponent": { - "doc_values": false, - "index": false, - "type": "long" - }, - "public_key_size": { - "type": "long" - }, - "serial_number": { - "ignore_above": 1024, - "type": "keyword" - }, - "signature_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "version_number": { - "ignore_above": 1024, - "type": "keyword" - } - } } } }, @@ -3847,112 +2614,6 @@ "subject": { "ignore_above": 1024, "type": "keyword" - }, - "x509": { - "properties": { - "alternative_names": { - "ignore_above": 1024, - "type": "keyword" - }, - "issuer": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "not_after": { - "type": "date" - }, - "not_before": { - "type": "date" - }, - "public_key_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_curve": { - "ignore_above": 1024, - "type": "keyword" - }, - "public_key_exponent": { - "doc_values": false, - "index": false, - "type": "long" - }, - "public_key_size": { - "type": "long" - }, - "serial_number": { - "ignore_above": 1024, - "type": "keyword" - }, - "signature_algorithm": { - "ignore_above": 1024, - "type": "keyword" - }, - "subject": { - "properties": { - "common_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country": { - "ignore_above": 1024, - "type": "keyword" - }, - "distinguished_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "locality": { - "ignore_above": 1024, - "type": "keyword" - }, - "organization": { - "ignore_above": 1024, - "type": "keyword" - }, - "organizational_unit": { - "ignore_above": 1024, - "type": "keyword" - }, - "state_or_province": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "version_number": { - "ignore_above": 1024, - "type": "keyword" - } - } } } }, @@ -4163,10 +2824,6 @@ "ignore_above": 1024, "type": "keyword" }, - "variant": { - "ignore_above": 1024, - "type": "keyword" - }, "version": { "ignore_above": 1024, "type": "keyword" @@ -4179,6 +2836,18 @@ } } }, + "vlan": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "vulnerability": { "properties": { "category": { From 8a554f8aaad137d36680a7e30b38281e8d4898f3 Mon Sep 17 00:00:00 2001 From: DeDe Morton Date: Thu, 18 Jun 2020 15:44:29 -0700 Subject: [PATCH 3/3] [DOCS] Add related link to the ingest management docs (#69467) * [DOCS] Add related link to the ingest management docs * Add link to ingest manager topic in Kibana * Remove link to ingest manager topic in kibana --- docs/settings/ingest-manager-settings.asciidoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/settings/ingest-manager-settings.asciidoc b/docs/settings/ingest-manager-settings.asciidoc index 0c3427b034ae2..f46c769079040 100644 --- a/docs/settings/ingest-manager-settings.asciidoc +++ b/docs/settings/ingest-manager-settings.asciidoc @@ -8,8 +8,10 @@ experimental[] You can configure `xpack.ingestManager` settings in your `kibana.yml`. -By default, {ingest-manager} is not enabled. You need to enable it. To use -{fleet}, you also need to configure {kib} and {es} hosts. +By default, {ingest-manager} is not enabled. You need to +enable it. To use {fleet}, you also need to configure {kib} and {es} hosts. + +See the {ingest-guide}/index.html[Ingest Management] docs for more information. [[general-ingest-manager-settings-kb]] ==== General {ingest-manager} settings