[Cloud Posture] add posture_type field to rule saved object (#149796)

This commit is contained in:
Or Ouziel 2023-01-31 15:02:26 +02:00 committed by GitHub
parent 06179742f7
commit a63404c48e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -35,6 +35,7 @@ export const cspRuleTemplateMetadataSchemaV870 = rt.object({
id: rt.string(),
version: rt.string(),
rule_number: rt.maybe(rt.string()),
posture_type: rt.maybe(rt.string()),
}),
default_value: rt.maybe(rt.string()),
description: rt.string(),

View file

@ -43,9 +43,19 @@ function migrateCspRuleTemplatesToV870(
): SavedObjectUnsanitizedDoc<CspRuleTemplateV870> {
// Keeps only metadata, deprecated state
const { muted, enabled, ...attributes } = doc.attributes;
return {
...doc,
attributes,
attributes: {
metadata: {
...attributes.metadata,
benchmark: {
...attributes.metadata.benchmark,
// CSPM introduced in 8.7, so we can assume all docs from 8.4.0 are KSPM
posture_type: 'kspm',
},
},
},
};
}