elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.72k stars 8.14k forks source link

[Detections][Discuss] Detection engine tech debt/refactor opportunities #80792

Open marshallmain opened 3 years ago

marshallmain commented 3 years ago

Summary

Now with 6 different rule types in the detection engine we've accumulated some tech debt. Below are areas that I think we can refactor to reduce maintenance burden and make the detection engine easier to reason about.

High level goals:

I propose that the single source of truth is the rule SO data structure, which in turn is represented using a union of the individual rule types. The schemas for the various create/update/patch requests would be defined separately and should be the few places where we see some schema duplication due to the need for setting defaults for certain fields in the routes. However, unit tests can verify that the output from decoding with the create/update/patch schemas is a valid rule by following up with a decode using the source of truth rule schema. This ensures that the route schemas stay in sync with the source of truth.

Prior refactoring art

elasticmachine commented 3 years ago

Pinging @elastic/siem (Team:SIEM)

peluja1012 commented 3 years ago

Related PR: https://github.com/elastic/kibana/pull/82462

marshallmain commented 2 years ago

Remaining work on this issue is to remove the legacy RulesSchema (kibana/x-pack/plugins/security_solution/common/detection_engine/schemas/response/rules_schema.ts) in favor of the new schemas introduced in https://github.com/elastic/kibana/pull/82462.