-
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] Incorporates EQL options in EQL query validation on both Rule Creation and Timeline #178468
Merged
rylnd
merged 25 commits into
elastic:main
from
rylnd:rylnd/bugfix/eql_rule_timestamp_override
Mar 19, 2024
Merged
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
02a0c50
Document current EQL rule behavior with timestamp fields
rylnd 7838039
Add similar tests for data with @timestamp
rylnd 413ed8c
Add tests validating that our EQL search strategy respects certain pa…
rylnd cedecbb
EQL validation function accepts EQL options as a parameter
rylnd b2fa55c
Makes eqlOptions a used field on our Define Step form
rylnd 3dc18c1
Ensure that changes to EQL options cause the EQL query to be revalidated
rylnd 4105e69
Add a test validating how onOptionsChange is called
rylnd 39d005b
Remove unused interface
rylnd daf87a4
Add an eqlOptions form field to the timeline EQL form
rylnd 10a47fd
Remove default values from timeline EQL options
rylnd 2676ada
Merge branch 'main' into rylnd/bugfix/eql_rule_timestamp_override
rylnd bbd6a8d
Rename new archive to be more accurate
rylnd fa03d22
Rename archive, again
rylnd b2aec76
More accurate cypress selector
rylnd 0d8ad8b
Add a cypress test around the EQL option/validation functionality
rylnd 3a9d040
Prevent component props from being passed as DOM attributes
rylnd 532dd15
Revert "Remove default values from timeline EQL options"
rylnd 5b18854
Guard against using timeline default of '' for tibreakerField
rylnd e837f19
validateEql options parameter is optional
rylnd f6739dd
Merge branch 'main' into rylnd/bugfix/eql_rule_timestamp_override
rylnd c970f74
Merge branch 'main' into rylnd/bugfix/eql_rule_timestamp_override
rylnd 7ac409a
Remove duplicated es_archive thanks to new cypress task functionality
rylnd 92a2bd2
Merge branch 'main' into rylnd/bugfix/eql_rule_timestamp_override
rylnd 6767182
Fix type incompatibility with EQL search strategy
rylnd f3e55d5
Fix test descriptions to align with test bodies
rylnd 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -59,7 +59,14 @@ import { StepContentWrapper } from '../../../rule_creation/components/step_conte | |
import { ThresholdInput } from '../threshold_input'; | ||
import { SuppressionInfoIcon } from '../suppression_info_icon'; | ||
import { EsqlInfoIcon } from '../../../rule_creation/components/esql_info_icon'; | ||
import { Field, Form, getUseField, UseField, UseMultiFields } from '../../../../shared_imports'; | ||
import { | ||
Field, | ||
Form, | ||
getUseField, | ||
HiddenField, | ||
UseField, | ||
UseMultiFields, | ||
} from '../../../../shared_imports'; | ||
import type { FormHook } from '../../../../shared_imports'; | ||
import { schema } from './schema'; | ||
import { getTermsAggregationFields } from './utils'; | ||
|
@@ -768,14 +775,20 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({ | |
onOpenTimeline, | ||
] | ||
); | ||
|
||
const onOptionsChange = useCallback( | ||
(field: FieldsEqlOptions, value: string | undefined) => { | ||
setOptionsSelected((prevOptions) => ({ | ||
...prevOptions, | ||
[field]: value, | ||
})); | ||
setOptionsSelected((prevOptions) => { | ||
const newOptions = { | ||
...prevOptions, | ||
[field]: value, | ||
}; | ||
|
||
setFieldValue('eqlOptions', newOptions); | ||
return newOptions; | ||
}); | ||
}, | ||
[setOptionsSelected] | ||
[setFieldValue, setOptionsSelected] | ||
); | ||
|
||
const optionsData = useMemo( | ||
|
@@ -814,17 +827,16 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({ | |
<> | ||
<StepContentWrapper addPadding={!isUpdateView}> | ||
<Form form={form} data-test-subj="stepDefineRule"> | ||
<StyledVisibleContainer isVisible={false}> | ||
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. This is wholly unrelated to this PR, but react was throwing dev warnings on this page and I couldn't help but fix it. See 3a9d040 for more details. |
||
<UseField | ||
path="dataSourceType" | ||
componentProps={{ | ||
euiFieldProps: { | ||
fullWidth: true, | ||
placeholder: '', | ||
}, | ||
}} | ||
/> | ||
</StyledVisibleContainer> | ||
<UseField | ||
path="dataSourceType" | ||
component={HiddenField} | ||
componentProps={{ | ||
euiFieldProps: { | ||
fullWidth: true, | ||
placeholder: '', | ||
}, | ||
}} | ||
/> | ||
<UseField | ||
path="ruleType" | ||
component={SelectRuleType} | ||
|
@@ -838,29 +850,31 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({ | |
</StyledVisibleContainer> | ||
<EuiSpacer size="s" /> | ||
{isEqlRule(ruleType) ? ( | ||
<UseField | ||
key="EqlQueryBar" | ||
path="queryBar" | ||
component={EqlQueryBar} | ||
componentProps={{ | ||
optionsData, | ||
optionsSelected, | ||
isSizeOptionDisabled: true, | ||
onOptionsChange, | ||
onValidityChange: setIsQueryBarValid, | ||
idAria: 'detectionEngineStepDefineRuleEqlQueryBar', | ||
isDisabled: isLoading, | ||
isLoading: isIndexPatternLoading, | ||
indexPattern, | ||
showFilterBar: true, | ||
// isLoading: indexPatternsLoading, | ||
dataTestSubj: 'detectionEngineStepDefineRuleEqlQueryBar', | ||
}} | ||
config={{ | ||
...schema.queryBar, | ||
label: i18n.EQL_QUERY_BAR_LABEL, | ||
}} | ||
/> | ||
<> | ||
<UseField | ||
key="EqlQueryBar" | ||
path="queryBar" | ||
component={EqlQueryBar} | ||
componentProps={{ | ||
optionsData, | ||
optionsSelected, | ||
isSizeOptionDisabled: true, | ||
onOptionsChange, | ||
onValidityChange: setIsQueryBarValid, | ||
idAria: 'detectionEngineStepDefineRuleEqlQueryBar', | ||
isDisabled: isLoading, | ||
isLoading: isIndexPatternLoading, | ||
indexPattern, | ||
showFilterBar: true, | ||
dataTestSubj: 'detectionEngineStepDefineRuleEqlQueryBar', | ||
}} | ||
config={{ | ||
...schema.queryBar, | ||
label: i18n.EQL_QUERY_BAR_LABEL, | ||
}} | ||
/> | ||
<UseField path="eqlOptions" component={HiddenField} /> | ||
</> | ||
) : isEsqlRule(ruleType) ? ( | ||
EsqlQueryBarMemo | ||
) : ( | ||
|
This file contains 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 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 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
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.
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.
why this error happens here?
I don't see any top level await introduced here
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.
These
@ts-expect-error
s were due to an incompatibility between the actual EQL endpoint, and the types in the search strategy. I managed to extend the type to make this all work without the need for the@ts-expect-error
: 6767182.I'm not sure what you were referring to with the
await
comment, though.