Commit graph

60 commits

Author SHA1 Message Date
Jonathan Buttner
2180a8a6b0
[ResponseOps][Rules] Adding rule.url variable (#145035)
This PR adds a new actions variable for linking back the stack
management rule page. In a future PR we will require the rule type to
specify the plugin's path when registering the rule type that way we can
link back to the specific plugin that created the rule.

Issue: https://github.com/elastic/kibana/issues/145132

<details><summary>Mustache variable</summary>


![image](https://user-images.githubusercontent.com/56361221/201212197-48577715-954b-463d-9164-5d2ebfc18cb4.png)


![image](https://user-images.githubusercontent.com/56361221/201212231-23319658-0b21-469b-a272-7c59f5caa618.png)


</details>

<details><summary>Constructed URL</summary>


![image](https://user-images.githubusercontent.com/56361221/201212322-6a4eab78-88ef-4cef-aa41-e34792a8148b.png)


</details>

Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
2022-11-15 16:05:32 -07:00
Marshall Main
a2647ab67c
[Security Solution][Alerts] Alert suppression per rule execution (#142686)
## Summary

Addresses https://github.com/elastic/kibana/issues/130699

This PR implements alert throttling per rule execution for query and
saved query rules. The implementation is very similar in concept to
threshold rules. We allow users to pick one or more fields to group
source documents by and use a composite aggregation to collect documents
bucketed by those fields. We create 1 alert for each bucket based on the
first document in the bucket and add metadata to the alert that
represents how to retrieve the rest of the documents in the bucket.

The metadata fields are:
- `kibana.alert.suppression.terms`: `{field: string; value: Array<string
| number>}` An array of objects, each object represents one of the terms
used to group these alerts
- `kibana.alert.suppression.start`: `Date` The timestamp of the first
document in the bucket
- `kibana.alert.suppression.end`: `Date` The timestamp of the last
document in the bucket
- `kibana.alert.suppression.docs_count`: `number` The number of
suppressed alerts

There is one new rule parameter, currently implemented at the solution
level, to enable this feature: `alertSuppression.groupBy`: `string[]`.

Similar to threshold rules, the throttled query rules keep track of
created alerts in the rule state in order to filter out duplicate
documents in subsequent rule executions. When a throttled alert is
created, we store the bucket information including field names, values,
and end date in the rule state. Subsequent rule executions convert this
state into a filter that excludes documents that have already been
covered by existing alerts. This is necessary because consecutive rule
executions will typically query overlapping time ranges.

## Screenshots
### Rule Create/Edit With License
<details>


![image](https://user-images.githubusercontent.com/55718608/201762013-c973b121-e85a-4163-a645-24beaa738add.png)
</details>

### Rule Details With License
<details>


![image](https://user-images.githubusercontent.com/55718608/201970156-6e64fe01-e7b2-43c0-a740-45f72ad21863.png)
</details>

### Rule Create, or Rule Edit of a rule without existing suppression
configuration, Without License
<details>


![image](https://user-images.githubusercontent.com/55718608/201763392-20364d77-809b-46a0-b3c0-9ca7fe04f636.png)
</details>

### Editing a rule that has existing suppression configuration, but
without the correct license, still allows changing the configuration (to
allow removing the params)
<details>


![image](https://user-images.githubusercontent.com/55718608/201763671-afb2e7b8-6c8f-4a5e-8947-99ad21dd92f9.png)
</details>

### Rule Details Without License
<details>


![image](https://user-images.githubusercontent.com/55718608/201970472-8e69267d-7c53-4172-9b45-b8b46ebd67bc.png)
</details>

### Alerts table
<details>


![image](https://user-images.githubusercontent.com/55718608/201968736-e0165387-bb08-45ce-a92f-5e2b428c7426.png)
</details>

### Known issues
- The layers icon in the rule name for suppressed alerts does not show
up in the rule preview table

Co-authored-by: Madi Caldwell <madison.caldwell@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-11-15 11:08:41 -08:00
Ersin Erdal
c5bcfd6762
Add flapping state object and interface in AAD index and Event Log (#143920)
* move flapping to kibana.alerting in event log

* move flapping back to under kibana.alert. Add integration tests

* add default flapping state to alert logs
2022-11-07 18:15:30 +01:00
Jonathan Budzenski
ab1bca56b2 fix codeowners 2022-11-04 08:21:31 -05:00
Tiago Costa
e41569b4a6
fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463)
* chore(NA): remove overrides for rootDir on packages

* chore(NA): replace './target_types' with 'target_types' on packages

* chore(NA): removes stripInternal false configs

* chore(NA): remove unused strip internals
2022-11-03 01:04:55 +00:00
Michael Olorunnisola
01d76ebd13
[Security Solution][Investigations] - Alert Details Summary Page (#141709)
* initialize alert details page

* fix checks

* fix types

* remove unused import

* update details page

* fix cases tests

* update based on PR feedback:

* disable filter in and filter out in alerts details page

* fix types

* PR feedback

* sync with main
2022-10-31 12:16:37 -07:00
spalger
52f2b33a07
[auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
spalger
e5d186a6f0
[ts] stop building @types packages in bootstrap 2022-10-28 14:03:55 -05:00
spalger
42879f7656
[bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
Chris Cowan
71aebb7024
[ResponseOps] Add kibana.alert.time_range field to Alert-As-Data mappings and populate it (#141309)
* [ResponseOps] Add kibana.alert.time_range field to Alert-As-Data mappings and populate it

* Fixing snapshots to match new reality

* Removing the lte (end of range) for active alerts.

* Fixing expected resutls for mapping test

* fixing tests

* updating readme

* Fixing field name in README

Co-authored-by: Faisal Kanout <faisal.kanout@elastic.co>
2022-10-04 13:53:59 -06:00
Spencer
32491462a9
add kibana.jsonc files to existing packages (#138965)
* [packages] add kibana.jsonc files

* auto-migrate to kibana.jsonc

* support interactive pkg id selection too

* remove old codeowners entry

* skip codeowners generation when .github/CODEOWNERS doesn't exist

* fall back to format validation if user is offline

* update question style

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-09-08 13:31:57 -07:00
Tiago Costa
1cbf83f73c
chore(NA): remove src folder requirement from packages (part 2) (#138476)
* refact(NA): apply root_input_dir=src to each already created pkg

* refact(NA): update package generator

* fix(NA): correctly use rootDir

* fix(NA): use root input dir on latest introduced pkgs for jsts_transpiler macro

* chore(NA): merge with main

* chore(NA): first attempt to complete removal of src folder on a small group of pkgs

* Revert "chore(NA): first attempt to complete removal of src folder on a small group of pkgs"

This reverts commit b6f34b7530.

* chore(NA): remove src folder requirement from xpack pkgs

* chore(NA): remove src folder from analytics pkgs

* chore(NA): remove src folder from home pkgs

* chore(NA): remove src folder from shared_ux pkgs

* fix(NA): remove missing src folder inputs on sharedux pkg

* chore(NA): remove src folder from kbn-a* pkgs

* chore(NA): remove src folder from kbn-b* pkgs

* chore(NA): remove src folder from kbn-c* pkgs

* chore(NA): correct exclude pattern for each changed pkg

* chore(NA): remove src folder from kbn-y* pkgs

* chore(NA): remove src folder from kbn-e* pkgs

* chore(NA): remove src folder from kbn-f* and kbn-g* pkgs

* chore(NA): remove src folder from kbn-f* and kbn-g* pkgs

* chore(NA): remove src folder from kbn-h** pkgs

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* Revert "chore(NA): remove src folder from kbn-h** pkgs"

This reverts commit dcdf72bcc1.

* fix(NA): grammar location

* test(NA): fix tests for kbn/config-schema

* test(NA): fix tests for kbn/config-schema

* chore(NA): multiple errors fixed

* chore(NA): remove kuery grammar fix

* fix(NA): @kbn/ace imports

* fix(NA): grammar location

* fix(NA): add missing files to tsconfigs

* [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs'

* chore(NA): complete tsconfigs

* Revert "chore(NA): complete tsconfigs"

This reverts commit f48c616864.

* chore(NA): remove src folder from kbn-core* pkgs

* chore(NA): remove src folder from kbn-u* pkgs

* chore(NA): remove src folder from kbn-ui-shared-deps* pkgs

* chore(NA): fix problems on core pkgs

* chore(NA): fix problems on core pkgs

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* fix(NA): shared_built_assets correct location'

* test(NA): update @kbn/optimizer integration snapshots

* chore(NA): remove src folder from kbn-t* p1 pkgs

* chore(NA): remove src folder from kbn-t* p2 pkgs

* chore(NA): update rootDir on utility types pkg

* chore(NA): include missing files on @kbn/test

* chore(NA): include missing files on @kbn/test

* fix(NA): new jest preset paths on @kbn/test

* chore(NA): fix eslint

* fix(NA): new jest preset paths on @kbn/test

* chore(NA): remove exclusion for mocks folde on @kbn/test

* fix(NA): several imports from target_node

* fix(NA): @kbn/test mocha and jest types clash

* chore(NA): remove src folder from kbn-storybook pkg

* chore(NA): remove src folder from kbn-stdio-dev-helpers pkg

* chore(NA): remove src folder from kbn-std pkg

* chore(NA): remove src folder from kbn-sort-pkg-json pkg

* chore(NA): remove src folder from kbn-some-dev-log and kbn-shared-ux-utility pkgs

* chore(NA): remove src folder from kbn-ux-storybook pkg

* chore(NA): remove src folder from kbn-shared-ux-services pkg

* chore(NA): remove src folder from kbn-shared-ux-components pkg

* chore(NA): remove src folder from kbn-shared-svg pkg

* chore(NA): remove src folder from kbn-server-http-tools pkg

* chore(NA): remove src folder from kbn-securitysolution-* pkgs

* chore(NA): remove src folder from kbn-r-* pkgs

* chore(NA): remove src folder from kbn-p* pkgs

* chore(NA): remove src folder from kbn-o* pkgs

* chore(NA): remove src folder from kbn-m* pkgs

* chore(NA): remove src folder from kbn-j,k,l* pkgs

* chore(NA): remove src folder from kbn-j,k,l* pkgs

* chore(NA): remove src folder from kbn-io-ts-utils* pkgs

* chore(NA): remove src folder from kbn-* pkgs except a few

* chore(NA): update @kbn/generate

* fix(NA): wrong exclusion on kbn-storybook

* chore(NA): remove src folder from kbn-monaco pkg

* chore(NA): remove src folder from kbn-interpreter pkg

* fix(NA): wrong exclusion on kbn-storybook

* chore(NA): update every require for target_*/src

* chore(NA): remover src folder from @kbn/handlebars

* fix(NA): license for @kbn/handlebars

* chore(NA): copy templates as part of the jsts_transpiler macro for @kbn/storybook

* chore(NA): update handlebars

* fix(NA): @kbn/plugin-generator import paths

* fix(NA): bundle sizes

* fix(NA): web bundle for @kbn/i18n-react

* Revert "fix(NA): bundle sizes"

This reverts commit 8aefe84fbc.

* Revert "Revert "fix(NA): bundle sizes""

This reverts commit e9d87d72a4.

* fix(NA): @kbn/docs-utils index.ts path expectation

* chore(NA): merge and solve conflicts with main

* fix(NA): relative import to index

* chore(NA): merge and solve conflicts with main

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* chore(NA): apply eslint fix

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-08-30 15:57:35 +01:00
Tiago Costa
df8b62aa98
chore(NA): allow packages to not have an obligation for a src folder on packages (#138038)
* refact(NA): apply root_input_dir=src to each already created pkg

* refact(NA): update package generator

* fix(NA): correctly use rootDir

* fix(NA): use root input dir on latest introduced pkgs for jsts_transpiler macro

* chore(NA): merge with main

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-08-08 15:54:05 +01:00
Spencer
a3b2757e4e
[type-summarizer] reimplement for broader support (#135163)
* [type-summarizer] reimplement for broader support

* Enable sourceMaps in all packages

* include naming collision in summarizePackage test

* fix readmes

* remove unnecessary transient dependency

* remove code that was commented out

* remove outdated todo comment

* ensure errors triggered by untyped-exports are ligible

* remove unused import

* break out snippet generation from AstIndexer

* refactor several massive files into smaller pieces and add more inline docs

* fix typos

* update jest snapshots

* add sections to readme that points people to the useful parts of the source code along with a high-level overview of how the type-summarizer works

* remove --dump flag, it doesn't work

* use decName instead of calling names.get a second time

* include `export` as invalid name
2022-07-06 13:48:45 -05:00
Alejandro Fernández Haro
f7a1739dc0
Use target_web to ensure browser compatibility (#130874) 2022-05-05 21:20:51 +02:00
Marshall Main
482f819a05
[Security Solution][Alerts] Replace schemas derived from FieldMaps with versioned alert schema (#127218)
* Replace schemas derived from FieldMaps with versioned alert schema

* Import fixes and comment

* Another import fix

* Separate read and write schemas

* Separate read and write schemas for common alert fields

* fix import

* Update ALERT_RULE_PARAMETERS type

* Fix getField type

* Fix more types

* Remove unneeded index signature from PersistenceAlertServiceResult

* Fix types and tests

* Update comment describing new schema process

* Update Ancestor800 type

* Add modified PR description as initial README

* Remove duplication in CommonAlertFields definition

* Add explicit undefined value for rule in mock

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-03-29 20:11:55 -07:00
Madison Caldwell
11bba0a04b
[Security Solution] Consider exceptions when loading threshold alert timelines (#128495)
* Add exceptions to threshold timeline

* Tests and error handling

* Fix unit tests

* Add alias for exceptions filter

* Fix tests

* Type fixes

Co-authored-by: Marshall Main <marshall.main@elastic.co>
2022-03-29 15:09:55 -04:00
Spencer
614139b8e5
[bazel] avoid a little boilerplate in packages (#126309)
* [bazel] avoid a little boilerplate for @types packages

* [bazel/ts] stop building sourcemaps since they're ignored
2022-02-24 12:43:12 -06:00
Garrett Spong
48693d1fd6
[RAC][Alerting][Security Solution] Adds Rule Execution UUID (#113058)
## Summary

Resolves: https://github.com/elastic/kibana/issues/110135

This PR is for introducing a new UUID (`kibana.alert.rule.execution.uuid` as defined in the AAD schema) for identifying individual rule executions. This id is introduced as a `private readonly` member of the [alerting server task_manager](a993668663/x-pack/plugins/alerting/server/task_runner/task_runner.ts (L123)), and plumbed through the `executionHandler` and to all appropriate alert event and event-log touch points.

For persistence when writing alerts within the RuleRegistry, `kibana.alert.rule.execution.uuid` is plumbed through [`getCommonAlertFields()`](c81341c325/x-pack/plugins/rule_registry/server/utils/get_common_alert_fields.ts (L52)) so it is grouped with like fields and is picked up by both the [`createPersistenceRuleTypeWrapper`](c81341c325/x-pack/plugins/rule_registry/server/utils/create_persistence_rule_type_wrapper.ts (L38)) used by Security Solution, and [`createLifecycleExecutor`](d152ca5b6b/x-pack/plugins/rule_registry/server/utils/create_lifecycle_executor.ts (L157)) used by Observability rules.

Additionally on the Security Solution side, `kibana.alert.rule.execution.uuid` was plumbed through the `RuleExecutionLog` so that all events written to the event-log will now include this id so individual rule status events/metrics can be correlated with specific rule executions.

No UI facing changes were made, however `kibana.alert.rule.execution.uuid` is now available within the Alerts Table FieldBrowser, and can be toggled and viewed alongside alerts:

<p align="center">
  <img width="500" src="https://user-images.githubusercontent.com/2946766/149594433-b16e369b-adf4-4ae3-b6e9-98189b214d51.png" />
</p>

As visible when exploring `event-log` in Discover:

<p align="center">
  <img width="500" src="https://user-images.githubusercontent.com/2946766/149595237-155d25d7-8324-4981-9ec2-faf0af8e7bd7.png" />
</p>



### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials 
  - Will need to sync with Doc folks on updates here.
- [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
2022-01-20 18:47:36 -07:00
Mikhail Shustov
38feafad72
Update ES client to canary.37 (#119791)
* upgrade es client to canary 37

* fix error in core

* mute error in test/

* mute incompatible errors

* unskip request_entity_too_large_exception test

* commit autofix

* unskip batch_size_bytes_exceeds_es_content_length test

* fix errors in Core code

* fix or mute errors in data plugin

* fix data_view_management

* fix error index_management

* fix x-pack/test errors

* fix watcher

* fix event_log

* fix data_enhanced

* fix uptime

* fix triggers_actions_ui

* fix transform

* fix reporting

* fix rule_registry

* fix timeline

* fix task_manager

* fix security_solution

* fix rule_registry

* fix fleet

* fix index_management

* fix lens

* fix maps

* fix ml

* fix observability

* bump to canary 8.1-2

* fix error in packages

* fix errors in core

* fix errors in data

* fix errors in discover

* fix some discover tests

* fix errors in telemetry

* fix alerting

* fix errors in apm

* fix errors in event_log

* fix errors in fleet

* fix errors in infra

* fix errors in lists

* mute errors in maps

* fix errors in ml

* fix errors in osquery

* fix errors in security_solution

* fix errors in stack_alerts

* fix errors in task_manager

* fix errors in timelines

* fix errors in transform

* fix errors in watcher

* fix errors in tests

* update docs

* adjust fleet code

* fix problem in fleet

* remove outdated _type from data plugin tests

* fix packages tests

* update type

* fix tests part 2

* Adds product header back to elasticsearch

* Updates API docs

* Fix Discover tests

* update alerting typings

* Fix type errors

* Import Sort type

* Update x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_server.ts

Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>

* Remove double negation

* Fix snapshot conflict issues after merge from "main"

Co-authored-by: Christiane Heiligers <christiane.heiligers@elastic.co>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alejandro Fernández Haro <afharo@gmail.com>
Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
2021-12-24 14:43:53 +01:00
Tiago Costa
aa6fe695af
chore(NA): splits types from code on @kbn/rule-data-utils (#121535)
* chore(NA): splits types from code on @kbn/rule-data-utils

* chore(NA): remove old style imports for this pkg

* chore(NA): eslint fix

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-12-20 20:41:46 +00:00
Marshall Main
e59a8feaa4
[Security Solution] Remove extra rule fields from kibana.alert.rule (#121135)
* Remove kibana.alert.rule.risk_score and severity

* Fix tests related to risk_score and severity

* Make translation a template

* Can't use expression in template literal

* Remove commented line added by bad merge

* Fix linting

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-12-17 13:23:27 -08:00
mgiota
cdd66ea0eb
[RAC][Observability] Use flattened type for rule params in Observability (#120758)
* add kibana.alert.rule.parameters as a flattened type

* temp

* rule_data_formatter

* fix bug in search strategy with flattend field type where prefix was wrong (kibana.alert.rule.parameters was ignored)

* fix inventory rule data formatters

* remove console log

* hack that prepends kibana.alerts.rule.parameters in the nested subfields

* import ALERT_RULE_PARAMETERS from kbn rule data utils

* remove console log

* format custom metric link

* remove ALERT_PARAMS from technical field names

* fix bug in timelines plugin to use dotField instead of prependField & fix failing tests

* remove console log and unused variable

* delete kibana.alert.rule.params from the mapping

* flatten kibana.alert.rule.parameters and add some unit tests

* fix rule_data_formatter

* handle scenario of having multiple items in an array (multiple conditions setup in the rule)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-12-16 21:29:06 +01:00
Marshall Main
ba48a7eaa2
[RAC][Security Solution] Add flattened parameters object and populate it in Security Solution (#120698)
* Add flattend parameters object and populate it in Security Solution

* Fix severity, risk_score, bugs, tests

* Add ALERT_RULE_PARAMETERS to package

* Skip tightly coupled test

* fix more tests

* Remove unused import

* Fix threat matching API test

* Continue overriding kibana.alert.rule.risk_score and severity for now

* Add ignore_above to ALERT_RULE_PARAMETERS

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-12-14 11:45:29 -05:00
Tiago Costa
662f491251
chore(NA): splits types from code on @kbn/es-query (#120783)
* chore(NA): splits types from code on @kbn/es-query

* chore(NA): add missing type exports

* chore(NA): export types as types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-12-09 02:49:30 +00:00
Garrett Spong
3d9bfe2972
[Security Solution][Detections] Updates RuleDetails to query alerts by RuleId instead of Rule SO ID (#120053)
* Switches RuleDetails to query alerts by ruleId instead of SO id

* Increases integrity of test outputs

* Cleans up duplicate RuleRegistry functions

* Removes support for rule.id for alerts filter and updates exceptions to use new filter
2021-12-07 17:12:21 -07:00
mgiota
8d16f6086e
remove kibana.consumers from technical field names (#120173) 2021-12-01 15:28:50 -07:00
Spencer
0f68fcf5af
[kbn/rule-data-utils] add submodules and require public use them (#117963)
* [kbn/rule-data-utils] add submodules and require public use them

* fix lint errors

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-11-15 15:23:52 -07:00
Tyler Smalley
139a3c9866
[ci] Run Jest tests in parallel (#117188)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
2021-11-09 11:25:25 -08:00
Tyler Smalley
98de5f673c Revert "[ci] Run Jest tests in parallel (#115687)"
This reverts commit 237d68d6e9.
2021-11-02 10:05:55 -07:00
Tyler Smalley
237d68d6e9
[ci] Run Jest tests in parallel (#115687)
* [ci] Run Jest tests in parallel

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Disable coverage

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Make hourly match prs

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Update timeout

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* mock process.execArgv so that it is consistent

* Remove comment

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-11-02 08:53:07 -07:00
Madison Caldwell
117efdf87f
[RAC][Security Solution] Adds migration to new SecuritySolution rule types (#112113)
* Initial commit

* Properly handle signal history

* Fix #95258 - cardinality sort bug

* Init threshold rule

* Create working threshold rule

* Fix threshold signal generation

* Fix tests

* Update mappings

* ALERT_TYPE_ID => RULE_TYPE_ID

* Add tests

* Fix types

* Adds RAC rule type migration

* Fix threshold tests (remove outputIndex)

* Add threshold rule type to ruleTypeMappings

* Add kbn-securitysolution-rules package for sharing with alerting framework

* Fix type errors

* Fix find_rules tests

* First round of test fixes

* Fix issues from merge conflicts

* Use ruleDataClient getReader() for reading

* Fixes to 'generating_signals' tests

* Remove more refs to legacy schema

* Linting

* Quick type fix

* Bug fixes

* Add saved query rule type

* Linting

* Fix types

* Signal generation tests

* Test updates

* Update some more refs

* build_alert tests

* Cleanup

* Ref updates

* Revert "Ref updates"

This reverts commit 4d1473d6b0.

* Update status field

* Test fixes

* Another test

* Got a little too aggressive with search/replace

* let's see where we're at

* Fix

* Test fixes

* cleanup

* Fix cases API integration test config, flaky DE tests

* Move flattenWithPrefix to package / skip signal migration tests

* Fix unit tests

* Use new schema for bulk rule creation

* event: { kind } => event.kind

* Fix signal migration API tests

* Fix ml integration test

* Fix threat match integration tests

* Fix ML rule type tests and add correct producer to all rule types

* Update threat match API integration test

* Remove dupe properties

* Type fix

* Fix ML producer in functional test

* Fix generating_signals tests

* Remove usage of RuleDataClient-based execution log client

* Don't check output index version if rule registry enabled

* Fix bulk duplicate rule

* Fix duplicate rule test

* Fix readPrivileges and timestamp check logic

* Fixes for eql and exceptions tests... disable open_close_signals

* Type fixes / keyword test fixes

* Additional test fixes

* Unit test fixes + signal -> kibana.alert

* Test fixes for exceptions

* Fix read_resolve_rules test

* Various test fixes with marshallmain

* Sort search results

* Fix create_rules tests

* Disable writer cache for integration tests

* Disable writer cache for cases integration tests

* Fix types in rule_data_plugin_service

* Fix ordering in exceptions tests

* Remove rule_registry.enabled flag

* Fix signals migration tests

* Don't check signals index before creation

* Fix cypress config

* Fix type error

* create_migrations tests

* Skip flaky test

* Helpful comment

* Fixes from merge conflicts

* Pretend that signals index exists

* Fix type errors

* Skip flaky tests

* Fix threat matching test

* Clean up

* Reverting default ruleRegistry experimental flag (breaks unit tests)

* Reenable rule registry experimental feature by default

* Execute DE rule migration in 8.0

Co-authored-by: Marshall Main <marshall.main@elastic.co>
2021-10-26 16:56:40 -04:00
Mikhail Shustov
3c8fa527a7
[ES] Upgrade client to v8.0 (#113950)
* bump to a pre-8.0 version

* export KibanaClient from /lib sub-folder

* workaround the problem of the absence of estypes

* update es client usage in pacakges

* export estypes from another path

* import errors from root

* import errors from root 2

* update transport import

* update import path for /api/types

* update import path for /api/types

* import errors from top export

* use TransportResult instead if ApiResponse

* fix errors in client_config

* fix src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts

* use KibanaClient in mock. we dont export the original Client

* fix client mocks

* fix errors on SO

* fix remaining core errors

* update estype import path

* fix errors in data plugin

* fix data_views

* fix es_ui_shared

* fix errors in interactive_setup

* fix errors in ./test folder

* add @elastic/transport to the runtime deps

* fix errors in packages

* fix erros in src/core

* fix errors in test/

* fix an error in actions plugin

* woraround and fix errors in APM plugin

* fix errors in canvas

* fix errors in event_log

* fix errors in fleet

* fix errors in ILM

* fix errors in infra

* fix errors in ingest_pipeline

* fix errors in lens

* fix errors in license_management

* fix errors in licensing

* fix errors in logstash

* fix errors in ml

* fix errors in monitoring

* fix errors in observability

* fix errors in rule_registry

* fix errors in reporting

* fix errors in rule_registry

* fix errors in security

* fix errors in security_solution

* fix errors in snapshot_restore

* fix errors in transform

* fix errors in UA

* fix errors in uptime

* fix errors in x-pack/test

* fix eslint errors

* fix new errors

* use default HTTP Connection. Undici does not support agent config options keepAlive and maxSockets

* create does not accept require_alias option

* update deps

* use transport types exported from ES client package

* fix ErrorCause | string errors

* do not use enum

* fix errors in data plugin

* update x-pack code

* fix transport

* fix apm search request

* do not crash on reporting

* fix kbn-test build

* mute reporting error to start

* fix ftr build

* another attempt

* update import path

* address or mute new errors

* REMOVE me. pin transport version temporarily.

* remove deep imports from transport package

* fix jest crash

* fix product check tests

* remove unnecessary ts-expect-error

* fix a few failed unit tests

* bump to canary 24

* remove unnecessary ts-expect-error

* remove dependency on transport

* fix types in tests

* mute errors in xpack tests

* product check doesn;t  spam in logs anymore

* filterPath --> filter_path

* ignoreUnavailable --> ignore_unavailable

* ignoreUnavailable --> ignore_unavailable

* trackScores --> track_scores

* trackTotalHits --> track_total_hits

* fix es-arcives

* fix data plugin crashes

* fix watcher test utils

* rollback unnecessary changes

* fix another problem in es-archiver

* fix scroll. for whatever reason scroll fails when request scroll_id in body

* add meta: true in kbn-securitysolution-es-utils

* bump client to canary 25

* fix errors in accordance with the es client spec

* update securityscolution-es-utils

* unify scroll api in reporting and fix tests

* fix unit tests in watcher

* refactor APM to abort request with AbortController API

* fix missing es client calls in tests

* fix missing meta in detection engine FTR tests

* fix another bunch of errors in js tests

* fix wrong coercion

* remove test-grep pattern

* fix apm unit test

* rename terminateAfter to terminate_after in infra plugin

* rename terminateAfter to terminate_after in uptime plugin

* rename terminateAfter to terminate_after in apm plugin

* fix security roles FTR tests

* fix reference

* fix post_privilidges test

* fix post_privilidges

* bump client to 26

* add meta for index_management test helpers

* remove ts-expect-error caused by bad type in reason

* bump client to 27

* REMOVE me. workaround until fixed in the es client

* fix incorrect type casting

* swtich from camelCase params

* use `HttpConnection` for FTR-related clients

* bump client to 29

* Revert "REMOVE me. workaround until fixed in the es client"

This reverts commit c038850c09.

* fix new util

* revert repository changes

* do not crash if cannot store event_loop data

* fix new estypes imports

* fix more types

* fix security test types and add ts-ignore for custom ES client

* fix more estypes imports

* yet more ts violations

* line by line fixing is hard

* adapt `evaluateAlert` from infra as it's also used from FTR tests

* use convertToKibanaClient in FTR test instead of meta:true in plugin code

* migrate from deprecated API in fleet

* fix intergration tests

* fix fleet tests

* fix another fleet test

* fix more tests

* let's call it a day

* Removes custom header check on 404 responses, includes es client ProductNotSupportedError in EsUnavailableError conditional (#116029)

* Removes custom header check on 404 responses, includes es client ProductNotSupportedError in EsUnavailableError conditional

* Updates proxy response integration test

* disable APM until compatible with client v8

* skip async_search FTR test

* use kbnClient in integration tests

* bump version to 29

* bump to 30

* have configureClient return a KibanaClient instead of Client, remove resolved violations.

* bump to 31

* bump to 31

* Revert "bump to 31"

This reverts commit 5ac713e640.

* trigger stop to unusubscribe

* update generated docs

* remove obsolete test

* put "as" back

* cleanup

* skip test

* remove new type errors in apm package

* remove ErrorCause casting

* update a comment

* bump version to 32

* remove unnecessary ts-expect-error in apm code

* update comments

* update to client v33

* remove outdated type definition

* bump to 34 without params mutation

* unskip the test that should not fail anymore

* remove unnecessary ts-expect-error comments

* update to v35. body can be string

* move `sort` to body and use body friendly syntax

* fix a failing test. maps register the same SO that has been already registered by home

Co-authored-by: pgayvallet <pierre.gayvallet@gmail.com>
Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co>
2021-10-26 14:08:22 +02:00
Alejandro Fernández Gómez
685f58579d
[RAC] Store rule params in the alert document (#113429)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-10-05 18:21:30 +02:00
Tiago Costa
7c4e4f507b
chore(NA): replace babel config files by inline presets by default in the jsts_transpiler rule (#110620)
* chore(NA): replace babel config files by inline presets by default in the js_ts_transpiler rule

* chore(NA): update @kbn/ace build to exclude worker file

* chore(NA): remove config file support

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-09-03 21:17:46 +01:00
Marshall Main
f58865c1f5
[Rule Registry][RAC] Rename kibana.alert.id to kibana.alert.instance.id (#110528)
* Rename kibana.alert.id to kibana.alert.instance.id

* Update test snapshot

* Fix test

* One more fix
2021-09-01 16:56:49 -04:00
Felix Stürmer
137c182761
[RAC] Populate common rule fields in alert helpers (#108679)
Co-authored-by: mgiota <panagiota.mitsopoulou@elastic.co>
2021-08-26 09:19:51 -04:00
Georgii Gorbachev
8ce1d10791
[RAC] Fix index names used by RBAC, delete hardcoded map of Kibana features to index names (#109567)
**Ticket:** https://github.com/elastic/kibana/issues/102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of https://github.com/elastic/kibana/pull/109346 and replaces https://github.com/elastic/kibana/pull/108872.

TODO:

- [x] Address https://github.com/elastic/kibana/pull/109346#pullrequestreview-735158370
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close https://github.com/elastic/kibana/pull/108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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
2021-08-25 16:29:16 +02:00
mgiota
8c8dca6ad2
[RAC] [Observability] Use simpler alert severity level mapping (#109068)
* [RAC][Observability] remove severity fields from mapping keep only ALERT_SEVERITY

* temporarily remove severity value occurences

* remove ALERT_SEVERITY_VALUE occurences, this value is not being read and shown in the Observability alerts table

* remove duplicate ALERT_SEVERITY identifier

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-18 16:29:24 -04:00
Yara Tercero
9fa41d1aef
[Security Solution] - Updating UI to work with new kibana privileges abstraction on alerts (#108961)
## Summary

Holy moly. 

What is happening in this PR? 🤷🏽‍♀️ Let's break it down:
- Added a package `@kbn/alerts` - another one?! ...yes
  - This is meant to add shared hooks and components around alerts as data
  - `useGetUserAlertsPermissions` - accepts the Kibana capabilities object and returns whether the user has `read` and `crud` alerts privileges
  - `AlertsFeatureNoPermissions` - component displayed when user does not have alerts privileges
- UI changes for user with NO alerts privileges
  - `Alerts` tab hidden in security solution side navigation
  - `Alerts` tab hidden in rule details page  
- UI changes for user with alerts READ ONLY privileges
  - alerts checkboxes hidden in alerts table
  - alerts bulk actions hidden in alerts table
2021-08-18 14:48:31 -04:00
Marshall Main
05d1e326a4
[RAC][Security Solution] Remove ALERT_RULE_ID in favor of ALERT_RULE_UUID (#108922)
* Remove ALERT_RULE_ID in favor of ALERT_RULE_UUID

* Update snapshot

* KEVINNN

* fix test

* Add back home.disableWelcomeScreen=true

* Only disable welcome screen in security solution cypress tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-18 10:37:14 -04:00
Dominique Clarke
15494cd25f
uptime - index default severity of warning for tls and monitor status alerts (#108731)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-17 12:10:00 -04:00
Kerry Gallagher
85e07662d8
[RAC] Disable RAC multi-tenancy (#108506)
* Disable RAC multi-tenancy
2021-08-16 20:01:27 +01:00
Dominique Clarke
024eeed3c3
[Uptime] adjust RAC RBAC and index settings (#108200)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-16 14:01:01 -04:00
Sergi Massaneda
a7661a553c
[TGrid] Alerts status update use RAC api (#108092)
Co-authored-by: Devin Hurley <devin.hurley@elastic.co>
2021-08-13 22:11:53 -04:00
Tiago Costa
dfaf54082a
chore(NA): moving @kbn/rule-data-utils to babel transpiler (#107573)
* chore(NA): moving @kbn/rule-data-utils to babel transpiler

* chore(NA): update imports

* chore(NA): targetted imports for apm

* chore(NA): fix imports

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-08-11 15:59:21 +01:00
Yara Tercero
cec5d3f27a
[RAC] - Update field names (#107857)
### Summary
### Fields used moving forward
`kibana.alert.rule.consumer` will refer to the context in which a rule instance is created. Rules created in:
- stack --> `alerts`
- security solution --> `siem`
- apm --> `apm`

`kibana.alert.rule.producer` will refer to the plugin that registered a rule type. Rules registered in:
- stack --> `alerts`
- security solution --> `siem`
- apm --> `apm`

So an `apm.error_rate` rule created in stack will have:
- consumer: `alerts` and producer: `apm`
 An `apm.error_rate` rule created in apm will have:
- consumer: `apm` and producer: `apm`

`kibana.alert.rule.rule_type_id` will refer to a rule's rule type id. Examples:
- `apm.error_rate`
- `siem.signals`
- `siem.threshold`

Also renamed the following because `rule.*` fields are meant to be ecs fields pulled from the source/event document, not refer to our rule fields.
`rule.name` --> `kibana.alert.rule.name` will refer to the rule's name.

`rule.category` --> `kibana.alert.rule.category` will refer to the rule's category.

`rule.id` --> `kibana.alert.rule.uuid` will refer to the rule's uuid.
2021-08-11 06:25:46 -04:00
Spencer
c0395c9ef6
[build_ts_refs] improve caches, allow building a subset of projects (#107981)
* [build_ts_refs] improve caches, allow building a subset of projects

* cleanup project def script and update refs in type check script

* rename browser_bazel config to avoid kebab-case

* remove execInProjects() helper

* list references for tsconfig.types.json for api-extractor workload

* disable composite features of tsconfig.types.json for api-extractor

* set declaration: true to avoid weird debug error

* fix jest tests

Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-08-10 22:12:45 -07:00
Devin W. Hurley
ab43afab88
[RAC] [RBAC] Adds bulk update route to rule registry and bulk update function to alerts client (#106297)
Adds a bulk update route (POST /internal/rac/alerts/bulk_update) to the rule registry and bulkUpdate function to the alerts as data client.
2021-08-09 15:39:48 -04:00
Xavier Mouligneau
923eca0adf
[RAC] integrating rbac search strategy with alert table (#107242)
### Summary

We are integrating alert search strategy with RBAC on top of alert tables for security solution and o11y.
2021-08-05 21:10:27 -04:00