-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution][Detections] Add new fields to the rule model: Related Integrations, Required Fields, and Setup #132409
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ | |
| */ | ||
|
|
||
| export * from './rule_monitoring'; | ||
| export * from './rule_params'; | ||
| export * from './schemas'; | ||
146 changes: 146 additions & 0 deletions
146
x-pack/plugins/security_solution/common/detection_engine/schemas/common/rule_params.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import * as t from 'io-ts'; | ||
| import { NonEmptyString } from '@kbn/securitysolution-io-ts-types'; | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
| // Related integrations | ||
|
|
||
| /** | ||
| * Related integration is a potential dependency of a rule. It's assumed that if the user installs | ||
| * one of the related integrations of a rule, the rule might start to work properly because it will | ||
| * have source events (generated by this integration) potentially matching the rule's query. | ||
| * | ||
| * NOTE: Proper work is not guaranteed, because a related integration, if installed, can be | ||
| * configured differently or generate data that is not necessarily relevant for this rule. | ||
| * | ||
| * Related integration is a combination of a Fleet package and (optionally) one of the | ||
| * package's "integrations" that this package contains. It is represented by 3 properties: | ||
| * | ||
| * - `package`: name of the package (required, unique id) | ||
| * - `version`: version of the package (required, semver-compatible) | ||
| * - `integration`: name of the integration of this package (optional, id within the package) | ||
| * | ||
| * There are Fleet packages like `windows` that contain only one integration; in this case, | ||
| * `integration` should be unspecified. There are also packages like `aws` and `azure` that contain | ||
| * several integrations; in this case, `integration` should be specified. | ||
| * | ||
| * @example | ||
| * const x: RelatedIntegration = { | ||
| * package: 'windows', | ||
| * version: '1.5.x', | ||
| * }; | ||
| * | ||
| * @example | ||
| * const x: RelatedIntegration = { | ||
| * package: 'azure', | ||
| * version: '~1.1.6', | ||
| * integration: 'activitylogs', | ||
| * }; | ||
| */ | ||
| export type RelatedIntegration = t.TypeOf<typeof RelatedIntegration>; | ||
| export const RelatedIntegration = t.exact( | ||
| t.intersection([ | ||
| t.type({ | ||
| package: NonEmptyString, | ||
| version: NonEmptyString, | ||
| }), | ||
| t.partial({ | ||
| integration: NonEmptyString, | ||
| }), | ||
| ]) | ||
| ); | ||
|
|
||
| /** | ||
| * Array of related integrations. | ||
| * | ||
| * @example | ||
| * const x: RelatedIntegrationArray = [ | ||
| * { | ||
| * package: 'windows', | ||
| * version: '1.5.x', | ||
| * }, | ||
| * { | ||
| * package: 'azure', | ||
| * version: '~1.1.6', | ||
| * integration: 'activitylogs', | ||
| * }, | ||
| * ]; | ||
| */ | ||
| export type RelatedIntegrationArray = t.TypeOf<typeof RelatedIntegrationArray>; | ||
| export const RelatedIntegrationArray = t.array(RelatedIntegration); | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
| // Required fields | ||
|
|
||
| /** | ||
| * Almost all types of Security rules check source event documents for a match to some kind of | ||
| * query or filter. If a document has certain field with certain values, then it's a match and | ||
| * the rule will generate an alert. | ||
| * | ||
| * Required field is an event field that must be present in the source indices of a given rule. | ||
| * | ||
| * @example | ||
| * const standardEcsField: RequiredField = { | ||
| * name: 'event.action', | ||
| * type: 'keyword', | ||
| * ecs: true, | ||
| * }; | ||
| * | ||
| * @example | ||
| * const nonEcsField: RequiredField = { | ||
| * name: 'winlog.event_data.AttributeLDAPDisplayName', | ||
| * type: 'keyword', | ||
| * ecs: false, | ||
| * }; | ||
| */ | ||
| export type RequiredField = t.TypeOf<typeof RequiredField>; | ||
| export const RequiredField = t.exact( | ||
| t.type({ | ||
| name: NonEmptyString, | ||
| type: NonEmptyString, | ||
| ecs: t.boolean, | ||
| }) | ||
| ); | ||
|
|
||
| /** | ||
| * Array of event fields that must be present in the source indices of a given rule. | ||
| * | ||
| * @example | ||
| * const x: RequiredFieldArray = [ | ||
| * { | ||
| * name: 'event.action', | ||
| * type: 'keyword', | ||
| * ecs: true, | ||
| * }, | ||
| * { | ||
| * name: 'event.code', | ||
| * type: 'keyword', | ||
| * ecs: true, | ||
| * }, | ||
| * { | ||
| * name: 'winlog.event_data.AttributeLDAPDisplayName', | ||
| * type: 'keyword', | ||
| * ecs: false, | ||
| * }, | ||
| * ]; | ||
| */ | ||
| export type RequiredFieldArray = t.TypeOf<typeof RequiredFieldArray>; | ||
| export const RequiredFieldArray = t.array(RequiredField); | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
| // Setup guide | ||
|
|
||
| /** | ||
| * Any instructions for the user for setting up their environment in order to start receiving | ||
| * source events for a given rule. | ||
| * | ||
| * It's a multiline text. Markdown is supported. | ||
| */ | ||
| export type SetupGuide = t.TypeOf<typeof SetupGuide>; | ||
| export const SetupGuide = t.string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,9 @@ export const savedRuleMock: Rule = { | |
| max_signals: 100, | ||
| query: "user.email: '[email protected]'", | ||
| references: [], | ||
| related_integrations: [], | ||
| required_fields: [], | ||
| setup: '', | ||
| severity: 'high', | ||
| severity_mapping: [], | ||
| tags: ['APM'], | ||
|
|
@@ -80,6 +83,9 @@ export const rulesMock: FetchRulesResponse = { | |
| 'event.kind:alert and event.module:endgame and event.action:cred_theft_event and endgame.metadata.type:detection', | ||
| filters: [], | ||
| references: [], | ||
| related_integrations: [], | ||
| required_fields: [], | ||
| setup: '', | ||
| severity: 'high', | ||
| severity_mapping: [], | ||
| updated_by: 'elastic', | ||
|
|
@@ -115,6 +121,9 @@ export const rulesMock: FetchRulesResponse = { | |
| query: 'event.kind:alert and event.module:endgame and event.action:rules_engine_event', | ||
| filters: [], | ||
| references: [], | ||
| related_integrations: [], | ||
| required_fields: [], | ||
| setup: '', | ||
| severity: 'medium', | ||
| severity_mapping: [], | ||
| updated_by: 'elastic', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,9 +67,12 @@ describe('useRule', () => { | |
| max_signals: 100, | ||
| query: "user.email: '[email protected]'", | ||
| references: [], | ||
| related_integrations: [], | ||
| required_fields: [], | ||
| risk_score: 75, | ||
| risk_score_mapping: [], | ||
| rule_id: 'bbd3106e-b4b5-4d7c-a1a2-47531d6a2baf', | ||
| setup: '', | ||
| severity: 'high', | ||
| severity_mapping: [], | ||
| tags: ['APM'], | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,9 +78,12 @@ describe('useRuleWithFallback', () => { | |
| "name": "Test rule", | ||
| "query": "user.email: '[email protected]'", | ||
| "references": Array [], | ||
| "related_integrations": Array [], | ||
| "required_fields": Array [], | ||
| "risk_score": 75, | ||
| "risk_score_mapping": Array [], | ||
| "rule_id": "bbd3106e-b4b5-4d7c-a1a2-47531d6a2baf", | ||
| "setup": "", | ||
| "severity": "high", | ||
| "severity_mapping": Array [], | ||
| "tags": Array [ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.