-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution] Restructuring folders of Detection Engine + refactoring Rule Management #142950
Changes from 23 commits
2eef5de
20a7de5
f03f3d1
5babefe
4657f76
872394b
323db29
9eb427b
87b7299
fe818a1
1a0f5ba
31c5a82
1e79428
4a08b8b
5abd594
ae573dc
49d6f94
95c0926
1bb6651
38c27c5
c9476c6
a55d91d
cf04cf4
25cc4f8
66dc2ad
0b78136
8f55566
d6363ee
df5dfd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ pageLoadAssetSize: | |
screenshotting: 22870 | ||
searchprofiler: 67080 | ||
security: 65433 | ||
securitySolution: 273763 | ||
securitySolution: 339077 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be addressed shortly in a follow-up PR. #143532 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can resolving #95870 please be prioritized? It's affecting the end-user performance of Kibana as a whole and just appears to be getting worse, not better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will come with this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think after updating this PR with the main, which contains the recent bundle changes, we can set securitySolution: 66738 back. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @YulNaumenko @tylersmalley I managed to keep 66738 in this PR. Will see if I can reduce it a bit more by doing #143532 |
||
sessionView: 77750 | ||
share: 71239 | ||
snapshotRestore: 79032 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,42 +6,47 @@ | |
* Side Public License, v 1. | ||
*/ | ||
|
||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
import * as t from 'io-ts'; | ||
import { saved_object_attributes } from '../saved_object_attributes'; | ||
|
||
export type RuleActionGroup = t.TypeOf<typeof RuleActionGroup>; | ||
export const RuleActionGroup = t.string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reasoning behind using PascalCase for the io-ts runtime values now? In the past we've used camelCase for objects and PascalCase for types, which generally makes it simple to distinguish between types and concrete instances of that type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marshallmain This is a TypeScript feature called aliases. In this case, it's handy because it allows to write only one JSDoc comment which will be applied to both the TS type and the io-ts schema. So when you hover over them in the IDE you will see the same comment. Without that, we'd need to either duplicate the comment or leave either the TS type or the io-ts schema uncommented. Personally, I also like the fact that it's 1 import instead of 2 when you need both (e.g. in routes). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the examples of how JSDoc comments for rule attributes could look like: |
||
|
||
export type RuleActionId = t.TypeOf<typeof RuleActionId>; | ||
export const RuleActionId = t.string; | ||
|
||
export type RuleActionTypeId = t.TypeOf<typeof RuleActionTypeId>; | ||
export const RuleActionTypeId = t.string; | ||
|
||
/** | ||
* Params is an "object", since it is a type of RuleActionParams which is action templates. | ||
* @see x-pack/plugins/alerting/common/rule.ts | ||
*/ | ||
export const action_group = t.string; | ||
export const action_id = t.string; | ||
export const action_action_type_id = t.string; | ||
export const action_params = saved_object_attributes; | ||
export type RuleActionParams = t.TypeOf<typeof RuleActionParams>; | ||
export const RuleActionParams = saved_object_attributes; | ||
|
||
export const action = t.exact( | ||
export type RuleAction = t.TypeOf<typeof RuleAction>; | ||
export const RuleAction = t.exact( | ||
t.type({ | ||
group: action_group, | ||
id: action_id, | ||
action_type_id: action_action_type_id, | ||
params: action_params, | ||
group: RuleActionGroup, | ||
id: RuleActionId, | ||
action_type_id: RuleActionTypeId, | ||
params: RuleActionParams, | ||
}) | ||
); | ||
|
||
export type Action = t.TypeOf<typeof action>; | ||
export type RuleActionArray = t.TypeOf<typeof RuleActionArray>; | ||
export const RuleActionArray = t.array(RuleAction); | ||
|
||
export const actions = t.array(action); | ||
export type Actions = t.TypeOf<typeof actions>; | ||
|
||
export const actionsCamel = t.array( | ||
t.exact( | ||
t.type({ | ||
group: action_group, | ||
id: action_id, | ||
actionTypeId: action_action_type_id, | ||
params: action_params, | ||
}) | ||
) | ||
export type RuleActionCamel = t.TypeOf<typeof RuleActionCamel>; | ||
export const RuleActionCamel = t.exact( | ||
t.type({ | ||
group: RuleActionGroup, | ||
id: RuleActionId, | ||
actionTypeId: RuleActionTypeId, | ||
params: RuleActionParams, | ||
}) | ||
); | ||
export type ActionsCamel = t.TypeOf<typeof actions>; | ||
|
||
export type RuleActionArrayCamel = t.TypeOf<typeof RuleActionArrayCamel>; | ||
export const RuleActionArrayCamel = t.array(RuleActionCamel); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import * as t from 'io-ts'; | ||
import { From } from '../from'; | ||
|
||
export type RuleInterval = t.TypeOf<typeof RuleInterval>; | ||
export const RuleInterval = t.string; // we need a more specific schema | ||
|
||
export type RuleIntervalFrom = t.TypeOf<typeof RuleIntervalFrom>; | ||
export const RuleIntervalFrom = From; | ||
|
||
/** | ||
* TODO: Create a regular expression type or custom date math part type here | ||
*/ | ||
export type RuleIntervalTo = t.TypeOf<typeof RuleIntervalTo>; | ||
export const RuleIntervalTo = t.string; // we need a more specific schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to add
@elastic/security-detections-response-alerts
here and on/x-pack/plugins/security_solution/server/lib/detection_engine/rule_schema
since our area does a fair amount of work adding fields to the schema, migrating rules, etc. The rule schemas are one of the few places I think shared ownership makes sense so both teams get pinged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marshallmain I thought you would like to stop owning it, but apparently, I misunderstood you. Shared ownership makes total sense to me here. Will add.