-
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] [Exceptions] Fix Exception Auto-populate from Alert actions #159908
Changes from 29 commits
e123658
d618d0a
702f330
8cf53cb
ee9d078
9156746
115eff7
a88527c
033842c
94283e4
a0cca84
d6da91a
78aedc3
4daff25
9519b5b
e78b92a
ace134a
58f350a
aaf86d3
54e0588
4932445
20aa5bb
0bc6b56
87829b1
0aa23bb
d8c5c32
20a7a46
7f11193
24ae54f
4375245
86f8b19
9c684cf
21c404c
d0780b0
471a6ce
2e280fd
1b28f82
1382430
94b4d88
f676400
0468b11
76d41f9
ab3b222
823fbd9
3e8a70d
37a9f68
cbaf0ec
e5cae86
7843461
046574c
f147868
6d0c1d4
eab421e
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* 2.0. | ||
*/ | ||
|
||
import React, { useCallback, useEffect, useMemo, useReducer } from 'react'; | ||
import React, { useCallback, useEffect, useMemo, useReducer, useState } from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
import { HttpStart } from '@kbn/core/public'; | ||
|
@@ -34,6 +34,7 @@ import { | |
} from '@kbn/securitysolution-list-utils'; | ||
import { DataViewBase } from '@kbn/es-query'; | ||
import type { AutocompleteStart } from '@kbn/unified-search-plugin/public'; | ||
import deepEqual from 'fast-deep-equal'; | ||
|
||
import { AndOrBadge } from '../and_or_badge'; | ||
|
||
|
@@ -131,6 +132,9 @@ export const ExceptionBuilderComponent = ({ | |
disableNested: isNestedDisabled, | ||
disableOr: isOrDisabled, | ||
}); | ||
const [currentExceptionListItems, setCurrentExceptionListItems] = useState< | ||
ExceptionsBuilderExceptionItem[] | ||
>([]); | ||
|
||
const { | ||
addNested, | ||
|
@@ -395,11 +399,14 @@ export const ExceptionBuilderComponent = ({ | |
}, [exceptions, handleAddNewExceptionItem]); | ||
|
||
useEffect(() => { | ||
if (exceptionListItems.length > 0) { | ||
if ( | ||
exceptionListItems.length > 0 && | ||
!deepEqual(exceptionListItems, currentExceptionListItems) | ||
) { | ||
setCurrentExceptionListItems(exceptionListItems); | ||
setUpdateExceptions(exceptionListItems); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
}, [currentExceptionListItems, exceptionListItems, setUpdateExceptions]); | ||
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. Noticed an issue, when added new exception item and then typed name. Screen.Recording.2023-06-21.at.12.46.07.movThere 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. Indeed, a similar issue was identified by Yara. Upon further investigation, I discovered that modifying the entries of the Exception and subsequently changing another field causes a reset to the initial entries. This behavior occurs because altering the entries (conditions) does not trigger a corresponding change in the exceptionListItems. |
||
|
||
return ( | ||
<EuiFlexGroup gutterSize="s" direction="column" data-test-subj="exceptionsBuilderWrapper"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,6 +419,7 @@ export const EventFiltersForm: React.FC<ArtifactFormComponentProps & { allowSele | |
comments: exception?.comments ?? [], | ||
os_types: exception?.os_types ?? [OperatingSystem.WINDOWS], | ||
tags: exception?.tags ?? [], | ||
meta: exception.meta, | ||
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. Is this change related to the bug fix or something else you found? 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. |
||
} | ||
: exception; | ||
const hasValidConditions = | ||
|
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.
maybe using
useRef
would be more preferable here as it would not trigger another re-renderThere 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 tried it but it didn't work, and I am not sure if it will as the previous reason :(