kibana/docs
Ryland Herrick 7cfdeaeede
[Security Solution][Detections] EQL Validation (#77493)
* WIP: Adding new route for EQL Validation

This is mostly boilerplate with some rough parameter definitions; the
actual implementation of the validation is going to live in our
validateEql function.

A few tests are failing as the mocks haven't yet been implemented, I
need to see the shape of the responses first.

* Cherry-pick Marshall's EQL types

* Implements actual EQL validation

* Performs an EQL search
* filters out non-parsing errors, and returns what remains in the
  response
* Adds mocks for empty EQL responses (we don't yet have a need for
  mocked data, but we will when we unit-test validateEql)

* Adds validation calls to the EQL form input

* Adds EQL Validation response schema,mocks,tests
* Adds frontend function to call our validation endpoint
* Adds hook, useEqlValidation, to call the above function and return
  state
* Adds labels/help text for EQL Query bar
* EqlQueryBar consumes useEqlValidation and marks the field as invalid,
  but does not yet report errors.

* Do not call the validation API if query is not present

This causes a broader error that results in a 400 response; we can (and
do) handle the case of a blank query in the form itself.

* Remove EQL Help Text

It doesn't add any information for the user, and it currently looks bad
when combined with validation errors.

* Flesh out and use our popover for displaying validation errors

* Fixes issue where old errors were persisted after the user had made
  modifications

* Include verification_exception errors as validation errors

These include errors related to index fields and mappings.

* Generalize our validation helpers

We're concerned with validation errors; the source of those errors is an
implementation detail of these functions.

* Move error popover and EQL reference link to footer

This more closely resembles the new Eui Markdown editor, which places
errors and doc links in a footer.

* Fix jest tests following additional prop

* Add icon for EQL Rule card

* Fixes existing EqlQueryBar tests

These were broken by our use of useAppToasts and the EUI theme.

* Add unit tests around error rendering on EQL Query Bar

* Add tests for ErrorPopover

* Remove unused schema type

Decode doesn't do any additional processing, so we can use t.TypeOf here
(the default for buildRouteValidation).

* Remove duplicated header

* Use ignore parameter to prevent EQL validations from logging errors

Without `ignore: [400]` the ES client will log errors and then throw
them. We can catch the error, but the log is undesirable.

This updates the query to use the ignore parameter, along with updating
the validation logic to work with the updated response.

Adds some mocks and tests around these responses and helpers, since
these will exist independent of the validation implementation.

* Include mapping_exceptions during EQL query validation

These include errors for inaccessible indexes, which should be useful to
the rule writer in writing their EQL query.

* Display toast messages for non-validation messages

* fix type errors

This type was renamed.

* Do not request data in our validation request

By not having the cluster retrieve/send any data, this should saves us
a few CPU cycles.

* Move EQL validation to an async form validator

Rather than invoking a custom validation hook (useEqlValidation) at custom times (onBlur) in our EqlQueryBar
component, we can instead move this functionality to a form validation
function and have it be invoked automatically by our form when values
change. However, because we still need to handle the validation messages
slightly differently (place them in a popover as opposed to an
EuiFormRow), we also need custom error retrieval in the form of
getValidationResults.

After much pain, it was determined that the default behavior of
_.debounce does not work with async validator functions, as a debounced
call will not "wait" for the eventual invocation but will instead return
the most recently resolved value. This leads to stale validation
results and terrible UX, so I wrote a custom function (debounceAsync)
that behaves like we want/need; see tests for details.

* Invalidate our query field when index patterns change

Since EQL rules actually validate against the relevant indexes, changing
said indexes should invalidate/revalidate the query.

With the form lib, this is beautifully simple :)

* Set a min-height on our EQL textarea

* Remove unused prop from EqlQueryBar

Index corresponds to the value from the index field; now that our EQL
validation is performed by the form we have no need for it here.

* Update EQL overview link to point to elasticsearch docs

Adds an entry in our doclinks service, and uses that.

* Remove unused prop from stale tests

* Update docLinks documentation with new EQL link

* Fix bug where saved query rules had no type selected on Edit

* Wait for kibana requests to complete before moving between rule tabs

With our new async validation, a user can quickly navigate away from the
Definition tab before the validation has completed, resulting in the
form being invalidated. Any subsequent user actions cause the form to
correct itself, but until I can find a better solution here this really
just gives the validation time to complete and sidesteps the issue.
2020-10-02 13:19:02 -05:00
..
api [DOCS] Updates create.asciidoc (#73481) 2020-09-24 12:25:51 -05:00
apm Remove service map beta badge (#78039) 2020-09-22 10:14:31 -05:00
canvas updated discover with alt text (#77660) 2020-09-28 10:53:38 -05:00
dev-tools [DOCS] Removes occurrences of X-Pack Security and Reporting (#72302) 2020-07-17 14:53:04 -07:00
developer normalize paths before printing them into the generated plugin list (#79232) 2020-10-02 09:50:49 -07:00
development [Security Solution][Detections] EQL Validation (#77493) 2020-10-02 13:19:02 -05:00
discover [DOCS] Updates KQL doc (#77817) 2020-09-29 10:57:30 -07:00
getting-started Update tutorial-visualizing.asciidoc (#76977) 2020-09-28 10:41:03 -05:00
infrastructure [DOCS] Move metrics app content to metrics monitoring guide (#69033) 2020-06-12 19:33:26 +01:00
ingest_manager Add ingest manager topic to docs (#68980) 2020-06-12 11:27:55 -07:00
logs [DOCS] Move Logs app content to Logs monitoring guide (#68644) 2020-06-10 16:14:46 +01:00
management [DOCS] Redirects CCR and Remote Clusters docs to ES reference (#77909) 2020-09-23 11:52:04 -07:00
maps [maps][docs] add trouble shooting for index not listed (#73066) 2020-07-23 15:22:54 -06:00
migration Hide management sections based on cluster/index privileges (#67791) 2020-09-14 09:30:47 -04:00
observability [DOCS] Add Observability topic (#73041) 2020-08-05 09:28:20 +01:00
plugins Update known-plugins.asciidoc (#69370) 2020-07-02 18:01:31 +03:00
settings Add acnchors to Kibana docs-settings (#78115) 2020-09-23 08:01:05 -07:00
setup Remove unused elasticsearch.preserverHost setting (#78608) 2020-09-30 10:39:08 +02:00
siem [Docs]Security docs 7.9 updates (#75156) 2020-08-18 08:25:06 +03:00
spaces [DOCS] Updates Management docs to match UI (#72514) 2020-07-22 08:00:53 -07:00
uptime [DOCS] Move Uptime Kibana documentation into Uptime guide (#67508) 2020-06-04 15:58:58 +01:00
user Grouped features for role management (#78152) 2020-10-02 08:45:28 -04:00
visualize/images [Lens] Drag dimension to replace (#75895) 2020-09-04 10:11:41 -04:00
accessibility.asciidoc Adding the Accessibility Statement to docs (#57153) 2020-02-11 17:31:43 -05:00
CHANGELOG.asciidoc [DOCS] Removes abbrevtitles from parts (#34002) 2019-03-27 13:23:32 -07:00
glossary.asciidoc [DOCS] Dashboard-first docs refresh (#76194) 2020-09-03 16:34:25 -05:00
gs-index.asciidoc [DOCS] Adds kibana-pull attribute for release docs (#69554) 2020-06-18 13:19:10 -07:00
index.asciidoc [DOCS] Adds kibana-pull attribute for release docs (#69554) 2020-06-18 13:19:10 -07:00
index.x.asciidoc [DOCS] Removes redundant index.asciidoc files (#19192) 2018-05-18 11:50:51 -07:00
limitations.asciidoc [DOCS] Condenses limitations docs (#57393) 2020-02-12 08:18:58 -08:00
migration.asciidoc [DOCS] Adds What's New (#68918) 2020-06-11 12:06:29 -07:00
redirects.asciidoc [DOCS] Redirects CCR and Remote Clusters docs to ES reference (#77909) 2020-09-23 11:52:04 -07:00
template.asciidoc [DOCS] Kibana docs template (#44695) 2019-09-16 11:19:01 -05:00