-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Security Solutions][Detection Engine] Fixes bug with not being able to duplicate indicator matches #92565
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 Solutions][Detection Engine] Fixes bug with not being able to duplicate indicator matches #92565
Changes from all commits
3d47631
ee91f33
0884bd4
fdb9f2b
1e3d973
637362e
0e8853b
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import * as H from 'history'; | ||
| import React, { Dispatch } from 'react'; | ||
|
|
||
| import { CreateRulesSchema } from '../../../../../../common/detection_engine/schemas/request'; | ||
| import { | ||
| deleteRules, | ||
| duplicateRules, | ||
|
|
@@ -28,6 +29,7 @@ import { track, METRIC_TYPE, TELEMETRY_EVENT } from '../../../../../common/lib/t | |
|
|
||
| import * as i18n from '../translations'; | ||
| import { bucketRulesResponse } from './helpers'; | ||
| import { transformOutput } from '../../../../containers/detection_engine/rules/transforms'; | ||
|
|
||
| export const editRuleAction = (rule: Rule, history: H.History) => { | ||
| history.push(getEditRuleUrl(rule.id)); | ||
|
|
@@ -41,7 +43,11 @@ export const duplicateRulesAction = async ( | |
| ) => { | ||
| try { | ||
| dispatch({ type: 'loadingRuleIds', ids: ruleIds, actionType: 'duplicate' }); | ||
| const response = await duplicateRules({ rules }); | ||
| const response = await duplicateRules({ | ||
| // We cast this back and forth here as the front end types are not really the right io-ts ones | ||
| // and the two types conflict with each other. | ||
| rules: rules.map((rule) => transformOutput(rule as CreateRulesSchema) as Rule), | ||
|
Contributor
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 ran into the same thing with exceptions. I ended up creating two functions to deal with the two type scenarios, but thought about doing the export const transformOutput = (
exceptionItem: UpdateExceptionListItemSchema | ExceptionListItemSchema
): UpdateExceptionListItemSchema | ExceptionListItemSchema =>
flow(removeIdFromExceptionItemsEntries)(exceptionItem);
export const transformNewItemOutput = (
exceptionItem: CreateExceptionListItemSchema
): CreateExceptionListItemSchema => flow(removeIdFromExceptionItemsEntries)(exceptionItem);
Contributor
Author
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. Thanks for letting me know |
||
| }); | ||
| const { errors } = bucketRulesResponse(response); | ||
| if (errors.length > 0) { | ||
| displayErrorToast( | ||
|
|
||
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.
🎉 nice, this always feels great to add more tests here.