-
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
7 changed files
with
89 additions
and
27 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
34 changes: 34 additions & 0 deletions
34
...s/cloud_security_posture/common/runtime_mappings/get_safe_posture_type_runtime_mapping.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,34 @@ | ||
/* | ||
* 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 { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
/** | ||
* Creates the `safe_posture_type` runtime field with the value of either | ||
* `kspm` or `cspm` based on the value of `rule.benchmark.posture_type` | ||
*/ | ||
export const getSafePostureTypeRuntimeMapping = (): MappingRuntimeFields => ({ | ||
safe_posture_type: { | ||
type: 'keyword', | ||
script: { | ||
source: ` | ||
if (!doc.containsKey('rule.benchmark.posture_type')) | ||
{ | ||
def safe_posture_type = 'kspm'; | ||
emit(safe_posture_type); | ||
return | ||
} | ||
else | ||
{ | ||
def safe_posture_type = doc["rule.benchmark.posture_type"].value; | ||
emit(safe_posture_type); | ||
return | ||
} | ||
`, | ||
}, | ||
}, | ||
}); |
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