Commit graph

3029 commits

Author SHA1 Message Date
MadameSheema
0f71886f83
[SIEM] Adds 'Create new rule' Cypress test (#59790)
* adds 'Creates and activates new rule'

* loads data using es_archive

* refactor test
2020-03-10 21:03:48 +01:00
Greg Thompson
4e52deeca3
Use EUI test environment build with Jest (#55877)
* wip

* dir name

* src snapshot changes

* x-pack snapshots

* svg element lookups

* snapshot updates

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-10 13:48:49 -05:00
Steph Milovic
ecac63f258
[SIEM] [Case] Insert timeline into case textarea (#59586) 2020-03-10 11:49:55 -06:00
Ryland Herrick
b56cd41412
[SIEM] Fix and consolidate handling of error responses in the client (#59438)
* Convert our manual throwing of TypeError to a custom Error

Throwing a TypeError meant that our manual errors were indistinguishable
from, say, trying to invoke a method on undefined. This adds a custom
error, BadRequestError, that disambiguates that situation.

* Present API Error messages to the user

With Core's new HTTP client, an unsuccessful API call will raise an
error containing the body of the response it received. In the case of
SIEM endpoints, this will include a useful error message with
potentially more specificity than e.g. 'Internal Server Error'.

This adds a type predicate to check for such errors, and adds a handling
case in our errorToToaster handler.

If the error does not contain our SIEM-specific message, it will fall
through as normal and the general error.message will be displayed in the
toaster.

* Remove unnecessary use of throwIfNotOk in our client API calls

The new HTTP client raises an error on a 4xx or 5xx response, so there
should not be a case where throwIfNotOk is actually going to throw an
error.

The established pattern on the frontend is to catch errors at the call
site and handle them appropriately, so I'm mainly just verifying that
these are caught where they're used, now.

* Move errorToToaster and ToasterError to general location

These were living in ML since that's where they originated. However, we
have need of it (and already use it) elsewhere.

The basic pattern for error handling on the frontend is:
1) API call throws error
2) caller catches error and dispatches a toast

throwIfNotOk is meant to convert the error into a useful message in 1).
We currently use both errorToToaster and displayErrorToast to display
that in a toaster in 2)

Now that errorToToaster handles a few different types of errors, and
throwIfNotOk is going to be bypassed due to the new client behavior of
throwing on error, we're going to start consolidating on:

1) Api call throws error
2) caller catches error and passes it to errorToToaster

* Refactor Rules API functions to not use throwIfNotOk

* Ensures that all callers of these methods properly catch errors
* Updates error toasterification to use errorToToaster
* Simplifies tests now that we mainly just invoke the http client and
return the result.

throwIfNotOk is not being used in the majority of cases, as the client
raises an error and bypasses that call.

The few cases this might break are where we return a 200 but have errors
within the response. Whether throwIfNotOk handled this or not, I'll need
a simpler helper to accomplish the same behavior.

* Define a type for our BulkRule responses

These can be an array of errors OR rules; typing it as such forces
downstream to deal with both. enableRules was being handled correctly
with the bucketing helper, and TS has confirmed the rest are as well.

This obviates the need to raise from our API calls, as bulk errors are
recoverable and we want to both a) continue on with any successful rules
and b) handle the errors as necessary. This is highly dependent on the
caller and so we can't/shouldn't handle it here.

* Address case where bulk rules errors were not handled

I'm not sure that we're ever using this non-dispatch version, but it was
throwing a type error. Will bring it up in review.

* Remove more throwIfNotOk uses from API calls

These are unneeded as an error response will already throw an error to
be handled at the call site.

* Display an error toaster on newsfeed fetch failure

* Remove dead code

This was left over as a result of #56261

* Remove throwIfNotOk from case API calls

Again, not needed because the client already throws.

* Update use_get_tags for NP

* Gets rid of throwIfNotOK usage
* uses core http fetch

* Remove throwIfNotOk from signals API

* Remove throwIfNotOk

This served the same purpose as errorToToaster, but in a less robust
way. All usages have been replaced, so now we say goodbye.

* Remove custom errors in favor of KibanaApiError and isApiError type predicate

There was no functional difference between these two code paths, and
removing these custom errors allowed us to delete a bunch of associated
code as well..

* Fix test failures

These were mainly related to my swapping any remaining fetch calls with
the core router as good kibana denizens should :salute:

* Replace use of core mocks with our simpler local ones

This is enough to get our tests to pass. We can't use the core mocks for
now since there are circular dependencies there, which breaks our build.

* add signal api unit tests

* privilege unit test api

* Add unit tests on the signals container

* Refactor signals API tests to use core mocks

* Simplifies our mocking verbosity by leveraging core mocks
* Simplifies test setup by isolating a reference to our fetch mock
* Abstracts response structure to pure helper functions

The try/catch tests had some false positives in that nothing would be
asserted if the code did not throw an error. These proved to be masking
a gap in coverage for our get/create signal index requests, which do not
leverage `throwIfNotOk` but instead rely on the fetch to throw an error;
once that behavior is verified we can update those tests to have our
fetchMock throw errors, and we should be all set.

* Simplify signals API tests now that the subjects do less

We no longer re-throw errors, or parse the response, we just return the
result of the client call. Simple!

* Simplify API functions to use implict returns

When possible. Also adds missing error-throwing documentation where
necessary.

* Revert "Display an error toaster on newsfeed fetch failure"

This reverts commit 64213221f5.

* Error property is readonly

* Pull uuid generation into default argument value

* Fix type predicate isApiError

Uses has to properly inspect our errorish object. Turns out we have a
'message' property, not an 'error' property.

* Fix test setup following modification of type predicate

We need a message (via new Error), a body.message, and a
body.status_code to satisfy isApiError.

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-10 09:11:17 -05:00
Nathan Reese
eb533c8211
[Maps] convert tooltip classes to typescript (#59589)
* getting started

* fix ts lint errors

* TS es_tooltip_property

* convert ESAggTooltipProperty to TS

* final clean up

* ts lint cleanup

* review feedback

* remove unused import

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-10 07:33:20 -06:00
Corey Robertson
e982bed7c6
Move canvas to use NP Expressions service (#58387)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-10 09:11:58 -04:00
Anton Dosov
8a3e9c6b32
[Unit Testing] Configure react-testing-library queries to use Kibana's data-test-subj instead of default data-testid (#59445) 2020-03-10 13:16:58 +01:00
Oliver Gupte
35bcb36ee6
Fixes #59513 by hiding one of the symmetric edges rather than omiting it (#59514)
in cytoscape graph. Also selects root nodes with no incoming edges
rather than just unconnected nodes.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-09 23:55:44 -07:00
Thomas Neirynck
6e5e8c815e
[Maps] Support categorical styling for numbers and dates (#57908) 2020-03-09 13:22:30 -04:00
James Gowdy
92cc04c7df
[ML] Refactoring anomaly detector job types (#59556)
* [ML] Refactoring anomaly detector job types

* removing calendar type

* update validateCardinality

* fixing test

* updating  types in functional tests

* using state constants
2020-03-09 13:51:07 +00:00
Peter Pisljar
a6489aa70e
additional visualizations plugin cleanup before moving to NP (#59318) 2020-03-09 13:11:05 +01:00
Andrea Del Rio
55fa3d6f42
[Alerting] "Create alert" graph visualization design improvements (#59399) 2020-03-06 18:29:17 -08:00
Yuliia Naumenko
b960c6aff7
Alerting update route throttle property is missing (#59580)
* Added throttle property to update method of alertClient

* Fixed failing snapshot

* Fixed type check errors

* Fixed null update for siem throttle
2020-03-06 17:21:21 -08:00
MadameSheema
9ab4aa027c
[SIEM] Adds 'Load prebuilt rules' Cypress test (#59529)
* adds 'load prebuilt rules'

* fixes typecheck issue

* updates jest snapshot
2020-03-06 22:41:05 +01:00
Spencer
76c205cd1e
ensure fs deletes are not cwd dependent (#59570)
Co-authored-by: spalger <spalger@users.noreply.github.com>
2020-03-06 11:54:49 -07:00
Nathan L Smith
0d3dd97691
Empty message for APM service map (#59518)
When only one node is displayed, show an empty message.

Also:

* Start adding a basic Jest test for the ServiceMap component
* Fix bug where EuiDocsLink was rendering "children" instead of the actual children

Closes #59326.
Closes #59128.
2020-03-06 12:54:28 -06:00
Tim Sullivan
fbbb3f8091
[Reporting] Improve the page exit error messages (#59351)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-06 11:43:15 -07:00
Walter Rafelsberger
f4f956dfeb
[ML] Transforms: Migrate client plugin to NP. (#59443)
Migrates the client side plugin of transforms to NP.
- Gets rid of the last parts of the shim (http, documentation links)
- Moves the plugin from x-pack/legacy/plugins/transform/public to x-pack/plugins/transform
- Creates a custom mock for appDependencies based on NP services
- Fixes jest tests to get rid of all act() related warnings
2020-03-06 17:44:35 +01:00
Andrew Goldstein
060b9fb10e
[SIEM] Update Timeline to use the latest euiFlyoutBody style (#59524)
## [SIEM] Update Timeline to use the latest euiFlyoutBody style

[A recent update to EUI](https://github.com/elastic/eui/pull/2837) requires an update to Timeline to restore its original padding, per the before / after screenshots below:

### Before

The previous code, which was using the `euiFlyoutBody__overflow` style, has extra padding (before this PR):

![timeline-padding-before-chrome](https://user-images.githubusercontent.com/4459398/76060425-81e37500-5f3e-11ea-8083-a58297afee85.png)

### After Chrome `80.0.3987.132`

The new code in this PR uses `euiFlyoutBody__overflowContent`, which restores the Timeline's original padding:

![timeline-paddng-after-chrome-default-theme](https://user-images.githubusercontent.com/4459398/76060436-8b6cdd00-5f3e-11ea-80d6-9ff0e74722c3.png)

![timeline-padding-after-chrome-dark-theme](https://user-images.githubusercontent.com/4459398/76060601-dedf2b00-5f3e-11ea-8a46-1008d7defe09.png)

### After Firefox `73.0.1`

![timeline-padding-after-firefox](https://user-images.githubusercontent.com/4459398/76060692-18b03180-5f3f-11ea-8277-31b6f9dbf211.png)

### After Safari `13.0.5`

![timeline-padding-after-safari](https://user-images.githubusercontent.com/4459398/76060744-38475a00-5f3f-11ea-9b04-cdd45fa41702.png)
2020-03-06 08:45:08 -07:00
Dima Arnautov
d969c08a00
[ML] Show view series link in anomalies table for machine_learning_user role (#59549) 2020-03-06 16:19:03 +01:00
Corey Robertson
9a3d0a5229
Move build_embeddable_filters into public (#59087)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-06 10:12:05 -05:00
Marta Bondyra
4977e57a3e
[Lens] Remove warnings in tests in EditorFrame (#59447)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-06 13:06:41 +01:00
Dima Arnautov
3a53fe8e45
[ML] Use Kibana's HttpHandler for HTTP requests (#59320)
* [ML] use kibana http

* [ML] fromHttpHandler

* [ML] remove __LEGACY, update asSystemRequest header

* [ML] transform with NP http
2020-03-06 11:34:19 +01:00
Cauê Marcondes
2817d6e3a8
[APM] Create settings page to manage Custom Links (#57788)
* creating custom action index

* reverting service form to service section

* creating useForm hooks and fields section

* adding react-hook-form

* refactoring

* validating filters

* fixing imports

* refactoring to NP and creating save custom action

* creating basic apis for custom actions

* refactoring

* changing custom action filters type

* adding delete option

* removing useForm

* fixing flyout view

* filters are invalid when selecting the default value

* ui fixes

* ui fixes

* fixing typescript

* fixing typescript

* fixing labels and adding space btw components

* refactoring filters structure

* removing reach-hook-form

* removing reach-hook-form

* adding unit tests

* adding unit tests

* create custom action index

* adding filter option

* refactoring create index, creating filter links

* creating list api

* rename custom action to custom link

* fixing unit tests

* adding unit tests

* refactoring callApmApi

* removing useCallApmApi hook

* Rename Flyoutfooter.tsx to FlyoutFooter.tsx

* removing unused import

* fixing typescript errors

* fixing duplicate messages

* removing filters

* fixing save functionality

* fixing pr comments

* fixing pr comments
2020-03-06 11:06:16 +01:00
MadameSheema
8220999c12
completes navigation test (#59141)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-06 08:42:18 +01:00
Andrew Goldstein
4db7f49608
[SIEM] Fixes dragging entries to the Timeline while data is loading may trigger a partial page reload (#59476)
## [SIEM] Fixes dragging entries to the Timeline while data is loading may trigger a partial page reload

The `react-beautiful-dnd` library, upgraded during the `7.6` stack release from
`10.0.1` to `12.2.0`, includes a breaking change to the way [errors are handled](https://github.com/atlassian/react-beautiful-dnd/blob/v12.0.0/docs/guides/setup-problem-detection-and-error-recovery.md)
and recovered. As a result of this change, an uncaught error may trigger a
an effect that feels (from the perspective of a user) like a partial page
reload.

The most common condition where this can occur is when dragging entries to the
Timeline while data is loading, per the animated gif below:

![refresh-error](https://user-images.githubusercontent.com/4459398/76016029-59755f80-5ed9-11ea-858d-cb1189d22ea9.gif)

## Reproduction steps

1. Navigate to the Hosts page
2. Open the Timeline
3. Drag a host to the Timeline
4. While data is still loading, drag a different host to the Timeline to create an `or` query

**Expected Results**
* The page does not appear to reload
* In development mode, a single error is logged to the JS console

**Actual Results**
* The page appears to reload
* In development mode, two errors are logged to the JS console

**Error 1**
```
react-beautiful-dnd
Invariant failed: Cannot find droppable entry with id [droppableId.content.event-details-value-default-draggable-plain-column-renderer-formatted-field-value-timeline-1-kLGooXABOOUskGlPiQw5-@timestamp-1583260131000]👷<200d> This is a development only message. It will be removed in production builds.
    in Draggable (created by ConnectFunction)
    in ConnectFunction (created by PrivateDraggable)
    in PrivateDraggable (created by PublicDraggable)
    in PublicDraggable (created by Droppable)
    in Droppable (created by ConnectFunction)
    in ConnectFunction
```

**Error 2**
```
react-beautiful-dnd
Invariant failed: Cannot find droppable entry with id [droppableId.content.event-details-value-default-draggable-plain-column-renderer-formatted-field-value-timeline-1-kLGooXABOOUskGlPiQw5-@timestamp-1583260131000]👷<200d> This is a development only message. It will be removed in production builds.
    in ErrorBoundary (created by DragDropContext)
    in DragDropContext (created by Anonymous)
    in Anonymous
```

### Desk testing

Tested locally in:
* Chrome `80.0.3987.122`
* Firefox `73.0.1`
* Safari `13.0.5`

Fixes https://github.com/elastic/kibana/issues/59466
2020-03-05 23:08:56 -07:00
Tim Sullivan
893d8da1d8
[Reporting/Screenshots] Handle page setup errors and capture the page, don't fail the job (#58683)
* [Reporting] Handle error if intercepted request could not be continued

* [Reporting/Screenshots] Handle page setup errors and capture the page with errors shown

* show warnings in UI

* i18n todos

* Cleanup an old troubleshooting task

* set the default for all new timeout settings to 30 seconds

* fix some tests

* update error strings

* Cleanup 2

* fix tests 2

* polish the job info map status items

* More error message updating

* Log the error that was caught

* Oops fix ts

* add documentation

* fix i18n

* fix mocha test

* use the openUrl timeout as the default for navigation

* fix comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-05 22:26:36 -07:00
Xavier Mouligneau
c29ef14656
[SIEM] [CASES] API with io-ts validation (#59265)
* refactor to use io-ts, to be able to have ressource with sub, add total comments via comment_ids, be able to delete multiple cases/comments

* fix test

* adapt UI to refactor of the API

* put it back the way it was

* clean up to get cases

* review I

* review II - bring back url  parameter

* fix merge

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-05 23:29:55 -05:00
Nathan Reese
578137fb20
[Maps] top term percentage field property (#59386)
* [Maps] top term percentage property

* populate percentage in feature properties

* TS work

* clean up TS

* fix all type errors

* unit test for esAggFieldsFactory

* clean up

* i18n cleanup

* do not show decimal place for perentage

* fix jest expects

* fix eslint errors

* tslint errors

* handle empty top bucket aggregation

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-05 19:58:22 -07:00
Chandler Prall
096dda6f34
Upgrade EUI to v20.0.2 (#59199)
* Updated EUI to 20.0.1; updated typescript usage

* snapshots

* Upgrade to eui 20.0.2, fix one more type

* PR feedback

* Update EUI icon usage to the correct types

* Updated with master
2020-03-05 12:27:52 -07:00
Steph Milovic
91a5b17cfd
[SIEM] [Case] All cases page design updates (#59248) 2020-03-05 11:29:44 -07:00
Thomas Neirynck
46738cfa0a
[Maps] Add field and style-meta types (#58766) 2020-03-05 12:26:28 -05:00
Yuliia Naumenko
4883d4bb2a
Fixed ci type check errors for alerting and actions properties for SIEM RouteHandlerContext (#59400)
* Fixed ci type check errors for alerting and actions optional properties on RouteHandlerContext

* Reverted git revert b83f81458c
2020-03-05 07:52:24 -08:00
James Gowdy
4371b1ca7d
[ML] Fix advanced wizard datafeed form labels (#59413) 2020-03-05 14:59:58 +00:00
Walter Rafelsberger
ce9e887644
[ML] Transforms: Fixed custom KibanaContext deprecation. (#59410)
- Deprecates the custom KibanaContext.
- Where applicable dependencies provided via KibanaContext are now passed on via AppDependencies.
- The main feature of KibanaContext was to populate index pattern and saved search information for the transform wizard. This is now provided via the useSearchItems() custom hook.
2020-03-05 14:52:44 +01:00
Shahzad
edfbe03ffa
[Uptime] Improve duration chart (#58404)
* use differential colors for duration chart

* remove duration chart gql

* update type

* type fix

* fix tyoe

* update translation

* update test

* update conflicts

* type checking

* update snaps

* PR feedback

* PR feedback

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-05 10:43:55 +01:00
Sébastien Loix
a05c3211b9
[Snapshot & Restore] NP migration (#59109) 2020-03-05 15:07:23 +05:30
CJ Cenizal
bb86bf2ebb
Change remote_clusters ID to remoteClusters (#59246) 2020-03-04 19:53:15 -08:00
Luke Elmers
ba5784ac57
Clean up date histogram agg type. (#58805) 2020-03-04 17:03:23 -07:00
Melissa Alvarez
44921e6110
[ML] Management: fix license unsubscribe (#59365)
* check for undefined before unsubscribe.remove skip from test

* use take for observable
2020-03-04 19:00:34 -05:00
patrykkopycinski
ac4f8f4ef5
[SIEM] Fix rule delete/duplicate actions (#59306) 2020-03-04 21:31:43 +01:00
spalger
ef38287551 Revert "[ML] Transforms: Deprecate custom KibanaContext. (#59133)"
This reverts commit 29975fa614.
2020-03-04 12:50:04 -07:00
Stacey Gammon
543481ba53
Add direct access link registry and dashboard impl and use in ML (#57496)
* Add direct access link registry and dashboard impl and use in ML

* Add example plugin with migration example

* address code review comments

* Fixes, more code review updates

* Readme clean up

* add tests

* remove else

* Rename everything from DirectAccessLinkGenerator to the much short UrlGenerator. also fix the ml # thing and return a relative link from dashboard genrator

* add important text in bold

* Move url generators into share plugin

* add correct i18n prefix

* Fix timeRange url name

* make share plugin optional for dashboard

* fix code owners

* Use base UrlGeneratorState type, add comments

* Fix hash bug and add test that would have caught it
2020-03-04 12:43:09 -05:00
Aaron Caldwell
76e3f82754
[Maps] Add missing license to requests in maps embeddables (#59207)
* Pull core service init out into separate function

* Call bind function from embeddable factory constructor

* Move inspector init back to start method. Remove old license check file

* Add TS types
2020-03-04 10:00:01 -07:00
Walter Rafelsberger
29975fa614
[ML] Transforms: Deprecate custom KibanaContext. (#59133)
- Deprecates the custom KibanaContext.
- Where applicable dependencies provided via KibanaContext are now passed on via AppDependencies.
- The main feature of KibanaContext was to populate index pattern and saved search information for the transform wizard. This is now provided via the useSearchItems() custom hook.
2020-03-04 16:56:01 +01:00
Stacey Gammon
d2cbc59ad4
Further improve type checking for actions and triggers (#58765)
* wip

* review follow up

* make ACTION a prefix, not SUFFIX

* fix path

* add warnings about casting to ActionType

* Make context  an object in examples, not a string

* require object context, which seems to fix the partial requirement in type and thus the type issue

* mistake

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-04 10:27:14 -05:00
Christos Nasikas
aea4811750
[SIEM][CASE] Configure cases: Closure Options & Field Mappings UI (#59062)
* Create closure options radio group

* Create closure options component

* Refactor structure

* Create field mapping row

* Create field component

* Show closure options

* Show field mapping

* Translate editUpdate options

* Add more siem fields

* Remove unnecessary export

* Leave spaces between sections

* Fix callbacks

* Better return

* Fix callback

* Move thirdPartyFields to parent component

* Rename constant

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-04 17:06:33 +02:00
Chris Roberson
9a1b4b9a6b
[Monitoring] Ensure we use the monitoring cluster for retrieving xpack info (#59075)
* Ensure we use the monitoring cluster for retrieving xpack info

* Remove unnecessary code
2020-03-04 09:27:23 -05:00
Aaron Caldwell
c4458ca1b4
[File upload] Move File Upload to New Platform (#58550)
* Move file upload to np. Some additional mods & removals

* Consume file upload from NP in maps and pass to kibana services

* Register telemetry mappings

* Init indexPatternService in start method

* Fix type check issues. Add missing prop to telemetry

* Update i18n path

* Review feedback
2020-03-04 06:44:44 -07:00
patrykkopycinski
7ad083f332
Restores [SIEM] Fix Timeline registerProvider to be called only when it's needed (#59003)
* [SIEM] Fix Timeline registerProvider to be called only when it's needed

* cleanup

* add unit tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-04 03:31:10 -08:00