kibana/x-pack/test
Ryland Herrick 569c209f2c
[Security Solution][CTI] Investigation time enrichment UI (#103383)
* Add pure fn and consuming hook to fetch event enrichment

It's not being invoked yet, but I've added a placeholder where it's
going.

* Move existing enrichment tests to new spec file

This is a rough copy/paste, I'll clean up as I flesh out the new tests.

* Move test constants into tests that use them

* style: declare FC function as an FC

* Extract some inline parsing logic into a helper function

And test it!

* Solidifying enrichment types on the backend

* Declares an enum for our types
* Sets type during indicator match rule enrichment
* Sets type during investigation-time enrichment

* WIP: Enrichment rows are rendered on the alerts summary

There are lots of TODOs here, but this implements the following:

* Fetching investigation-time enrichments from the backend
* Parsing existing enrichments from timeline data
* Merging the two enrichment types together, and rendering them in rows
  as specified

Much of the data-fetching is hardcoded, and this broke the existing
pattern with SummaryView/SummaryRow so that got a little messy; I may
end up just using my own EuiTable but we'll see.

Threat Intel tab is currently broken; that's up next.

* Updates ThreatDetailsView to accept an array of enrichments

The investigation-time enrichments are a little messy because they
contain all the non-ECS fields that indicators contain; other than that,
this is looking good.

Still need to add the new header, and potentially sort the fields.

* Sort our details fields

This promotes sanity for the user.

* Add "view threat intel data" button

This simply opens the threat intel tab.

* Implement header for threat details sections

* Add a basic jest "unit" test around ThreatSummaryView

* Fix remaining tests for components we modified

This also addresses a bug where we were not properly sorting new
enrichments by first_seen; this is covered under the tests that were
fixed.

* Filter out duplicate investigation-time enrichments

Because the enrichment endpoint is dumb and doesn't know about the
existing event or its enrichments, we need to merge these together on
the client to reduce noise and redundant data.

* Add inspect button to investigation enrichments

* Massages the response into the format that the inspect component uses
* Moves stateful fetching of query and persisting in redux to new, more
  specialized hook
* Moves existing enrichment hook to a more suitable location in
  containers/

* Fix failing unit tests

* indicator match rule now specifies `matched.type` as coming from the
  rule
* Inspecting the enrichment query requires use of the redux store, which
  was not previously mocked

* Fix existing CTI cypress tests

This covers the basics of the Alert Summary and Threat Intel tabs; the
investigation-time enrichment functionality is up next.

* Adds a cypress test exercising investigation time enrichment

* Loads more indicators (filebeat data, `threat_indicator2` archive)
  AFTER the rule has executed
* Asserts that those indicators are also found on the alert summary.

* Populate event enrichment call with actual alert fields

This was previously hardcoded during development.

* Add a new field to our suspicious event to trigger enrichment

The existing myhash field will generate an alert due to the way the rule
is written, but the alert had no other fields that would match the
investigation time enrichment. This gives it a source.ip, and updates
the indicator to match.

* Only fetch enrichments data if there are valid event fields

If none of the alert's fields would be relevant to the enrichment query,
then we don't make the request at all.

* Update enrichments matched.typed in integration tests

This field was updated to reflect the source of the match, in this case:
indicator match rules.

* Ensure draggable fields are unique in a multi-match scenario

If a given field matched multiple indicators, then the previous
contextId was not unique as it was based on field/value that matched.
Adding provider to the mix would fix it, except that we're not
guaranteed to have a provider.

I've added both provider (if present) and an index value to the key to
ensure that it's unique.

* Simplify types

This field can never be null, as we always set it in our response.

* Move helper functioons out of shared location and into consuming component

These are unlikely to be used elsewhere.

* Clean up data parsing logic using reduce

This obviates the need for our filter/guard function and the extra loop
that it entails. We have to specify the return value of our reduce fn,
however, but that's mostly equivalent to our type guard.

* Move our general function into a general location

* Extract the concept of "enrichment identifiers"

This was already partially codified with 'buildEnrichmentId,' which is
used to dedup enrichments; this extends the idea to all fields that
could uniquely identify a given indicator.

* Use existing constant as the source of our enrichments query

This is now used by both the overview card and the enrichment query.

* Codify our default enrichment lookback as constants

* Remove unnecessary flexbox

The generic SummaryView component previously had to deal with
multi-valued CTI fields, representing the multiple values coming from
the multiple nested objects with that field.

However, with the new UI we no longer have that constraint, and so the
default columnar style, and the corresponding overriding styles, are no
longer necessary.

* Filter out partial responses in the event enrichment observable

The UI does not currently handle these. We need to test the behavior of
long-running queries with this filter, but this should simplify the
behavior to complete/error until we handle partial responses.

* Display placeholders while event enrichment is loading

Displays a loading spinner in the Threat Intel tab title, and some
loading lines where the enrichments summary is.

* Update our indicator data to be within the last 30 days

This fixes our cypress test, but it's going to start failing again in 30
days. However, by that time I'll have implemented the absolute data
picker, which will allow for a more comprehensive test in addition to us
sidestepping this issue.

* Fix type error with our details tabs

The name prop on a Tab will be rendered as a node, so both strings and
elements are acceptable. This relaxes the types to inherit from the
component itself.

* Fix failing jest tests

The addition of our filtering of the search observable broke this test,
since we now need to implement the search observable.

Rather than do that, we'll instead mock our local hook as that's more
likely to change.
2021-06-30 01:16:24 -04:00
..
accessibility [KibanaPageTemplate] Adds collapsibility to solutionNav (#103192) 2021-06-29 15:25:27 -04:00
alerting_api_integration [Alerting] Enable rule import/export and allow rule types to exclude themselves from export (#102999) 2021-06-28 20:35:27 -04:00
api_integration [ILM] Update API integration test (#103495) 2021-06-28 13:05:37 -04:00
api_integration_basic [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
apm_api_integration [APM] Filter on defined environment for latency charts (#103621) 2021-06-29 21:45:51 +02:00
banners_functional [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
case_api_integration [Cases] Fix push to external service error when connector's mapping does not exists (#102894) 2021-06-24 16:31:18 +03:00
cloud_integration Add telemetry for Elastic Cloud (#102390) 2021-06-24 14:47:38 -04:00
common [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
detection_engine_api_integration [Security Solution][CTI] Investigation time enrichment UI (#103383) 2021-06-30 01:16:24 -04:00
encrypted_saved_objects_api_integration [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
endpoint_api_integration_no_ingest [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
examples [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
fleet_api_integration [Detections] Adds automatic updating for Prebuilt Security Detection Rules package (#101846) 2021-06-24 15:31:25 -06:00
fleet_functional [Fleet + Integrations UI] Migrate Fleet UI to new tabbed layout (#101828) 2021-06-16 10:29:38 -07:00
functional [Page layouts] Some light fixes (#103197) 2021-06-29 19:50:15 -05:00
functional_basic Change file data visualizer links to point to new location in home application (#101393) 2021-06-09 08:30:40 -06:00
functional_cors [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
functional_embedded [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
functional_enterprise_search [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
functional_vis_wizard [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
functional_with_es_ssl [Alerting] Enable rule import/export and allow rule types to exclude themselves from export (#102999) 2021-06-28 20:35:27 -04:00
licensing_plugin [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
lists_api_integration [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
load [load testing] adjust ES heap size (#101906) 2021-06-24 13:45:39 +02:00
observability_api_integration [Kuery] Move json utils (#102058) 2021-06-16 18:15:47 +03:00
osquery_cypress Cypress baseline for osquery (#102265) 2021-06-23 13:59:35 +02:00
plugin_api_integration [Alerting] Using new es client in alerting functional tests (#102349) 2021-06-24 12:20:16 -04:00
plugin_api_perf [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
plugin_functional [RAC] T-Grid is moving to a new home (#100265) 2021-06-22 18:56:33 -04:00
reporting_api_integration Reporting: Check for pending jobs scheduled with ESQueue (#101447) 2021-06-23 12:06:23 -07:00
reporting_functional Replacing es_archives/reporting/ecommerce_kibana with kbn_archiver/reporting/ecommerce.json as part of migrating to kbn_archiver (#102825) 2021-06-22 19:16:53 -04:00
saved_object_api_integration Allow initialNamespaces to be used for isolated types (#102585) 2021-06-22 20:36:04 +02:00
saved_object_tagging Upgrade EUI to v34.3.0 (#101334) 2021-06-23 15:10:34 -05:00
saved_objects_field_count [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
search_sessions_integration [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
security_api_integration Update @elastic/elasticsearch to 8.0.0-canary13 (#98266) 2021-06-08 15:06:06 +02:00
security_functional Fix AppContainer layout (#101793) 2021-06-10 14:18:35 -04:00
security_solution_cypress [Security Solution][CTI] Investigation time enrichment UI (#103383) 2021-06-30 01:16:24 -04:00
security_solution_endpoint [Fleet] Improve performance of Fleet setup (#102219) 2021-06-17 11:58:41 -07:00
security_solution_endpoint_api_int [Fleet] Improve performance of Fleet setup (#102219) 2021-06-17 11:58:41 -07:00
security_solution_ftr/page_objects/detections [ts] migrate x-pack/test to composite ts project (#101441) 2021-06-08 12:54:05 -04:00
spaces_api_integration Sharing saved objects phase 3.5 (#100424) 2021-06-28 18:06:54 -04:00
stack_functional_integration [QA] Changes the telemetry banner dismiss location (#102721) 2021-06-21 14:33:12 -04:00
ui_capabilities [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
upgrade Upgrade functional test fixes (#100306) 2021-05-19 13:08:41 -06:00
upgrade_assistant_integration [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
usage_collection [kbn/test] move types/ftr into src (#99555) 2021-05-17 09:51:53 -07:00
visual_regression [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) 2021-06-08 17:37:42 -04:00
tsconfig.json Revert "[xpack/test] restore incremental: false in ts project" 2021-06-08 14:26:26 -07:00