kibana/packages
Madison Caldwell 475e9e8541
[RAC][Security Solution] Add base Security Rule Type (#105096) (#107755)
* injects bulkCreate and wrapHits to individual rule executors

* WIP create_security_rule_type_factory based on Marshall's work in #d3076ca54526ea0e61a9a99e1c1bce854806977e

* removes ruleStatusService from old rule executors, fixes executor unit tests

* fixes rebase

* Rename reference_rules to rule_types

* Fix type errors

* Fix type errors in base security rule factory

* Additional improvements to types and interfaces

* More type alignment

* Fix remaining type errors in query rule

* Add validation / inject lists plugin

* Formatting

* Improvements to typing

* Static typing on executors

* cleanup

* Hook up params for query/threshold rules... includes exceptionsList and daterange tuple

* Scaffolding for wrapHits and bulkCreate

* Add error handling / status reporting

* Fixup alert type state

* Begin threshold

* Begin work on threshold state

* Organize rule types

* Export base security rule types

* Fixup lifecycle static typing

* WrapHits / bulk changes

* Field mappings (partial)

* whoops

* Remove redundant params

* More flexibile implementation of bulkCreateFactory

* Add mappings

* Finish query rule

* Revert "Remove redundant params"

This reverts commit 87aff9c810.

* Revert "whoops"

This reverts commit a7771bd392.

* Fixup return types

* Use alertWithPersistence

* Fix import

* End-to-end rule mostly working

* Fix bulkCreate

* Bug fixes

* Bug fixes and mapping changes

* Fix indexing

* cleanup

* Fix type errors

* Test fixes

* Fix query tests

* cleanup / rename kibana.rac to kibana

* Remove eql/threshold (for now)

* Move technical fields to package

* Add indexAlias and buildRuleMessageFactory

* imports

* type errors

* Change 'kibana.rac.*' to 'kibana.*'

* Fix lifecycle tests

* Single alert instance

* fix import

* Fix type error

* Fix more type errors

* Fix query rule type test

* revert to previous ts-expect-error

* type errors again

* types / linting

* General readability improvements

* Add invariant function from Dmitrii's branch

* Use invariant and constants

* Improvements to field mappings

* More test failure fixes

* Add refresh param for bulk create

* Update more field refs

* Actually use refresh param

* cleanup

* test fixes

* changes to rule creation script

* Fix created signals count

* Use ruleId

* Updates to bulk indexing

* Mapping updates

* Cannot use 'strict' for dynamic setting

Co-authored-by: Marshall Main <marshall.main@elastic.co>
Co-authored-by: Ece Ozalp <ozale272@newschool.edu>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Marshall Main <marshall.main@elastic.co>
Co-authored-by: Ece Ozalp <ozale272@newschool.edu>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-05 12:18:29 -04:00
..
elastic-datemath
elastic-eslint-config-kibana chore(NA): moving @kbn/es-query to babel transpiler (#107281) (#107318) 2021-07-30 16:02:22 -04:00
elastic-safer-lodash-set
kbn-ace chore(NA): moving @kbn/ace to babel transpiler (#106922) (#107056) 2021-07-28 19:37:39 +00:00
kbn-analytics
kbn-apm-config-loader chore(NA): moving @kbn/apm-config-loader to babel transpiler (#107146) (#107219) 2021-07-29 16:46:29 -04:00
kbn-apm-utils chore(NA): moving @kbn/apm-utils to babel transpiler (#106989) (#107101) 2021-07-28 21:35:43 -04:00
kbn-babel-code-parser chore(NA): moving @kbn/babel-code-parser to babel transpiler (#107574) (#107599) 2021-08-03 23:27:39 +00:00
kbn-babel-preset chore(NA): moving @kbn/es-query to babel transpiler (#107281) (#107318) 2021-07-30 16:02:22 -04:00
kbn-cli-dev-mode [cli-dev-mode] get values from completed state subjects (#107428) (#107545) 2021-08-03 18:01:07 +00:00
kbn-common-utils chore(NA): moving @kbn/common-utils to babel transpiler (#107148) (#107191) 2021-07-29 14:27:17 -04:00
kbn-config
kbn-config-schema chore(NA): moving @kbn/config-schema to babel transpiler (#106929) (#107088) 2021-07-28 18:53:21 -04:00
kbn-crypto chore(NA): moving @kbn/dev-utils to babel transpiler (#107245) (#107331) 2021-07-30 18:24:02 -04:00
kbn-dev-utils chore(NA): moving @kbn/dev-utils to babel transpiler (#107245) (#107331) 2021-07-30 18:24:02 -04:00
kbn-docs-utils Improve deprecated API list, and update api docs (#106942) (#107441) 2021-08-02 16:44:47 -04:00
kbn-es chore(NA): moving @kbn/es to babel transpiler (#107577) (#107595) 2021-08-03 19:26:00 -04:00
kbn-es-archiver
kbn-es-query chore(NA): moving @kbn/es-query to babel transpiler (#107281) (#107318) 2021-07-30 16:02:22 -04:00
kbn-eslint-import-resolver-kibana
kbn-eslint-plugin-eslint
kbn-expect
kbn-field-types [data] Extract @kbn/field-types to a package (#106973) (#107276) 2021-07-30 08:58:29 -04:00
kbn-i18n chore(NA): moving @kbn/i18n to babel transpiler (#107447) (#107512) 2021-08-03 10:15:30 -04:00
kbn-interpreter
kbn-io-ts-utils
kbn-legacy-logging
kbn-logging
kbn-mapbox-gl
kbn-monaco chore(NA): moving @kbn/monaco to babel transpiler (#107461) (#107492) 2021-08-03 00:04:21 -04:00
kbn-optimizer [RAC] [TGrid] Bulk actions to EuiDataGrid toolbar (#107141) (#107646) 2021-08-04 12:20:25 -04:00
kbn-plugin-generator
kbn-plugin-helpers
kbn-pm [kbn/pm] Remove legacy build code (#107217) (#107449) 2021-08-02 18:08:44 -04:00
kbn-rule-data-utils [RAC][Security Solution] Add base Security Rule Type (#105096) (#107755) 2021-08-05 12:18:29 -04:00
kbn-securitysolution-autocomplete [Security Solutions] Removes deprecated types in kbn-securitysolution-* for newer kbn-es-query types (#106801) (#106869) 2021-07-28 20:17:08 +00:00
kbn-securitysolution-es-utils
kbn-securitysolution-hook-utils
kbn-securitysolution-io-ts-alerting-types
kbn-securitysolution-io-ts-list-types Remove duplicate license comments (#106850) 2021-07-28 20:03:18 +02:00
kbn-securitysolution-io-ts-types Implement RuleExecutionLog (#103463) (#107524) 2021-08-03 12:06:07 -04:00
kbn-securitysolution-io-ts-utils
kbn-securitysolution-list-api
kbn-securitysolution-list-constants
kbn-securitysolution-list-hooks
kbn-securitysolution-list-utils [Security Solutions] Removes deprecated types in kbn-securitysolution-* for newer kbn-es-query types (#106801) (#106869) 2021-07-28 20:17:08 +00:00
kbn-securitysolution-t-grid
kbn-securitysolution-utils
kbn-server-http-tools chore(NA): moving @kbn/server-http-tools to babel transpiler (#107572) (#107602) 2021-08-03 19:38:15 -04:00
kbn-server-route-repository chore(NA): moving @kbn/server-route-repository to babel transpiler (#107571) (#107716) 2021-08-05 08:26:37 +00:00
kbn-spec-to-console
kbn-std chore(NA): moving @kbn/std to babel transpiler (#107177) (#107212) 2021-07-29 19:53:30 +00:00
kbn-storybook
kbn-telemetry-tools chore(NA): moving @kbn/telemetry-tools to babel transpiler (#107540) (#107701) 2021-08-04 19:53:03 -04:00
kbn-test chore(NA): moving @kbn/test to babel transpiler (#107455) (#107476) 2021-08-02 19:53:52 -04:00
kbn-test-subj-selector
kbn-tinymath
kbn-typed-react-router-config chore(NA): moving @kbn/typed-react-router-config to babel transpiler (#107437) (#107474) 2021-08-02 23:55:26 +00:00
kbn-ui-framework
kbn-ui-shared-deps
kbn-utility-types chore(NA): moving @kbn/utility-types to babel transpiler (#107159) (#107320) 2021-07-30 17:05:52 -04:00
kbn-utils chore(NA): moving @kbn/utils to babel transpiler (#107010) (#107107) 2021-07-28 22:37:46 -04:00
BUILD.bazel [data] Extract @kbn/field-types to a package (#106973) (#107276) 2021-07-30 08:58:29 -04:00
README.md

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

How all of this works is described in more detail in the @kbn/pm docs.

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.

Jest

A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test or yarn grunt test runs all unit tests.
  • yarn jest runs all Jest tests in Kibana.

In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.


Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.