-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
81 deletions.
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
46 changes: 46 additions & 0 deletions
46
...reation/components/threat_match_mapping_edit/validators/threat_match_mapping_validator.ts
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
containsInvalidItems, | ||
singleEntryThreat, | ||
} from '../../../../../common/components/threat_match/helpers'; | ||
import type { FormData, ValidationFunc } from '../../../../../shared_imports'; | ||
import type { ThreatMapEntries } from '../../../../../common/components/threat_match/types'; | ||
|
||
export const threatMatchMappingValidator: ValidationFunc<FormData, string, ThreatMapEntries[]> = ( | ||
...args | ||
) => { | ||
const [{ path, value }] = args; | ||
|
||
if (singleEntryThreat(value)) { | ||
return { | ||
code: 'ERR_FIELD_MISSING', | ||
path, | ||
message: i18n.translate( | ||
'xpack.securitySolution.detectionEngine.createRule.stepDefineRule.customThreatQueryFieldRequiredError', | ||
{ | ||
defaultMessage: 'At least one indicator match is required.', | ||
} | ||
), | ||
}; | ||
} | ||
|
||
if (containsInvalidItems(value)) { | ||
return { | ||
code: 'ERR_FIELD_MISSING', | ||
path, | ||
message: i18n.translate( | ||
'xpack.securitySolution.detectionEngine.createRule.stepDefineRule.customThreatQueryFieldRequiredEmptyError', | ||
{ | ||
defaultMessage: 'All matches require both a field and threat index field.', | ||
} | ||
), | ||
}; | ||
} | ||
}; |
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
27 changes: 27 additions & 0 deletions
27
...on/components/threat_match_query_edit/validators/threat_match_query_required_validator.ts
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isEmpty } from 'lodash'; | ||
import type { FieldValueQueryBar } from '../../../../rule_creation_ui/components/query_bar'; | ||
import type { FormData, ValidationFunc } from '../../../../../shared_imports'; | ||
import * as i18n from './translations'; | ||
|
||
export const threatMatchQueryRequiredValidator: ValidationFunc< | ||
FormData, | ||
string, | ||
FieldValueQueryBar | ||
> = (...args) => { | ||
const [{ path, value }] = args; | ||
|
||
if (isEmpty(value.query.query as string) && isEmpty(value.filters)) { | ||
return { | ||
code: 'ERR_FIELD_MISSING', | ||
path, | ||
message: i18n.THREAT_MATCH_QUERY_REQUIRED_ERROR, | ||
}; | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
...ection_engine/rule_creation/components/threat_match_query_edit/validators/translations.ts
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const THREAT_MATCH_QUERY_REQUIRED_ERROR = i18n.translate( | ||
'xpack.securitySolution.detectionEngine.createRule.stepDefineRule.threatMatchQueryBar.requiredError', | ||
{ | ||
defaultMessage: 'A custom query is required.', | ||
} | ||
); |
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
50 changes: 0 additions & 50 deletions
50
...ion/public/detection_engine/rule_creation_ui/validators/threat_match_mapping_validator.ts
This file was deleted.
Oops, something went wrong.
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