Go to file
Frank Hassanabad d7d4a14c8d
[Security Solutions][Detection Engine] Implements best effort merging of constant_keyword, runtime fields, aliases, and copy_to fields (#102280)
## Summary

This adds utilities and two strategies for merging using the [fields API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html) and the `_source` document during signal generation. This gives us the ability to support `constant_keyword`, field alias value support, some runtime fields support, and `copy_to` support. Previously we did not copy any of these values and only generated signals based on the `_source` record values. This changes the behavior to allow us to copy some of the mentioned values above.

The folder of `source_fields_merging` contains a `strategy` folder and a `utils` folder which contains both the strategies and the utilities for this implementation. The two strategies are `merge_all_fields_with_source` and `merge_missing_fields_with_source`. The defaulted choice for this PR is we use `merge_missing_fields_with_source` and not the `merge_all_fields_with_source`. The reasoning is that this is much lower risk and lower behavior changes to the signals detection engine.

The main driving force behind this PR is that ECS has introduced `constant_keyword` and that field has the possibility of only showing up in the fields section of a document and not `_source` when index authors do not push the `constant_keyword` into the `_source` section. The secondary driving forces behind this behavioral change is that some users have been expecting their runtime fields, `copy_to` fields, and field alias values of their indexes to be copied into the signals index.

Both strategies of `merge_missing_fields_with_source` and  `merge_all_fields_with_source` are considered Best Effort meaning that both strategies will not always merge as expected when they encounter ambiguous use cases as outlined in the `README.md` text at the top of `source_fields_merging` in detail.

The default used strategy of `merge_missing_fields_with_source` which has the simplest behavior will work in most common use cases. This is simply if the `_source` document is missing a value that is present in the `fields`, and the `fields` value is a primitive concrete value such as a `string` or `number` or `boolean` and the `_source` document does not contain an existing object or ambiguous array, then the value will be merged into `_source` and a new reference is returned. If you call the strategy twice it should be idempotent meaning that the second call will detect a value is now present in `_source` and not re-merge a second time.

* 301 unit tests were added
* Extensive README.md docs are added
* e2e tests are updated to test scenarios and ambiguity and conflicts from previously to support this effort.
* Other e2e tests were updated
* One bug with EQL and fields was found with a workaround implemented. See https://github.com/elastic/elasticsearch/issues/74582
* SearchTypes adjusted to use recursive TypeScript types
* Changed deprecated for `@deprecated` in a few spots
* Removed some `ts-expect-error` in favor of `??` in a few areas
* Added a new handling of epoch strings and tests to `detection_engine/signals/utils.ts` since fields returns `epoch_millis` as a string instead of as a number. 
* Uses lodash safer set to reduce changes of prototype pollution

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

### Risk Matrix


| Risk                      | Probability | Severity | Mitigation/Notes        |
|---------------------------|-------------|----------|-------------------------|
| Prototype pollution | Low | High | Used lodash safer set |
| Users which have existing rules that work, upgrade and now we do not generate signals due to bad merging of fields and _source | Mid | High | We use the safer strategy method, `merge_missing_fields_with_source `, that is lighter weight to start with. We might add a follow up PR which enables a key in Kibana to turn off merging of fields with source. We added extensive unit tests and e2e tests. However, unexpected unknowns and behaviors from runtime fields and fields API such as geo-points looking like nested fields or `epoch_milliseconds` being a string value or runtime fields allowing invalid values were uncovered and tests and utilities around that have been added which makes this PR risky |
| Found a bug with using fields and EQL which caused EQL rules to not run. | Low | High | Implemented workaround for tests to pass and created an Elastic ticket and communicated the bug to EQL developers. |
2021-06-28 18:11:10 -06:00
.buildkite chore(NA): moving @kbn/ui-shared-deps into bazel (#101669) 2021-06-18 16:09:31 +01:00
.ci [APM-UI][e2e] discard CI builds more often (#102217) 2021-06-16 10:01:43 +01:00
.github Move ES aggregation types to src/core (#102597) 2021-06-21 11:11:15 +01:00
api_docs [Discover] Deangularization of search embeddable (#100552) 2021-06-14 09:33:58 +01:00
config Add config properties for HTTP security headers (#97158) 2021-04-19 13:12:45 -04:00
dev_docs [dev_docs] add tutorial for setting up a development env (#103566) 2021-06-28 19:44:29 -04:00
docs [Maps] deprecate 'map.regionmap' kibana config and 'Configured GeoJSON' source (#103373) 2021-06-28 16:27:41 -06:00
examples Locator docs (#103129) 2021-06-28 21:44:11 +02:00
licenses Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
packages [eslint/module-migration] add support for re-export defs and test rule (#102840) 2021-06-28 14:28:10 -07:00
plugins [dev/cli] ensure plugins/ and all watch source dirs exist (#78973) 2020-09-30 10:20:44 -07:00
rfcs Convert image names to snake_case in RFC 0020. (#103536) 2021-06-28 14:00:26 -05:00
scripts chore(NA): moving @kbn/spec-to-console into bazel (#103470) 2021-06-28 15:58:41 +01:00
src Sharing saved objects phase 3.5 (#100424) 2021-06-28 18:06:54 -04:00
tasks/config [KQL] Use cache and other performance improvements (#93319) 2021-03-08 10:21:15 -07:00
test Sharing saved objects phase 3.5 (#100424) 2021-06-28 18:06:54 -04:00
typings Move ES aggregation types to src/core (#102597) 2021-06-21 11:11:15 +01:00
utilities Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
vars [migrations v2] Integration test for multi-node cluster. (#100957) 2021-06-28 12:49:38 -04:00
x-pack [Security Solutions][Detection Engine] Implements best effort merging of constant_keyword, runtime fields, aliases, and copy_to fields (#102280) 2021-06-28 18:11:10 -06:00
.backportrc.json chore(NA): adds 7.13 branch and bumps 7.x on backportrc (#97804) 2021-04-21 19:08:28 +01:00
.bazelignore chore(NA): stop grouping bazel out symlink folders (#96066) 2021-04-01 14:16:14 -05:00
.bazeliskversion chore(NA): bump bazelisk to v1.7.5 (#92905) 2021-02-26 00:48:47 +00:00
.bazelrc chore(NA): manage npm dependencies within bazel (#92864) 2021-03-03 12:37:20 -05:00
.bazelrc.common chore(NA): @kbn/pm new commands to support development on Bazel packages (#96465) 2021-04-12 20:24:19 -04:00
.bazelversion chore(NA): bazel machinery installation on kbn bootstrap (#89469) 2021-01-28 00:51:01 +00:00
.browserslistrc [browserslist] remove unnecessary browsers (#89186) 2021-01-25 16:30:18 -07:00
.editorconfig .editorconfig MDX files should follow the same rules as MD (#96942) 2021-04-13 11:40:42 -04:00
.eslintignore [packages] Move @kbn/interpreter to Bazel (#101089) 2021-06-22 09:59:20 -05:00
.eslintrc.js Add @storybook/testing-react (#103004) 2021-06-28 12:34:43 -05:00
.fossa.yml Adds FOSSA CLI configuration file (#70137) 2020-07-02 08:37:37 -07:00
.gitattributes
.gitignore [gitignore] only ignore snapshot.js at the root (#100840) 2021-06-07 13:42:52 -04:00
.i18nrc.json chore(NA): moving @kbn/ui-shared-deps into bazel (#101669) 2021-06-18 16:09:31 +01:00
.node-version Bump Node.js from version 14.16.1 to 14.17.0 (#100314) 2021-05-19 07:36:43 -07:00
.npmrc chore(NA): assure puppeteer_skip_chromium_download is applied across every yarn install situation (#88346) 2021-01-14 18:00:23 +00:00
.nvmrc Bump Node.js from version 14.16.1 to 14.17.0 (#100314) 2021-05-19 07:36:43 -07:00
.prettierignore [dev] Replace sass-lint with stylelint (#86177) 2021-01-15 11:52:29 -06:00
.prettierrc
.stylelintignore chore(NA): stop grouping bazel out symlink folders (#96066) 2021-04-01 14:16:14 -05:00
.stylelintrc Amsterdam helpers (#93701) 2021-03-10 10:27:16 -06:00
.telemetryrc.json [Usage collection] Collect non-default kibana configs (#97368) 2021-04-20 11:02:27 -04:00
.yarnrc chore(NA): manage npm dependencies within bazel (#92864) 2021-03-03 12:37:20 -05:00
api-documenter.json Normalize EOL symbol in platform docs (#56021) 2020-01-27 18:42:45 +01:00
BUILD.bazel chore(NA): moving @kbn/analytics into bazel (#98917) 2021-05-03 22:34:53 +01:00
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT.md (#87439) 2021-02-23 09:01:51 +01:00
CONTRIBUTING.md Improvements to our developer guide (#67764) 2020-07-13 10:47:01 -04:00
FAQ.md
github_checks_reporter.json
Gruntfile.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
Jenkinsfile [CI] Don't do CI stats reporting/failures for feature branch PRs (#99668) 2021-05-10 16:38:32 -04:00
jest.config.integration.js [jest] use circus runner for the integration tests (#102782) 2021-06-22 11:48:47 -04:00
jest.config.js Remove /src/legacy (#95510) 2021-04-06 09:25:36 +02:00
kibana.d.ts Remove /src/legacy (#95510) 2021-04-06 09:25:36 +02:00
LICENSE.txt Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
NOTICE.txt [Detections] Adds automatic updating for Prebuilt Security Detection Rules package (#101846) 2021-06-24 15:31:25 -06:00
package.json Add @storybook/testing-react (#103004) 2021-06-28 12:34:43 -05:00
preinstall_check.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
README.md Fix "Getting started" link in README (#84153) 2020-11-23 15:33:02 -05:00
renovate.json5 Add auto-backport by default to ech renovate bot prs (#102208) 2021-06-16 12:05:56 -05:00
RISK_MATRIX.mdx Add "Risk Matrix" section to the PR template (#100649) 2021-06-02 14:43:47 +02:00
SECURITY.md Add security policy to the Kibana repository (#85407) 2020-12-10 09:26:00 -05:00
STYLEGUIDE.mdx Syntax in styleguide.mdx is breaking docs build (#99840) 2021-05-11 18:06:42 -04:00
tsconfig.base.json fix(NA): windows ts_project outside sandbox compilation (#100947) 2021-06-03 17:53:39 +01:00
tsconfig.browser.json Introduce TS incremental builds & move src/test_utils to TS project (#76082) 2020-09-03 14:20:04 +02:00
tsconfig.json [RAC] T-Grid is moving to a new home (#100265) 2021-06-22 18:56:33 -04:00
tsconfig.refs.json [RAC] T-Grid is moving to a new home (#100265) 2021-06-22 18:56:33 -04:00
tsconfig.types.json ui_actions service initial docs (#78902) 2020-09-30 16:44:29 +02:00
TYPESCRIPT.md Fixed grammar (#74725) 2020-08-11 06:40:22 -04:00
WORKSPACE.bazel chore(NA): upgrade bazel rules nodejs to v3.5.1 (#101412) 2021-06-04 19:56:52 +01:00
yarn.lock Add @storybook/testing-react (#103004) 2021-06-28 12:34:43 -05:00

Kibana

Kibana is your window into the Elastic Stack. Specifically, it's a browser-based analytics and search dashboard for Elasticsearch.

Getting Started

If you just want to try Kibana out, check out the Elastic Stack Getting Started Page to give it a whirl.

If you're interested in diving a bit deeper and getting a taste of Kibana's capabilities, head over to the Kibana Getting Started Page.

Using a Kibana Release

If you want to use a Kibana release in production, give it a test run, or just play around:

Building and Running Kibana, and/or Contributing Code

You might want to build Kibana locally to contribute some code, test out the latest features, or try out an open PR:

Documentation

Visit Elastic.co for the full Kibana documentation.

For information about building the documentation, see the README in elastic/docs.

Version Compatibility with Elasticsearch

Ideally, you should be running Elasticsearch and Kibana with matching version numbers. If your Elasticsearch has an older version number or a newer major number than Kibana, then Kibana will fail to run. If Elasticsearch has a newer minor or patch number than Kibana, then the Kibana Server will log a warning.

Note: The version numbers below are only examples, meant to illustrate the relationships between different types of version numbers.

Situation Example Kibana version Example ES version Outcome
Versions are the same. 5.1.2 5.1.2 💚 OK
ES patch number is newer. 5.1.2 5.1.5 ⚠️ Logged warning
ES minor number is newer. 5.1.2 5.5.0 ⚠️ Logged warning
ES major number is newer. 5.1.2 6.0.0 🚫 Fatal error
ES patch number is older. 5.1.2 5.1.0 ⚠️ Logged warning
ES minor number is older. 5.1.2 5.0.0 🚫 Fatal error
ES major number is older. 5.1.2 4.0.0 🚫 Fatal error

Questions? Problems? Suggestions?

  • If you've found a bug or want to request a feature, please create a GitHub Issue. Please check to make sure someone else hasn't already created an issue for the same topic.
  • Need help using Kibana? Ask away on our Kibana Discuss Forum and a fellow community member or Elastic engineer will be glad to help you out.