Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Security Solution] [Detections] EQL Rule Creation (#76831) #77523

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

rylnd
Copy link
Contributor

@rylnd rylnd commented Sep 15, 2020

Backports the following commits to 7.x:

* Use existing predicate helper to avoid hardcoded strings

* Render our field components with React.createElement

Without this, we get some bad behaviors:
* Cannot use React.memo'd components
* Cannot switch between UseField components (causes a "change in the
  order of hooks" error from React)

* WIP: EQL Rules can be created

WIP because: they're probably not treated well in the UI, and they're certainly not
going to execute properly, and there are no tests.

* Add unit tests for changes to schema + helpers

* Add unit tests for new EQL query input component

It's mostly just a glorified textarea for now.

* Add integration test for EQL Rule creation

* Does not assert the query language, as that is not displayed on Rule
  Details
* Does not exercise rule execution

* Use predicate helper

* Throw an error if an EQL Rule is executed

This is to prevent undefined behavior until EQL execution is
implemented.

* Fix failing tests

I changed the default value for the form field mock from an array to a
string; this fixes the few tests that were relying on it being an array.

* Audit our rule statements/switches

I made a pass through our treatment of RuleType to verify that EQL rules
would be treated appropriately. Since the default/fallthrough case is
typically the Query rule, and since this rule has the same
attributes/behavior as the new EQL rule, not much had to change here.

I converted a few if statements to exhaustive switches where possible,
and used predicate helpers in places where it was not.

* Add tests around use of custom components with UseField

There was an issue previously where memoized components would not work;
these are primarily regression tests covering that use case.

* Fix typo

* Add keys to UseField to ensure unmount

When swapping between the Custom Query and EQL rule types, we want to
ensure that the corresponding input component coming from UseField fully
unmounts and remounts with the new component.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@rylnd rylnd requested review from a team as code owners September 15, 2020 17:30
@rylnd rylnd added the backport label Sep 15, 2020
@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 1959 +2 1957

async chunks size

id value diff baseline
securitySolution 10.0MB +3.5KB 10.0MB

page load bundle size

id value diff baseline
esUiShared 995.1KB +63.0B 995.0KB
securitySolution 793.0KB +18.0B 793.0KB
total +81.0B

distributable file count

id value diff baseline
default 47264 +1 47263

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@rylnd rylnd merged commit f9c56c0 into elastic:7.x Sep 15, 2020
@rylnd rylnd deleted the backport/7.x/pr-76831 branch September 15, 2020 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants