-
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] [Detections] Adds support for system actions (and cases action) to detection rules #183937
Changes from 71 commits
2cfed78
a2bb5ba
7082de6
5e137b3
3600f32
7140b48
33cebd7
2a91ec0
4d73f76
2ef4df5
62b6ec8
67e406b
5e61574
7c72634
7f7a4ba
098194d
fdce619
8d75153
0599aa2
3c8a799
1d02e49
0b121bd
b697826
43a779f
ed4b400
033fe41
b3f5498
caa8702
73202f0
6a6f397
6e16ab0
1b35aeb
9eeb2e6
56c8b03
06efd06
c250336
dfb239e
1fbafc3
0e42109
7254095
77e351b
0e4f045
683504b
57a4a77
e36a295
ed6f8c7
69ba82b
475915e
3b8e874
bf2d39b
9e8eda5
9e67428
5827e1e
ee5ae09
cc33a01
dbf4db2
991e10a
374309c
da2217f
fee7dbb
bd7c725
604a755
bc9efa2
09716a2
f2e919d
8de96fa
19748e3
851e19a
3848196
8d517b4
739a6a3
3903f00
872477e
256b6ea
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 |
---|---|---|
|
@@ -9,10 +9,17 @@ import React from 'react'; | |
import { EuiToolTip, EuiText, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui'; | ||
import type { ActionType, AsApiContract } from '@kbn/actions-plugin/common'; | ||
import type { ActionResult } from '@kbn/actions-plugin/server'; | ||
import type { RuleActionFrequency, RuleAction } from '@kbn/alerting-plugin/common'; | ||
import type { | ||
RuleActionFrequency, | ||
RuleAction, | ||
RuleSystemAction, | ||
} from '@kbn/alerting-plugin/common'; | ||
import type { ActionTypeRegistryContract } from '@kbn/triggers-actions-ui-plugin/public'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { getTimeTypeValue } from '../../../rule_creation_ui/pages/rule_creation/helpers'; | ||
import { | ||
getTimeTypeValue, | ||
isRuleAction as getIsRuleAction, | ||
} from '../../../rule_creation_ui/pages/rule_creation/helpers'; | ||
import * as i18n from './translations'; | ||
|
||
const DescriptionLine = ({ children }: { children: React.ReactNode }) => ( | ||
|
@@ -79,7 +86,7 @@ export const FrequencyDescription: React.FC<{ frequency?: RuleActionFrequency }> | |
}; | ||
|
||
interface NotificationActionProps { | ||
action: RuleAction; | ||
action: RuleAction | RuleSystemAction; | ||
connectorTypes: ActionType[]; | ||
connectors: Array<AsApiContract<ActionResult>>; | ||
actionTypeRegistry: ActionTypeRegistryContract; | ||
|
@@ -91,13 +98,23 @@ export function NotificationAction({ | |
connectors, | ||
actionTypeRegistry, | ||
}: NotificationActionProps) { | ||
const isRuleAction = getIsRuleAction(action, actionTypeRegistry); | ||
const connectorType = connectorTypes.find(({ id }) => id === action.actionTypeId); | ||
const connectorTypeName = connectorType?.name ?? ''; | ||
const registeredAction = actionTypeRegistry.get(action.actionTypeId); | ||
|
||
const connector = connectors.find(({ id }) => id === action.id); | ||
const connectorName = connector?.name ?? ''; | ||
/* | ||
since there is no "connector" for system actions, | ||
we need to determine the title based off the action | ||
properties in order to render helpful text on the | ||
rule details page. | ||
*/ | ||
const connectorTypeName = isRuleAction | ||
? connectorType?.name ?? '' | ||
: registeredAction.actionTypeTitle ?? ''; | ||
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. since there is no "connector" for system actions, we need to determine the title based off the action properties in order to render helpful text on the rule details page. 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 we add this as comment here? Or even better, extract the logic out to a function and explain it there. |
||
const iconType = registeredAction?.iconClass ?? 'apps'; | ||
|
||
const iconType = actionTypeRegistry.get(action.actionTypeId)?.iconClass ?? 'apps'; | ||
const connector = connectors.find(({ id }) => id === action.id); | ||
const connectorName = (isRuleAction ? connector?.name : registeredAction.actionTypeTitle) ?? ''; | ||
|
||
return ( | ||
<EuiFlexItem> | ||
|
@@ -114,7 +131,7 @@ export function NotificationAction({ | |
<EuiFlexItem grow={false}> | ||
<EuiIcon size="s" type="bell" color="subdued" /> | ||
</EuiFlexItem> | ||
<FrequencyDescription frequency={action.frequency} /> | ||
{isRuleAction && <FrequencyDescription frequency={action.frequency} />} | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
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.
For any questions on this, I pulled this from the system actions RFC:
Ref: https://docs.google.com/document/d/1mYStNLxrafnyxR6v_uB4ONw_iFHTg1pmE3EAQYgKFSY/edit?pli=1