Commit graph

7665 commits

Author SHA1 Message Date
Ryland Herrick
9e911469a3
[SIEM] Fix patching of ML Rules (#60830)
* Allow ML Rules to be patched

* Test passing of params from our patch routes to our helpers

Since patchRules accepts a partial there's no way to verify this in
typescript, we need regression tests instead.

* Update lists when importing with overwrite

This was simply missed earlier.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 21:32:51 -05:00
Oliver Gupte
9de2d815fc
[APM] Service Map - Separate overlapping edges by rotating nodes (#60477)
* Adds rotation transform which does the top->bottom to left->right
transformation + an extra 5 degrees which results in taxi edges
separating when rendered.

* PR feedback to reduce edge width on hover, and assure that connected
edges are highlighted when node is selected/focused

* update disabled kuery bar placeholder text for service map
2020-03-20 18:56:08 -07:00
Patrick Mueller
e73159281e
[Alerting] fix flaky test for index threshold grouping (#60792)
resolves https://github.com/elastic/kibana/issues/60744

This is a fairly complex test, with alerts that run actions that write to
an index which we then do queries over.  The tests didn't account for some
slop in all that async activity, but now should be about as flake-free as they
can be.
2020-03-20 20:00:47 -04:00
Frank Hassanabad
74ceceb324
[SIEM][Detection Engine] Adds test scripts for machine learning feature
## Summary

* Adds ad-hoc testing scripts for machine learning feature

## Testing

```ts
./post_rule.sh ./rules/queries/query_with_machine_learning.json
./update_rule.sh ./rules/updates/update_machine_learning.json
./patch_rule.sh ./rules/patches/update_machine_learning.json
```
2020-03-20 17:33:09 -06:00
kqualters-elastic
677055f3ad
Flatten child api response for resolver (#60810) 2020-03-20 18:07:41 -04:00
Brittany Joiner
0bf199757f
Change "url" to "urls" in APM agent instructions (#60790) 2020-03-20 17:05:46 -05:00
Steph Milovic
cf9b64eada
[SIEM] [Cases] Create case from timeline (#60711) 2020-03-20 15:14:09 -06:00
Wylie Conlon
fc24febec9
[Lens] Resetting a layer generates new suggestions (#60674)
* [Lens] Resetting a layer generates new suggestions

* Include preview in tests
2020-03-20 17:03:59 -04:00
MadameSheema
5d93a0890c
increases loading timeout (#60788) 2020-03-20 21:52:26 +01:00
Patrick Mueller
5efd59b43f
[Alerting]: harden APIs of built-in alert index-threshold (#60702)
resolves https://github.com/elastic/kibana/issues/59889

The index threshold APIs - used by both the index threshold UI and the
alert executor - were returning errors (500's from http endpoints) when
getting errors from ES.

These have been changed so that the error is logged as a warning, and the
relevant API returns an "empty" result.

Another 500 response was found while experimenting with this.  Apparently
the date_range agg requires a date format to be passed in if the date format
in ES is not an ISO date.  The repro on this was to select the `.security`
alias (or it's index) within the index threshold alert UI, and then select
one of it's date fields.
2020-03-20 16:36:01 -04:00
Paul Tavares
7983d1dff7
[Endpoint] Integrate the Policy list with ingest datasources api (#60548)
* Use ingest API to get endpoint datasources

* Add `application` service to `KibanaContextProvider`

* Adjust Policy list to show data available from API

* Added ingest service + refactored middleware

* handle api failures/errors

* Removed policy list fake_data generator

* Fix typing

* Rename method + added explicit return type

* move dispatch outside of try block

* Removed unnecessary action

* Added FIXME comments with link to issue

* Skip some functional tests

* added tests for ingest service

* Policy list tests - turn it all off

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 16:32:55 -04:00
Catherine Liu
ca55db53c1
[Canvas] Switch to using EUI SuperDatePicker in time filter el… (#59249)
* Replaced custom custom time filter component with EuiSuperDatePicker

* Added advanced settings dateFormat and timepicker:quickRanges to time filter

* Round up end date in time filter

* Updated snapshots

* Fixed timefilter function

* Fixed import

* reduce margin between datepicker and selection border (#59498)

* Added time_filter renderer stories

* Updated storyshots

* Updated timefilter element thumbnail

* Updated snapshots

* Used Filter type instead of any

* Renamed timefilter components folder

* Removed unused time range i18n strings

* Updated translations

* BROKEN

* Updated snapshots

* Revert "BROKEN"

This reverts commit e3b8bd7865.

* Fix time-filter element preview image

* Upated time filter preview image

* Fix time-filter renderer

* fixed storybook tests

* Fixed time filter renderer
2020-03-20 13:32:01 -07:00
Chandler Prall
0bf62cbf3e
Upgrade EUI to 21.0.1 (#60282)
* update to eui 21.0.1

* most changes needed for search bar ts changes

* Passing types

* snapshots

* jest tests

* Removed IQuery placeholder types

* Updated functional test to only look at table headers with content

* Moved 'filters' definition around in api docs

* Update types

* update snapshot

* typo

* Move DATA_FRAME_TASK_STATE enum to its own file to fix x-pack functional test config imports

* merge public api 'changes'

Co-authored-by: patrykkopycinski <patryk.kopycinski@elastic.co>
Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
2020-03-20 14:07:04 -06:00
Tim Sullivan
d896292b6f
[Reporting] revert skip telemetry step (#60450)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 12:37:22 -07:00
Jen Huang
b01832249d
[Ingest] Support input-level config fields (#60594)
* Support input-level config fields

* Adjust tests

* Adjust server schema
2020-03-20 12:18:07 -07:00
Yuliia Naumenko
67a01a71bd
Removed restriction on adding multiple connectors of the same action type to an alert (#60720)
* Allows multiple action under the same connector for alert

* Fixed due to comments

* fixed ui issue
2020-03-20 12:14:32 -07:00
Wylie Conlon
6d1479fc08
[Lens] Fix bug when removing dimensions from non-XY chart (#60704) 2020-03-20 14:59:51 -04:00
Gidi Meir Morris
ce0722b558
[Alerting] retains empty AlertsList when filter has removed all items (#60501)
Ensure that when the filtering on the AlertList removes all items we show the empty list rather than the Create Your First Alert CTA
2020-03-20 18:49:16 +00:00
Nathan L Smith
b5f460fb6e
Remove all client-side map munging (#60701)
Remove the getCytoscapeElements function.

On the server:

* Replace `source` with `sourceData`, `destination` with `targetData`, `source.id` with `source`, and `destination.id` with `target`.
* Return a single array as an `elements` property instead of `nodes` and `connections`
* Map all of the items data to be inside of a `data` object
* Replace SERVICE_AGENT_NAME with AGENT_NAME
* Add some missing constants

On the client:

* Remove getCytoscapeElements
* Move all presentation-specific data transformation to use the original attributes in the place where they're needed
* Remove `href` since it wasn't being used
* Move BetaBadge to its own file
* Move cytoscapeDivStyle to cytoscapeOptions
* Fix storybook to work with new data formats
2020-03-20 13:14:39 -05:00
Chris Roberson
3a396027f6
[Monitoring] Migrate server to NP (#56675)
* First pass

* First pass

* Add new routes

* Getting closer

* Remove legacy server code, and other fixes

* Register the plugin with xpack

* Pass a legacy client to telemetry

* Suport callWithInternalUser

* Remove this

* More NP work

* Fix some tests

* Fix broken test

* Move over new telemetry changes, and fix other issues

* Fix TODO item

* Reuse the same schema as elasticsearch module

* Use a singular config definition here

* Disable this for now

* Use the right method

* Use custom config again

* Tweak the config to make this optional

* Remove these

* Remove these unnecessary files

* Fix jest test

* Fix some linting issues

* Fix type issue

* Fix localization issues

* Use the elasticsearch config

* Remove todos

* Fix this check

* Move kibana alerting over

* PR feedback

* Use new metrics core service

* Change config for xpack_api_polling_frequency_millis

* Make sure this is disabled for now

* Disable both

* Update this to the new function

* Tighten up legacy api needs

* Check for existence

* Fix jest tests

* Cleaning up the plugin definition

* Create custom type in our plugin

* Revert this change

* Fix CI issues

* Add these tests back

* Just use a different collector type

* Handle errors better

* Use custom type

* PR feedback

* Fix type issues

* PR feedback
2020-03-20 14:02:15 -04:00
Gidi Meir Morris
da2ec4bf40
[alerting] fixes View In App Functional test (#60606)
Enables the FT that tests the View inApp functionality.
It addresses an issue that causes a race condition on CI where the ViewInApp button was thought to be enabled when it was, in fact, still disabled.
This meant that the click on the button didn't trigger the handler which, in turn, made the test fail.
2020-03-20 17:42:25 +00:00
Gidi Meir Morris
55814addac
[Alerting] Unifies the use of a single constant for Api urls in alerting & actions (#60430)
Unifies the use of a single constant for Api urls in alerting & actions
2020-03-20 17:39:07 +00:00
Nicolas Chaulet
558aaaa8ba
[Fleet] Create a fleet_enroll user and role during fleet setup (#60562) 2020-03-20 13:31:56 -04:00
Nathan Reese
103f217964
[Maps] convert Vector style descriptor to typescript (#60526)
* vector style descriptor TS

* revert color_utils TS conversion

* clean up TS errors

* updated blended layer to use vector style descriptor type

* fix eslint error

* use FIELD_ORIGIN.SOURCE instead of SOURCE_DATA_ID_ORIGIN

* fix other incorrect uses of SOURCE_DATA_ID_ORIGIN

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 11:29:31 -06:00
Melissa Alvarez
c9cc04423d
[ML] Data Visualizer: error toast shows error text (#60682)
* dataviz searchbar:update error toast with full message

* update error toast title
2020-03-20 13:04:08 -04:00
Jen Huang
22f14b53cd
Fix config value type and schema (#60688) 2020-03-20 09:54:01 -07:00
Marco Vettorello
88612743a9
Update dependency @elastic/charts to v18.1.0 (#60578) 2020-03-20 17:37:11 +01:00
Daniil Suleiman
1a1e2e7b2e
[NP] Remove ui/agg_types dependencies and move paginated table to kibana_legacy (#60276)
* fix agg type shims and move paginated table to kibana_legacy

* fix types

* fix i18n ids

* fix unit tests

* Update imports

* Remove ui/agg_types imports

* Clean up vis_default_editor plugin

* Remove agg_types imports in vis_type_table

* Clean up x-pack

* Clean up vis_type_vislib

* Last cleanups

* Update docs

* Mock Schemas in vis_type_metric

* Use data plugin mocks

* Remove ui/directives/paginate reference

* Remove snapshot

* Remove shallow

Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 18:39:44 +03:00
patrykkopycinski
87e07ef64f
[SIEM] Fix types in rules tests (#60736)
* [SIEM] Fix types in rules tests

* Update create_rules.test.ts

* Update create_rules.test.ts
2020-03-20 14:57:07 +00:00
Gidi Meir Morris
4c19cad11b
[Alerting] prevent flickering when fields are updated in an alert (#60666)
This addresses the flickering in the graph when updating the Alert Add & Edit forms and adds an automatic refresh of the graph every 5 seconds.
2020-03-20 14:50:35 +00:00
Mike Côté
851b8a82a5
License checks for actions plugin (#59070)
* Define minimum license required for each action type (#58668)

* Add minimum required license

* Require at least gold license as a minimum license required on third party action types

* Use strings for license references

* Ensure license type is valid

* Fix some tests

* Add servicenow to gold

* Add tests

* Set license requirements on other built in action types

* Use jest.Mocked<ActionType> instead

* Change servicenow to platinum

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

* Make actions config mock and license state mock use factory pattern and jest mocks (#59370)

* Add license checks to action HTTP APIs (#59153)

* Initial work

* Handle errors in update action API

* Add unit tests for APIs

* Make action executor throw when action type isn't enabled

* Add test suite for basic license

* Fix ESLint errors

* Fix failing tests

* Attempt 1 to fix CI

* ESLint fixes

* Create sendResponse function on ActionTypeDisabledError

* Make disabled action types by config return 403

* Remove switch case

* Fix ESLint

* Add license checks within alerting / actions framework (#59699)

* Initial work

* Handle errors in update action API

* Add unit tests for APIs

* Verify action type before scheduling action task

* Make actions plugin.execute throw error if action type is disabled

* Bug fixes

* Make action executor throw when action type isn't enabled

* Add test suite for basic license

* Fix ESLint errors

* Stop action task from re-running when license check fails

* Fix failing tests

* Attempt 1 to fix CI

* ESLint fixes

* Create sendResponse function on ActionTypeDisabledError

* Make disabled action types by config return 403

* Remove switch case

* Fix ESLint

* Fix confusing assertion

* Add comment explaining double mock

* Log warning when alert action isn't scheduled

* Disable action types in UI when license doesn't support it (#59819)

* Initial work

* Handle errors in update action API

* Add unit tests for APIs

* Verify action type before scheduling action task

* Make actions plugin.execute throw error if action type is disabled

* Bug fixes

* Make action executor throw when action type isn't enabled

* Add test suite for basic license

* Fix ESLint errors

* Stop action task from re-running when license check fails

* Fix failing tests

* Attempt 1 to fix CI

* ESLint fixes

* Return enabledInConfig and enabledInLicense from actions get types API

* Disable cards that have invalid license in create connector flyout

* Create sendResponse function on ActionTypeDisabledError

* Make disabled action types by config return 403

* Remove switch case

* Fix ESLint

* Disable when creating alert action

* Return minimumLicenseRequired in /types API

* Disable row in connectors when action type is disabled

* Fix failing jest test

* Some refactoring

* Card in edit alert flyout

* Sort action types by name

* Add tooltips to create connector action type selector

* Add tooltips to alert flyout action type selector

* Add get more actions link in alert flyout

* Add callout when creating a connector

* Typos

* remove float right and use flexgroup

* replace pixels with eui variables

* turn on sass lint for triggers_actions_ui dir

* trying to add padding around cards

* Add callout in edit alert screen when some actions are disabled

* improve card selection for Add Connector flyout

* Fix cards for create connector

* Add tests

* ESLint issue

* Cleanup

* Cleanup pt2

* Fix type check errors

* moving to 3-columns cards for connector selection

* Change re-enable to enable terminology

* Revert "Change re-enable to enable terminology"

This reverts commit b497dfd6b6.

* Add re-enable comment

* Remove unecessary fragment

* Add type to actionTypeNodes

* Fix EuiLink to not have opacity of 0.7 when not hovered

* design cleanup in progress

* updating classNames

* using EuiIconTip

* Remove label on icon tip

* Fix failing jest test

Co-authored-by: Andrea Del Rio <delrio.andre@gmail.com>

* Add index to .index action type test

* PR feedback

* Add isErrorThatHandlesItsOwnResponse

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Andrea Del Rio <delrio.andre@gmail.com>
2020-03-20 10:49:37 -04:00
Yuliia Naumenko
64e09af107
Implemented ability to clear and properly validate alert interval (#60571)
* Implemented ability to clear and properly validate alert interval

* Fixed due to comments

* Fixed additional request for the last field

* Fixed failing test
2020-03-20 07:18:54 -07:00
Dmitry Lemeshko
992c502cf5
WebElementWrapper: add findByTestSubject/findAllByTestSubject to search with data-test-subj (#60568)
* [web_element_wrapper] add find/findAll to search with data-test-subj

* fixes

* fix wrong function call

* review fixes

* simplify test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 17:18:35 +03:00
Aaron Caldwell
592ded89c0
[Maps] Update layer dependencies to NP (#59585)
* Layers dir up through sources migrated. Kibana services updated

* Create separate init method for plugin setup, leverage in embeddable factory

* Add NP timefilter, http, IndexPatternSelect

* Pull vis color utils into Maps

* Add NP dark mode and toast handling. Some fixes

* Init autocomplete and indexPattern via normal paths

* Test fixes and clean up

* Update index pattern and autocomplete refs. Make getters functions

* Fix remaining broken jest tests

* Update inspector start contract

* Clean up plugin and legacy files. Fix type issues

* Set inspector in plugin start method not external function

* Keep both injected var functions (legacy and NP). Move inspector init back to separate init function

* Add back ts-ignore on NP kibana services import
2020-03-20 08:17:05 -06:00
James Gowdy
f18c571ed6
[ML] Listing all categorization wizard checks (#60502)
* [ML] Listing all categorization wizard checks

* fixing translation

* changes based on review

* moving check

* adding real values to messages

* reordering checks enum

* fixing types

* updating tests

* updating id
2020-03-20 12:07:54 +00:00
Angela Chuang
ab44099739
[SIEM] Export timeline (#58368)
* update layout

* add utility bars

* add icon

* adding a route for exporting timeline

* organizing data

* fix types

* fix incorrect props for timeline table

* add export timeline to tables action

* fix types

* add client side unit test

* add server-side unit test

* fix title for delete timelines

* fix unit tests

* update snapshot

* fix dependency

* add table ref

* remove custom link

* remove custom links

* Update x-pack/legacy/plugins/siem/common/constants.ts

Co-Authored-By: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>

* remove type ExportTimelineIds

* reduce props

* Get notes and pinned events by timeline id

* combine notes and pinned events data

* fix unit test

* fix type error

* fix type error

* fix unit tests

* fix for review

* clean up generic downloader

* review with angela

* review utils

* fix for code review

* fix for review

* fix tests

* review

* fix title of delete modal

* remove an extra bracket

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 10:09:12 +00:00
patrykkopycinski
8f1e22f078
[SIEM] Add support for actions and throttle in Rules (#59641) 2020-03-20 10:54:51 +01:00
Jean-Louis Leysens
b841526979
Fix ace a11y listener (#60639)
Also move the hook use_ui_ace_keyboard_mode.tsx into es_ui_shared

This was defined (and used) in both Console and SearchProfiler.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 10:14:44 +01:00
Liza Katz
ef0935ff45
Add addInfo toast to core notifications service (#60574)
* addInfo toast

* md files

* fis types

* Added options to toast methods

* Export ToastOptions

* Export ToastOptions

* added test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-20 08:38:02 +02:00
Spencer
c3957d8554
[canvas/shareable_runtime] sync sass loaders with kbn/optimizer (#60653)
* [canvas/shareable_runtime] sync sass loaders with kbn/optimizer

* limit sass options to those relevant in this context

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 17:41:28 -07:00
Ryland Herrick
182acdb666
[SIEM] Fixes Modification of ML Rules (#60662)
* Fix updating of ML rules

* Add a regression test for updating ML Rules

* Allow ML Rules to be patched

And adds a regression unit test.

* Allow ML rule params to be imported when overwriting

* Add a basic regression test for creating a rule with ML params

* Prevent users from changing an existing Rule's type
2020-03-19 19:33:36 -05:00
Steph Milovic
0163a71d24
[SIEM] [Case] Bulk status update, add comment avatar, id => title in breadcrumbs (#60410) 2020-03-19 17:08:53 -06:00
Patrick Mueller
d5989e8baa
[Alerting] add functional tests for index threshold alertType (#60597)
resolves https://github.com/elastic/kibana/issues/58902
2020-03-19 18:29:26 -04:00
nnamdifrankie
d1aaa4430a
[Ingest]EMT-248: add post action request handler and resources (#60581)
[Ingest]EMT-248: add resource to allow to post new agent action.
2020-03-19 18:15:56 -04:00
Christos Nasikas
3acbbcd2b0
Return incident's url (#60617) 2020-03-19 23:23:37 +02:00
Eric Davis
347160b71a
[Endpoint] TEST: GET alert details - boundary test for first alert retrieval (#60320)
* boundary test for first alert retrieval

* boundary test for first alert retrieval cleaned up

* redo merge conflict resolving for api test

* redo merge conflict resolving for api test try 2

* updating to current dataset expectations

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 17:10:56 -04:00
Walter Rafelsberger
b2b5fcedcc
[ML] Transforms: Fix pivot preview table mapping. (#60609)
- Fixes regression caused by elastic/elasticsearch#53572.
- Adjusts the TS mappings and code to reflect the newly returned API response.
- Re-enables functional tests.
2020-03-19 22:02:16 +01:00
marshallmain
404e941e63
[Endpoint] Log random seed for sample data CLI to console (#60646)
* log random seed to console

* fix off by 1 error with children
2020-03-19 17:01:39 -04:00
kqualters-elastic
cd2d54d59a
Use common event model for determining if event is v0 or v1 (#60667) 2020-03-19 16:14:45 -04:00
Tim Sullivan
ce2e3fd621
[Reporting] Allow reports to be deleted in Management > Kibana > Reporting (#60077)
* [Reporting] Feature Delete Button in Job Listing

* refactor listing buttons

* multi-delete

* confirm modal

* remove unused

* fix test

* mock the id generator for snapshotting

* simplify

* add search bar above table

* fix types errors
2020-03-19 12:36:19 -07:00
Zacqary Adam Xeper
431b06fee0
[Metrics Alerts] Add functional and unit tests (#60442)
* Add tests for metric threshold alerts

* Fix count aggregator

* Remove redundant typedefs

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 14:12:01 -05:00
Paul Tavares
58b7e20795
Refactor to use new top-level PackageIcon component (#60628)
- removes PackageIcon from EPM section
- refactors code to use new top-level `PackageIcon` component
2020-03-19 14:38:12 -04:00
Melissa Alvarez
f5355a9ee8
[ML] Data Visualizer: Replace KqlFilterBar with QueryStringInput (#60544)
* data visualizer:replace kqlFilterBar

* remove unused translation

* show syntax error toast
2020-03-19 14:35:04 -04:00
Mike Côté
bafd45fff2
Fix race condition in flaky alerting test (#60438)
* Fix race condition in flaky test

* Fix flakiness in test

* Fix more flakiness
2020-03-19 13:20:48 -04:00
Catherine Liu
3bd3364a55
[Canvas] Add Lens embeddables (#57499)
* Added lens embeddables to embed flyout

Fixed import

embedded panel styles (#58654)

Merging to WIP draft branch

* Added i18n strings for savedLens

* Added tests for lens embeddables

* Updated tests

* Updated tests

* Added style overrides for lens table

* DDisables triggers on lens emebeddable

* Updated test

* Sets embeddable view mode according to app state

* Fix embeddable component

* Removed embeddable view mode logic

* Removed unused import
2020-03-19 09:58:22 -07:00
Justin Kambic
fcf439625b
[Uptime] Add Alerting UI (#57919)
* WIP trying things.

Add new alert type for Uptime.

Add defensive checks to alert executor.

Move status check code to dedicated adapter function.

Clean up code.

* Port adapter function to dedicated file.

* WIP.

* Working on parameter selection.

* Selector expressions working.

* Working on actions.

* Change anchor prop for popovers.

* Reference migrated alerting plugin.

* Clean up code for draft.

* Add button to expose flyout. Clean up some client code.

* Add test for requests function, add support for filters.

* Reorganize and clean up files.

* Add location and filter support to monitor status request function.

* Add tests for monitor status request function.

* Specify default action group id in alert registration.

* Extract repeated string value to a constant.

* Move test file to server in NP plugin.

* Update imports after NP migration.

* Fix UI bug that caused incorrect location selections in alert creation.

* Change alert expression language to clarify meaning.

* Add ability for user to select timerange units.

* Add code that fixes active item highlighting.

* Add better default value for active index selection.

* Introduce dedicated field number component.

* Add message to status check alert.

* Add tests for context message.

* Formalize alert action group definitions.

* Extract monitor id squashing from context message generator.

* Write test for monitor ID uniqueness function.

* Add alert state creator function and tests.

* Update action group id value.

* Add tests for alert factory and executor function.

* Rename alert context props to be more domain-specific.

* Clean up unnecessary type markup.

* Clean up alert ui controls file.

* Better organize new registration code.

* Simplify some logic code.

* Clean up bootstrap code.

* Add unit tests for alert type.

* Delete temporary test code from triggers_actions_ui.

* Rename a test file.

* Add some comments to annotate a file.

* Add io-ts type checking to alert create validation and alert executor.

* Add translation of plaintext content string.

* Further simplify monitor status alert validation.

* Add io-ts type checking to alert params.

* Update a comment.

* Prefer inline snapshots to more error-prone assertions.

* Clean up and comment request function.

* Rename a symbol.

* Fix broken types in reducer file and add a test.

* Fix a validation logic error and add tests.

* Delete unused import.

* Delete obsolete dependency.

* Fix function call to have correct parameters.

* Fixing some import weirdness.

* Reintroduce accidentally-deleted code.

* Delete unneeded require from legacy entry file.

* Remove unneeded connected component.

* Update flyout controls for new interface and delete connected components.

* Remove unneeded require from app index file.

* Introduce data-test-subj attributes to various components to assist with functional tests.

* Introduce functional test helpers for alert flyout.

* Add functional test arch and a test for alerting UI to ES SSL test suite.

* Add explicit exports to module index.

* Reorganize file to keep interfaces closer to their implementations.

* Move create alert button to better position.

* Clean up a file.

* Update a functional test attribute, clean up a file, rename a selector, add tests.

* Add a comment.

* Make better default alert message, translate messages, add/update tests.

* Fix broken type.

* Update obsolete snapshot.

* Introduce mock provider to tests and update snapshots.

* Reduce a strange type to `any`.

* Add alert flyout button connected component.

* Add alert flyout wrapper connected component.

* Create connected component for alert monitor status alert.

* Clean up index files.

* Update i18nrc file to cover translation in server plugin code.

* Fix broken imports.

* Update test snapshots.

* Prefer more descriptive type.

* Prefer more descriptive type.

* Prefer built-in React propType to custom.

* Prefer simpler validation.

* Add whitespace to clean up file.

* Extract function and write tests.

* Simplify validation function.

* Add navigate to alerting button.

* Move context item inside the items list.

* Clean up alert creation component.

* Update type check parsing and error messaging, and update snapshot/test assertions.

* Update broken snapshot.

* Update README for running functional tests.

* Update functional test service to reflect improved UX.

* Fix broken type that resulted from a mistake during a merge resolution.

* Add spacer between alert title and kuery bar.

* Update the id and name of our alert type because it was never changed from placeholder value.

* Rename alert keys.

* Fix broken unit tests.

* Add aria-labels to alert UI.

* Implement design feedback.

* Fix broken test snapshots.

* Add missing props to unit tests to staisfy updated types.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 12:50:05 -04:00
James Gowdy
a0730f7951
[ML] Fixing file data visualizer override arguments (#60627) 2020-03-19 16:42:53 +00:00
Jean-Louis Leysens
304b322a47
[Console] Refactor and cleanup of public and server (#60513)
* Clean up use of ace in autocomplete in public

Remove ace from lib/autocomplete.ts and set up hooking up of ace
in legacy_core_editor. Also remove use of ace mocks in tests.

* Added TODO in lib/kb (console public)

* Server-side cleanup

Refactored the loading of spec into a new SpecDefinitionsService.
In this way, state can be contained inside of the service as much
as possible. Also converted all JS spec to TS and updated the
Console plugin contract so that processors (which alter loaded
spec) happen at plugin "start" phase.

* Fix types

* Small refactor

- Updated naming of argument variable in registerAutocompleter
- Refactored the SpecDefinitionsService to handle binding of
it's own functions
2020-03-19 17:32:39 +01:00
Steph Milovic
d5ed93ee63
[SIEM] [Cases] Case closed and add user email (#60463) 2020-03-19 10:27:41 -06:00
Alejandro Fernández
fe4c164681
[Logs UI] Use the Super date picker in the log stream (#54280) 2020-03-19 17:19:21 +01:00
Dima Arnautov
7aa4651292
[ML] Use a new ML endpoint to estimate a model memory (#60376)
* [ML] refactor calculate_model_memory_limit route, use estimateModelMemory endpoint

* [ML] refactor validate_model_memory_limit, migrate tests to jest

* [ML] fix typing issue

* [ML] start estimateModelMemory url with /

* [ML] fix typo, filter mlcategory

* [ML] extract getCardinalities function

* [ML] fields_service.ts

* [ML] wip getMaxBucketCardinality

* [ML] refactor and comments

* [ML] fix aggs keys with special characters, fix integration tests

* [ML] use pre-defined job types

* [ML] fallback to 0 in case max bucket cardinality receives null

* [ML] calculateModelMemoryLimit on influencers change

* [ML] fix maxModelMemoryLimit

* [ML] cap aggregation to max 1000 buckets

* [ML] rename intervalDuration
2020-03-19 16:45:40 +01:00
Felix Stürmer
ae0e35041e
[Logs UI] Correctly update the expanded log rate table rows (#60306)
This ensures that the content of the expanded rows in the log rate table reflect the most recent results.

Fixes #60300
2020-03-19 16:42:58 +01:00
MadameSheema
b0a6b302ad
fixes drag and drop flakiness (#60625) 2020-03-19 16:32:19 +01:00
Jean-Louis Leysens
254cf99339
[Cross Cluster Replication] NP Shim (#60121)
* Public in WiP state, removed all 'ui/' imports

* First iteration of public shimmed and working

* A whole lotta WIP server side

* Server-side to using the NP router + client side changes

Updated the client code to properly encode requests to the
server. Did first E2E test.

Route tests are probably broken, need to fix them.

* Removed unused error wrapping code

* Update client Jest tests

* Add breadcrumbs service mock

* Fix server side Jest tests

* Add helper functions file for server side Jest tests

* Fix API integration tests

* Fixed boolean logic mistake in due to refactor in index mgmt ext.

Also migrated to the a more NP friendly version of index mgmt
extension.

* Remove unused import

* Clean up some cruft and refactor URL variable names

* Fix stringification of body and fix boolean server logic

* Fix mocha

Folder called __tests__ with Jest tests was breaking mocha.

* Refactor to Jest test

* Fix types issues in jest test

* Migrate to new config-schema API

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 15:42:25 +01:00
Mike Côté
05a0625048
Clear changes when canceling an edit to an alert (#60518)
* Clear alerting edit flyout after canceling an edit

* Add functional test

* Fix merge conflicts
2020-03-19 10:40:22 -04:00
Pierre Gayvallet
395d621249
migrate saved objects management edition view to react/typescript/eui (#59490)
* migrate so management edition view to react

* fix bundle name + add forgotten data-test-subj

* add FTR tests for edition page

* EUIfy react components

* wrap form with EuiPanel + caps btns labels

* Wrapping whole view in page content panel and removing legacy classes

* improve delete confirmation modal

* update translations

* improve delete popin

* add unit test on view components

* remove kui classes & address comments

* extract createFieldList and add tests

* disable form submit during submition

Co-authored-by: cchaos <caroline.horn@elastic.co>
2020-03-19 14:09:44 +01:00
Christos Nasikas
6ed2918b6c
[SIEM][CASE] Configuration page action bar (#60608)
* Add bottom bar

* Add listeners
2020-03-19 15:06:33 +02:00
Alison Goryachev
ee6bb64f13
[Remote clusters] Update copy (#60382) 2020-03-19 08:23:20 -04:00
Mike Côté
4efeeac560
Sort by name when fetching alerts and connectors (#60506)
* Sort by name when fetching alerts and connectors

* Fix jest tests

* Add functional test

* Fix failing jest test
2020-03-19 08:06:51 -04:00
Mike Côté
27045e0942
Make slack param validation handle empty messages (#60468) 2020-03-19 08:02:07 -04:00
Gidi Meir Morris
8fd317c55a
[Alerting] Adds navigation by consumer and alert type to alerting (#58997)
Adds Navigation APIs to Alerting.

Parts to this PR:

Adds a client side (Public) plugin to Alerting, including two APIs: registerNavigation & registerDefaultNavigation. These allow a plugin to register navigation handlers for any alerts which it is the consumer of- one for specific AlertTypes and one for a default handler for all AlertTypes created by the plugin.
The Alert Details page now uses these navigation handlers for the View In App button. If there's an AlertType specific handler it uses that, otherwise it uses a default one and if the consumer has not registered a handler - it remains disabled.
A generic Alerting Example plugin that demonstrates usage of these APIs including two AlertTypes - one that always fires, and another that checks how many people are in Outer Space and allows you to trigger based on that. 😉 To enable the plugin run yarn start --ssl --run-examples
2020-03-19 09:49:05 +00:00
Liza Katz
2eda06e770
Introduce search interceptor (#60523)
* Add async search strategy

* Add async search

* Fix async strategy and add tests

* Move types to separate file

* Revert changes to demo search

* Update demo search strategy to use async

* Add async es search strategy

* Return response as rawResponse

* Poll after initial request

* Add cancellation to search strategies

* Add tests

* Simplify async search strategy

* Move loadingCount to search strategy

* Update abort controller library

* Bootstrap

* Abort when the request is aborted

* Add utility and update value suggestions route

* Fix bad merge conflict

* Update tests

* Move to data_enhanced plugin

* Remove bad merge

* Revert switching abort controller libraries

* Revert package.json in lib

* Move to previous abort controller

* Add support for frozen indices

* Fix test to use fake timers to run debounced handlers

* Revert changes to example plugin

* Fix loading bar not going away when cancelling

* Call getSearchStrategy instead of passing  directly

* Add async demo search strategy

* Fix error with setting state

* Update how aborting works

* Fix type checks

* Add test for loading count

* Attempt to fix broken example test

* Revert changes to test

* Fix test

* Update name to camelCase

* Fix failing test

* Don't require data_enhanced in example plugin

* Actually send DELETE request

* Use waitForCompletion parameter

* Use default search params

* Add support for rollups

* Only make changes needed for frozen indices/rollups

* Only make changes needed for frozen indices/rollups

* Add back in async functionality

* Fix tests/types

* Fix issue with sending empty body in GET

* Don't include skipped in loaded/total

* Don't wait before polling the next time

* Add search interceptor for bulk managing searches

* Simplify search logic

* Fix merge error

* Review feedback

* Add service for running beyond timeout

* Refactor abort utils

* Remove unneeded changes

* Add tests

* cleanup mocks

* Update src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.html

Co-Authored-By: Lukas Olson <olson.lukas@gmail.com>

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-19 10:28:43 +02:00
Robert Oskamp
836b3d00ef
[ML] Add functional tests for file data visualizer (#60413)
This PR adds basic functional tests for the file data visualizer, covering a file import and error messages for non-log files. It also moves the file input path handling to a common location in order to avoid code duplication.
2020-03-19 09:08:43 +01:00
Dario Gieselaar
9cd0a36740
[APM] Optimize service map query (#60412)
* [APM] Optimize service map query

Closes #60411.

- Chunk trace lookup
- Remove pagination, move dedupe logic to server

* Fix imports

* Fix imports again

Co-authored-by: Nathan L Smith <smith@nlsmith.com>
2020-03-19 08:37:58 +01:00
Frank Hassanabad
01571b6739
[SIEM][Detection Engine] Adds lists feature flag and list values to the REST interfaces
## Summary

* https://github.com/elastic/kibana/issues/60022
* Adds the feature flag for simple list values
* Adds the boolean filters of "and", "and not" to further filter based on simple values
* Adds unit tests and e2e tests for the values.
* Most tests can include the simple list values but some have to be skipped until we move those to more functions or just enable simple list values as a permanent feature. 
* DOES NOT FILTER ON THE VALUES JUST YET (That will be a follow on PR)

## Testing:

To turn on/off the feature flag do this with an env variable (set this in your .bashrc/.zshrc):

```ts
export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true
```

Expect to see this error in the console when the environment variable is set:

```ts
server    log   [11:41:16.245] [error][plugins][siem] You have activated the lists feature flag which is NOT currently supported for SIEM! You should turn this feature flag off immediately by un-setting the environment variable: ELASTIC_XPACK_SIEM_LISTS_FEATURE and restarting Kibana
```

Expect create and update to work when the environment variable is set and look like this:

```ts
./update_rule.sh ./rules/updates/update_list.json 
{
  "created_at": "2020-03-15T17:42:37.074Z",
  "updated_at": "2020-03-15T17:54:22.427Z",
  "created_by": "yo",
  "description": "Query with a list",
  "enabled": true,
  "false_positives": [],
  "from": "now-6m",
  "id": "c602e3f6-713b-4f43-9bdd-b60fbfead1c5",
  "immutable": false,
  "interval": "5m",
  "rule_id": "query-with-list",
  "language": "kuery",
  "output_index": ".siem-signals-hassanabad-frank-default",
  "max_signals": 100,
  "risk_score": 1,
  "name": "Query with a list",
  "query": "user.name: root or user.name: admin",
  "references": [],
  "severity": "high",
  "updated_by": "yo",
  "tags": [],
  "to": "now",
  "type": "query",
  "threat": [],
  "version": 6,
  "lists": [
    {
      "field": "source.ip",
      "boolean_operator": "and",
      "values": [
        {
          "name": "127.0.0.1",
          "type": "value"
        }
      ]
    },
    {
      "field": "host.name",
      "boolean_operator": "and not",
      "values": [
        {
          "name": "rock01",
          "type": "value"
        }
      ]
    }
  ],
  "status": "succeeded",
  "status_date": "2020-03-15T17:42:40.718Z",
  "last_success_at": "2020-03-15T17:42:40.718Z",
  "last_success_message": "succeeded"
}
```

```ts
./post_rule.sh ./rules/queries/query_with_list.json 
{
  "created_at": "2020-03-15T17:42:37.074Z",
  "updated_at": "2020-03-15T17:42:37.116Z",
  "created_by": "yo",
  "description": "Query with a list",
  "enabled": true,
  "false_positives": [],
  "from": "now-6m",
  "id": "c602e3f6-713b-4f43-9bdd-b60fbfead1c5",
  "immutable": false,
  "interval": "5m",
  "rule_id": "query-with-list",
  "language": "kuery",
  "output_index": ".siem-signals-hassanabad-frank-default",
  "max_signals": 100,
  "risk_score": 1,
  "name": "Query with a list",
  "query": "user.name: root or user.name: admin",
  "references": [],
  "severity": "high",
  "updated_by": "yo",
  "tags": [],
  "to": "now",
  "type": "query",
  "threat": [],
  "version": 1,
  "lists": [
    {
      "field": "source.ip",
      "boolean_operator": "and",
      "values": [
        {
          "name": "127.0.0.1",
          "type": "value"
        }
      ]
    },
    {
      "field": "host.name",
      "boolean_operator": "and not",
      "values": [
        {
          "name": "rock01",
          "type": "value"
        },
        {
          "name": "mothra",
          "type": "value"
        }
      ]
    }
  ]
}
```

```ts
./patch_rule.sh ./rules/patches/update_list.json   
{
  "created_at": "2020-03-15T18:02:52.434Z",
  "updated_at": "2020-03-15T18:02:57.675Z",
  "created_by": "yo",
  "description": "Query with a list",
  "enabled": true,
  "false_positives": [],
  "from": "now-6m",
  "id": "40b7c2fb-83b4-4820-bf7c-056f3a631126",
  "immutable": false,
  "interval": "5m",
  "rule_id": "query-with-list",
  "language": "kuery",
  "output_index": ".siem-signals-hassanabad-frank-default",
  "max_signals": 100,
  "risk_score": 1,
  "name": "Query with a list",
  "query": "user.name: root or user.name: admin",
  "references": [],
  "severity": "high",
  "updated_by": "yo",
  "tags": [],
  "to": "now",
  "type": "query",
  "threat": [],
  "version": 1,
  "lists": [
    {
      "field": "source.ip",
      "boolean_operator": "and",
      "values": [
        {
          "name": "127.0.0.1",
          "type": "value"
        }
      ]
    },
    {
      "field": "host.name",
      "boolean_operator": "and not",
      "values": [
        {
          "name": "rock01",
          "type": "value"
        },
        {
          "name": "mothra",
          "type": "value"
        }
      ]
    }
  ],
  "status": "succeeded",
  "status_date": "2020-03-15T18:02:56.426Z",
  "last_success_at": "2020-03-15T18:02:56.426Z",
  "last_success_message": "succeeded"
}
```

```ts
./get_rule_by_rule_id.sh query-with-list
{
  "created_at": "2020-03-15T18:10:07.657Z",
  "updated_at": "2020-03-15T18:10:08.479Z",
  "created_by": "yo",
  "description": "Query with a list",
  "enabled": true,
  "false_positives": [],
  "from": "now-6m",
  "id": "9854162b-003c-47be-af59-8c3c9545aafa",
  "immutable": false,
  "interval": "5m",
  "rule_id": "query-with-list",
  "language": "kuery",
  "output_index": ".siem-signals-hassanabad-frank-default",
  "max_signals": 100,
  "risk_score": 1,
  "name": "Query with a list",
  "query": "user.name: root or user.name: admin",
  "references": [],
  "severity": "high",
  "updated_by": "yo",
  "tags": [],
  "to": "now",
  "type": "query",
  "threat": [],
  "version": 1,
  "lists": [
    {
      "field": "source.ip",
      "boolean_operator": "and",
      "values": [
        {
          "name": "127.0.0.1",
          "type": "value"
        }
      ]
    },
    {
      "field": "host.name",
      "boolean_operator": "and not",
      "values": [
        {
          "name": "rock01",
          "type": "value"
        },
        {
          "name": "mothra",
          "type": "value"
        }
      ]
    }
  ],
  "status": "going to run",
  "status_date": "2020-03-15T18:10:10.738Z"
}
```

Expect these errors when the environment variable is not set:

```ts
./post_rule.sh ./rules/queries/query_with_list.json 
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body]: child \"lists\" fails because [\"lists\" is not allowed]"
}
```

```ts
./update_rule.sh ./rules/queries/query_with_list.json
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body]: child \"lists\" fails because [\"lists\" is not allowed]"
}
```

```ts
./patch_rule.sh ./rules/patches/update_list.json
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[request body]: child \"lists\" fails because [\"lists\" is not allowed]"
}
```

Expect that this is _backwards_ compatible with the feature flag but not necessarily _forwards_ compatible. This means:

* You can have older data that never had lists and it will show up as an empty list when you query it. (backwards compatible)
* You _might_ have lists and remove the env. variable and get back items as if the list was not there for (forwards compatible) 

* You can export without lists, flip on the env flag and import with newer lists feature (backwards compatible)
* You can export lists and it will _not_ work with an older system (not forwards compatible)

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
2020-03-18 23:57:36 -06:00
Maggie Ghamry
cf08850489
Enhancement/update esdocs datasource (#59512)
* Initial Commit

Update to ESDocs datasource per team feedback

* Updates

Updates per Ryan's mockups

* Updates II

Updates per Poff's review

* Updates III

Update to some of the verbiage and card sizes - working on re-ordering and adding a link to the lucen query syntax

* design tweaks

* Adding lucene hyperlink

update to add hyperlink help for Lucene query syntax

* Consollidating datasources to sort

Consolidating the ESDocs datasource with the rest, so that we can order them

* updates for i18n

updates for i18n

* Updates

Updates from Gail for verbiage and integrating Ryan's change for style

* Update ui.ts

Updates for i18n

* Updates for datasource order

moving the esdocs datasource to live with the rest of the UI datasources, and sorting them accordingly.

* Update datasource_component.js

removing console log, whoops

* Update ui.ts

Update to fix i18n essql issue

* Update ui.ts

Updates to fix i18n references for the esdocs datasource move

* Update to Timelion URL

I noticed that the Timelion datasource showed "Lucene query syntax" which wasn't relevant, so I updated it to "Timelion", along with a tutorial, as the link for current Timelion docs does not provide any syntax tutorial.

* Update ui.ts

update for i18n

* Update ui.ts

update for i18n

* Update ui.ts

Update to removed unused value - the i18n check gave me latent errors, sorry for the repost

* i18n updates

Updating nomenclature to get past i18n errors

* Updates

Code review updates to remove extraneous code

* Update timelion.js

update to remove extraneous comment per code review

* More i18n updates

translation updates to accommodate the esdocs datasource move

* Update datasource_component.js

Update to toggle datasource icon in selected element mode

* Update ui.ts

hopefully last i18n fix

Co-authored-by: Ryan Keairns <contactryank@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 21:36:21 -04:00
renovate[bot]
b9d2affc73
Update dependency nock to v12 (#60422)
* Update dependency nock to v12

* update yarn.lock file

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 17:48:42 -07:00
Spencer
cc8f7c43dd
upgrade execa to get stdout/stderr in error messages (#60537)
* upgrade execa to get stdout/stderr in error messages

* rebuild kbn/pm

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 17:45:04 -07:00
spalger
650943df79 skip flaky suite (#60471) 2020-03-18 17:42:01 -07:00
Paul Tavares
8c5071939b
[Ingest] Agent Config Details - Data sources list ui (#60429)
* refactor `use_details_uri` hook and introduce `useAgentConfigLink`
* Refactor structure for datasources view
* Sync up table columns
* Added row actions to Datasources list
* Datasources table filters
* Support deleting datasource action
* Added PackageIcon to datasources list
2020-03-18 20:28:34 -04:00
Ryland Herrick
a05a61286f
[SIEM] Create ML Rules (#58053)
* Remove unnecessary linter exceptions

Not sure what was causing issues here, but it's gone now.

* WIP: Simple form to test creation of ML rules

This will be integrated into the regular rule creation workflow, but for
now this simple form should allow us to exercise the full ML rule
workflow.

* WIP: Adds POST to backend, and type/payload changes necessary to make that work

* Simplify logic with Math.min

* WIP: Failed spike of making an http call

* WIP: Hacking together an ML client

The rest of this is going to be easier if I have actual data. For now
this is mostly copy/pasted and simplified ML code. I've hardcoded time
ranges to a period I know has data for a particular job.

* Threading through our new ML Rule params

It's a bummer that we normalize our rule alert params across all rule
types currently, but that's the deal.

* Retrieve our anomalies during rule execution

Next step: generate signals

* WIP: Generate ECS-compatible ML Signals

This uses as much of the existing signal-creation code as possible. I
skipped the search_after stuff for now because it would require us
recreating the anomalies query which we really shouldn't own. For now,
here's how it works:

* Adds a separate branch of the rule executor for machine_learning rules
* In that branch, we call our new bulkCreateMlSignal function
  * This function first transforms the anomaly document into ECS fields
  * We then pass the transformed documents to singleBulkCreate, which
  does the rest
* After both branches, we update the rule's status appropriately.

We need to do some more work on the anomaly transformation, but this
works!

* Extract setting of rule failure to helper function

We were doing this identically in three places.

* Remove unused import

* Define a field for our Rule Type selection

This adds most of the markup and logic to allow an ML rule type to be
selected. We still need to add things like license-checking and
showing/hiding of fields based on type.

* Hide Query Fields when ML is selected

These are still getting set on the form. We'll need to filter these
fields before we send off the data, and not show them on the readonly
display either.

ALso, edit is majorly broken.

* Add input field for anomaly threshold

* Display numberic values in the readonly view of a step

TIL that isEmpty returns false for numbers and other non-iterable
values. I don't think it's exactly what we want here, but until I figure
out the intention this gets our anomalyThreshold showing up without a
separate logic branch here. Removes the unnecessary branch that was
redundant with the 'else' clause.

* Add field for selecting an ML job

This is not the same as the mockups and lacks some functionality, but
it'll allow us to select a job for now.

* Format our new ML Fields when sending them to the server

So that we don't get rejected due to snake case vs camelcase.

* Put back code that respects a rule's schedule

It was previously hardcoded to a time period I knew had anomalies.

* ML fields are optional in our creation step

In that we don't initialize them like we do the query (default) fields.

* Only send along type-specific Rule fields from form

This makes any query- or ML-specific fields optional on a Rule, and
performs some logic on the frontend to group and include these fieldsets
conditionally based on the user's selection. The one place we don't
handle this well is on the readonly view of a completed step in the
rules creation, but we'll address that.

* Rename anomalies query

It's no longer tabular data. If we need that, we can use the ML client.

* Remove spike page with simple form

* Remove unneeded ES option

This response isn't going to HTTP, which is where this option would
matter.

* Fix bulk create logic

I made a happy accident and flipped the logic here, which meant we
weren't capping the signals we created.

* Rename argument

Value is a little more ambiguous than data, here: this is our step data.

* Create Rule form stores all values, but filters by type for use

When sending off to the backend, or displaying on the readonly view, we
inspect which rule type we've currently selected, and filter our form
values appropriately.

* Fix editing of ML fields on Rule Create

We need to inherit the field value from our form on initial render, and
everything works as expected.

* Clear form errors when switching between rule types

Validation errors prevent us from moving to the next step, so it was
previously possible to get an error for Query fields, switch to an ML
rule, and be unable to continue because the form had Query errors.

This also adds a helper for checking whether a ruleType is ML, to
prevent having to change all these references if the type string
changes.

* Validate the selection of an ML Job

* Fix type errors on frontend

According to the types, this is essentially the opposite of formatRule,
so we need to reinflate all potential form values from the rule.

* Don't set defaults for query-specific rules

For ML rules these types should not be included.

* Return ML Fields in Rule responses

This adds these fields to our rule serialization, and then adds
conditional validation around those fields if the rule type is ML.
Conversely, we moved the 'language' and 'query' fields to be
conditionally validated if the rule is a query/saved_query rule.

* Fix editing of ML rules by changing who controls the field values

The source of truth for their state is the parent form object; these
inputs should not have local state.

* Fix type errors related to new ML fields

In adding the new ML fields, some other fields (e.g. `query` and
`index`) that were previously required but implicitly part of Query
Rules are now marked as optional.

Consequently, any downstream code that actually required these fields
started to complain. In general, the fix was to verify that those fields
exist, and throw an error otherwise as to appease the linter.

Runtime-wise, the new ML rules/signals follow a separate code path and
both branches should be unaffected by these changes; the issue is simply
that our conditional types don't work well with Typescript.

* Fix failing route tests

Error message changed.

* Fix integration tests

We were not sending required properties when creating a rule(index and
language).

* Fix non-ML Rule creation

I was accidentally dropping this parameter for our POST payload. Whoops.

* More informative logging during ML signal generation

The messaging diverged from the normal path here because we don't have
index patterns to display. However, we have the rest of the rule
context, and should report it appropriately.

* Prefer keyof for string union types

* Tidy up our new form components

* Type them as React.FCs
* Remove unnecessary use of styled-components

* Prefer destructuring to lodash's omit

* Fix mock params for helper functions

These were updated to take simpler parameters.

* Remove any type

This could have been a boolean all along, whoops

* Fix mock types

* Update outdated tests

These were added on master, but behavior has been changed on my branch.

* Add some tests around our helper function

I need to refactor it, so this is as good a time as any to pin down the
behavior.

* Remove uses of any in favor of actual types

Mainly leverages ML typings instead of our placeholder types. This
required handling a null case in our formatting of anomalies.

* Annotate our anomalies with @timestamp field

We were notably lacking this ECS field in our post-conversion anomalies,
and typescript was rightly complaining about it.

* ml_job_id -> machine_learning_job_id

* PR Feedback

* Stricter threshold type
* More robust date parsing
* More informative log/error messages
* Remove redundant runtime checks

* Cleaning up our new ML types

* Fix types on our Rest types
* Use less ambiguous machineLearningJobId over mlJobId
* Declare our ML params as required keys, and ensure we pass them around
everywhere we might need them (creating, importing, updating rules).

* Use implicit type to avoid the need for a ts-ignore

FormSchema has a very generic index signature such that our
filterRuleFieldsForType helper cannot infer that it has our necessary
rule fields (when in fact it does). By removing the FormSchema hint we
get the actual keys of our schema, and things work as expected.

All other uses of schema continue to work because they're expecting
FormSchema, which is effectively { [key: string]: any }.

* New ML params are not nullable

Rather than setting a null and then never using it, let's just make it
truly optional in terms of default values.

* Query and language are conditional based on rule type

For ML Rules, we don't use them.

* Remove defaulted parameter in API test

We don't need to specify this, and we should continue not to for
backwards compatibility.

* Use explicit types over implicit ones

The concern is that not typing our schemae as FormSchema could break our
form if there are upstream changes. For now, we simply use the
intersection of FormSchema and our generic parameter to satisfy our use
within the function.

* Add integration test for creation of ML Rule

* Add ML fields to route schemae

* threshold and job id are conditional on type
* makes query and language mutually exclusive with above

* Fix router test for creating an ML rule

We were sending invalid parameters.

* Remove null check against index for query rules

We support not having an index here, as getInputIndex will return the
current UI setting if none is specified.

* Add regression test for API compatibility

We were previously able to create a rule without an input index; we
should continue to support that, as verified by this test!

* Respect the index pattern determined at runtime when performing search_after

If a rule does not specify an input index pattern on creation, we use
the current UI default when the rule is evaluated. This ensures that any
subsequent searches use that same index.

We're not currently persisting that runtime index to the generated
signal, but we should.

* Fix type errors in our bulk create tests

We added a new argument, but didn't update the tests.
2020-03-18 19:26:42 -05:00
spalger
357ed0e10c skip flaky suite (#60559) 2020-03-18 17:13:34 -07:00
marshallmain
cf1a330206
fix agent type (#60554)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 19:46:54 -04:00
Yuliia Naumenko
3600f5b90b
Fixed default message for index threshold includes both threshold values (#60545)
* Fixed default message for index threshold includes both threshold values even if not used

* fixed due to review comments

* Fixed validation errors with ability to clear input
2020-03-18 16:43:22 -07:00
Jen Huang
60d385ed89
[Ingest] Add support for yaml field types (#60440)
* Support yaml var type:
* Change stream config model to save type and value, instead of just value
* Add code editor for configuring yaml vars
* Adjust tests

* Account for empty yaml value

* Better account for invalid yaml parsing
2020-03-18 15:59:38 -07:00
Yuliia Naumenko
2d44870e06
Solved the issue for a GROUP BY expression validation (#60558)
* Solved the issue for a GROUP BY expression validation

* fixed labels
2020-03-18 14:29:40 -07:00
Thomas Neirynck
a35267afd5
[Maps] Mark instance state as readonly (#60557) 2020-03-18 17:18:03 -04:00
CJ Cenizal
9aad8986e1
Move ui/indices into es_ui_shared plugin. (#60186)
* Convert js files to ts.
* Add indices namespace.
2020-03-18 13:07:41 -07:00
Christos Nasikas
24534e832e
ServiceNow action improvements (#60052)
* Apply action types to fields

* Add information to each field

* Do not create or update comments when actionType is set to nothing

* Improve helpers tests

* Improve tests

* Refactor: Use transformers and pipes

* Better types

* Refactor tests to new changes

* Better error messages

* Improve field formatting and display

* Improve integration tests

* Make username mandatory field

* Translate transformers

* Refactor schema

* Translate appendInformationToField helper

* Improve intergration tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 20:46:05 +02:00
Nicolas Chaulet
4e5aa93f45
[Fleet] Fix privileges for enrollment and access api keys (#60534) 2020-03-18 14:45:17 -04:00
Nathan Reese
7e085eabf5
[Maps] Blended layer that switches between documents and clusters (#57879)
* [Maps] Blended layer that switches between documents and clusters

* change layer type when scalingType changes

* getSource

* use cluster source when count exceeds value

* ensure doc source stays in editor

* start creating cluster style

* pass all parts of style descriptor

* get toggling between sources working

* derive cluster style from document style

* remove references to METRIC_TYPE

* fix import

* start typescripting blended_vector_layer

* more typescript work

* last of the TS errors

* add migration to convert useTopTerm to scalingType

* clean up

* remove MapSavedObject work since its in a seperate PR now

* fix EsSearchSource update editor jest test

* fix map_selector jest test

* move mutable state out of BlendedVectorLayer

* one more change for removing mutable BlendedVectorLayer state

* integrate newly merged MapSavedObjectAttributes type

* review feedback

* use data request for fetching feature count

* add functional test

* fix functional test

* review feedback

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-18 12:06:54 -06:00
Steph Milovic
4fc89aeb0d
[SIEM] [Cases] Shell scripts and unit tests (#60183) 2020-03-18 11:42:08 -06:00
Sandra Gonzales
4c9d95318e
change index pattern id to be the same as index pattern title (#60436) 2020-03-18 13:21:49 -04:00
kqualters-elastic
64af78045b
[Endpoint] resolver v1 events (#59233)
* Unifying the test index name for resolver and alerts

* Endpoint isn't sending the agent field so check for it

* Update resolver to use either legacy or ecs events

* Use correct format for child events api

* Adding string or array for category and type

* Add return types to process event models

* Create a common/models.ts for common event logic

* Decrease resolver min height

* Update types to match cli tool

* Add a smoke test for resolver rendering nodes, remove unused selector

* Add common/models/event

* Internationalize some strings, address pr comments

Co-authored-by: Jonathan Buttner <jonathan.buttner@elastic.co>
2020-03-18 13:18:35 -04:00
Dave Snider
52dd5e0f7a
Branding fixes for dashboard, loader and space selector (#60073) 2020-03-18 10:15:47 -07:00
spalger
696b19e67a skip flaky suite (#60535) 2020-03-18 10:09:58 -07:00
Frank Hassanabad
3e10276b20
[SIEM][Detection Engine] Fixes bug with timeline templates not working
### Summary

Fixes a bug with the timeline templates not working when specifying filters.

* Creates a type safe mechanism for getting StringArrays or regular strings
* AddsType Script function returns to functions in the helpers file
* Adds unit tests for the effected areas of code and corner cases

Before this fix you would get these toaster errors if you tried to use a template name such as `host.name` in the timeline filters:

<img width="677" alt="Screen Shot 2020-03-18 at 12 58 01 AM" src="https://user-images.githubusercontent.com/1151048/76934058-0bd2fc80-68b4-11ea-8dad-7c257bb81a1d.png">

After this fix it will work for you.

Testing:

1) Create a timeline template that has a host.name as both a query and a filter such as this. You can give the value of the host.name any value such as placeholder.

<img width="1125" alt="Screen Shot 2020-03-18 at 12 56 04 AM" src="https://user-images.githubusercontent.com/1151048/76934108-20af9000-68b4-11ea-8a11-4ba9c935506f.png">

2) Create a signal that uses it and produces a lot of signals off of something such as all host names
<img width="1054" alt="Screen Shot 2020-03-18 at 12 50 47 AM" src="https://user-images.githubusercontent.com/1151048/76934198-4f2d6b00-68b4-11ea-8ae3-6de76154cbb7.png">

3) Ensure you select your **Timeline template** you saved by using the drop down
<img width="1071" alt="Screen Shot 2020-03-18 at 12 51 21 AM" src="https://user-images.githubusercontent.com/1151048/76934281-73894780-68b4-11ea-9a2a-a0a9176f28ce.png">

4) Once your signals have run, go to the signals page and send one of the signals for your newly crated rule which has a host name to the timeline from "View in timeline"
<img width="568" alt="Screen Shot 2020-03-18 at 12 52 10 AM" src="https://user-images.githubusercontent.com/1151048/76934365-a4697c80-68b4-11ea-91a5-e0dea7e3e18f.png">

You should notice that your timeline has both the query and the filter set correctly such as this
<img width="1114" alt="Screen Shot 2020-03-18 at 12 56 23 AM" src="https://user-images.githubusercontent.com/1151048/76934432-c105b480-68b4-11ea-9a82-3e8a2da19376.png">


### Other notes

All the different fields you can choose from for templates are:
```
  'host.name',
  'host.hostname',
  'host.domain',
  'host.id',
  'host.ip',
  'client.ip',
  'destination.ip',
  'server.ip',
  'source.ip',
  'network.community_id',
  'user.name',
  'process.name',
```

And it should not work with anything outside of those. You should be able to mix and match them into different filters and queries to have a multiples of them.

### Checklist

- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
2020-03-18 11:00:44 -06:00
Yuliia Naumenko
18aa8245b7
Fixed errors which are happening if switch between alert types (#60453) 2020-03-18 09:48:10 -07:00
Sonja Krause-Harder
f93ec7988b
[EPM] Add mapping field types to index template generation v2 (#60266)
* Add properties needed for index templates to Field

* Add data type handling to template generation

* Adjust tests

* Update fields test snapshots

* Remove duplicate fields from test file

* Add test cases

* Enhance processFields

* move expand stage to expandFields
* fix expandFields
* add deduplication stage dedupFields

* Use processField() to preprocess fields

* Remove alias fields with invalid path

* Remove obsolete code.

* Fix documentation.

* Add unit tests for getField()

* Don't fail on invalid input for now.

* Validate array fields.

* Guard against invalid input.
2020-03-18 17:14:45 +01:00
Oliver Gupte
6abb9d7d18
Closes #60265. Adds Beta badge to service map (#60482) 2020-03-18 08:19:50 -07:00