mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Detection Engine] add validation for new terms history window (#191038)](https://github.com/elastic/kibana/pull/191038) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Yara Tercero","email":"yctercero@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-04T14:47:32Z","message":"[Detection Engine] add validation for new terms history window (#191038)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/kibana/issues/164525","sha":"6001786d04388f5f79cea74b674e510fc7a60d3a","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:prev-minor","backport:prev-major","Team:Detection Engine","v8.16.0"],"title":"[Detection Engine] add validation for new terms history window","number":191038,"url":"https://github.com/elastic/kibana/pull/191038","mergeCommit":{"message":"[Detection Engine] add validation for new terms history window (#191038)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/kibana/issues/164525","sha":"6001786d04388f5f79cea74b674e510fc7a60d3a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191038","number":191038,"mergeCommit":{"message":"[Detection Engine] add validation for new terms history window (#191038)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/kibana/issues/164525","sha":"6001786d04388f5f79cea74b674e510fc7a60d3a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Yara Tercero <yctercero@users.noreply.github.com>
This commit is contained in:
parent
625742cf1b
commit
9920506bc4
1 changed files with 29 additions and 0 deletions
|
@ -643,6 +643,35 @@ export const schema: FormSchema<DefineStepRule> = {
|
|||
defaultMessage: "New terms rules only alert if terms don't appear in historical data.",
|
||||
}
|
||||
),
|
||||
validations: [
|
||||
{
|
||||
validator: (
|
||||
...args: Parameters<ValidationFunc>
|
||||
): ReturnType<ValidationFunc<{}, ERROR_CODE>> | undefined => {
|
||||
const [{ path, formData }] = args;
|
||||
const needsValidation = isNewTermsRule(formData.ruleType);
|
||||
|
||||
if (!needsValidation) {
|
||||
return;
|
||||
}
|
||||
|
||||
const filterTimeVal = formData.historyWindowSize.match(/\d+/g);
|
||||
|
||||
if (filterTimeVal <= 0) {
|
||||
return {
|
||||
code: 'ERR_MIN_LENGTH',
|
||||
path,
|
||||
message: i18n.translate(
|
||||
'xpack.securitySolution.detectionEngine.validations.stepDefineRule.historyWindowSize.errMin',
|
||||
{
|
||||
defaultMessage: 'History window size must be greater than 0.',
|
||||
}
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
groupByFields: {
|
||||
type: FIELD_TYPES.COMBO_BOX,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue