--- policy: /ce/ca/azure/key-vault/automatic-key-rotation logic: /ce/ca/azure/key-vault/automatic-key-rotation/prod.logic.yaml executionTime: 2026-06-06T12:03:35.970044089Z generationMs: 39 executionMs: 1371 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10__disappearanceTime__c) actual: isDisappeared(CA10__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__lifetimeActions__c').isEmpty() actual: extract('CA10__lifetimeActions__c').isEmpty() runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: not(extract('CA10__lifetimeActions__c').contains('Rotate')) actual: not(extract('CA10__lifetimeActions__c').contains('Rotate')) runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: extract('CA10__lifetimeActions__c').contains('Rotate') actual: extract('CA10__lifetimeActions__c').contains('Rotate') runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: extract('CA10__lifetimeActions__c').contains('Rotate') actual: extract('CA10__lifetimeActions__c').contains('Rotate') runtimeError: {} - id: test6 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__enabledStatus__c') != 'Enabled' actual: extract('CA10__enabledStatus__c') != 'Enabled' runtimeError: {} - id: test7 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10__created__c').beyondLastDays(730) actual: extract('CA10__created__c').beyondLastDays(730) runtimeError: {} usedFiles: - path: /ce/ca/azure/key-vault/automatic-key-rotation/policy.yaml md5Hash: 499F8E081E8168E925C10AC3C7224C3D content: | --- names: full: Azure Key Vault Automatic Key Rotation is not enabled contextual: Automatic Key Rotation is not enabled description: "Automatic Key Rotation is available in Public Preview. The currently\ \ supported applications are Key Vault, Managed Disks, and Storage accounts accessing\ \ keys within Key Vault. The number of supported applications will incrementally\ \ increased." type: COMPLIANCE_POLICY categories: - SECURITY frameworkMappings: - "/frameworks/cis-azure-v6.0.0/08/03/09" - /frameworks/cloudaware/secret-and-certificate-governance/expiration-management - path: /ce/ca/azure/key-vault/automatic-key-rotation/prod.logic.yaml md5Hash: 475C9FC729D44D6B7ECBD4ABDF4466D3 content: | --- inputType: "CA10__CaAzureKeyVaultKey__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAzureKeyVaultKey__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "The key is not enabled." check: NOT_EQUAL: left: EXTRACT: "CA10__enabledStatus__c" right: TEXT: "Enabled" - status: "INCOMPLIANT" currentStateMessage: "The key rotation policy is not configured." remediationMessage: "Configure automated key rotation." check: IS_EMPTY: arg: EXTRACT: "CA10__lifetimeActions__c" - status: "INCOMPLIANT" currentStateMessage: "The key rotation policy is not configured." remediationMessage: "Configure automated key rotation." check: NOT: arg: CONTAINS: arg: EXTRACT: "CA10__lifetimeActions__c" search: TEXT: "Rotate" - status: "INCOMPLIANT" currentStateMessage: "This key has not been rotated in over two years." remediationMessage: "Rotate the key and ensure automatic key rotation is scheduled at least every two years." check: IS_BEYOND_LAST_DAYS: offsetDays: 730 arg: EXTRACT: "CA10__created__c" - status: "COMPLIANT" currentStateMessage: "The key rotation policy is configured." check: CONTAINS: arg: EXTRACT: "CA10__lifetimeActions__c" search: TEXT: "Rotate" otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected values in the fields." - path: /ce/ca/azure/key-vault/automatic-key-rotation/test-data.json md5Hash: 2D329277EA0F49B92D84C81248BD085C content: | [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2024-11-12T19:14:41Z", "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__lifetimeActions__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "not(extract('CA10__lifetimeActions__c').contains('Rotate'))", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "conditionText": "extract('CA10__lifetimeActions__c').contains('Rotate')", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "conditionText": "extract('CA10__lifetimeActions__c').contains('Rotate')", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}\n{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__enabledStatus__c') != 'Enabled'", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test6", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Disabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test-key-vault" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "extract('CA10__created__c').beyondLastDays(730)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test7", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}\n{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c": "2022-11-02T19:14:41Z", "CA10__keyVault__c": "test-key-vault" } ] - path: /types/CA10__CaAzureKeyVaultKey__c/object.extracts.yaml md5Hash: 3E108EC98943E81178B2BBCAD0272267 content: "---\nextracts:\n# Values: Enabled, Disabled. Not Nullable. Can't have\ \ no access, retrieved via Microsoft.KeyVault/keys\n - name: \"CA10__enabledStatus__c\"\ \n value: \n FIELD:\n path: \"CA10__enabledStatus__c\"\n \ \ undeterminedIf:\n isEmpty: \"Corrupted data. Key State cannot\ \ be empty.\"\n# Nullable. Can't have no access, retrieved via Microsoft.KeyVault/keys\n\ \ - name: \"CA10__expirationDate__c\"\n value: \n FIELD:\n path:\ \ \"CA10__expirationDate__c\"\n# Nullable\n - name: \"CA10__lifetimeActions__c\"\ \n value: \n FIELD:\n path: \"CA10__lifetimeActions__c\"\n \ \ # undeterminedIf:\n # noAccessDelegate:\n # path:\ \ \"CA10__lifetimeActions__c\"\n # currentStateMessage: \"Unable\ \ to determine Key Rotation Policy. Possible permission issue with keys/getrotationpolicy\"\ \n# Creation time in UTC.\n - name: \"CA10__created__c\"\n value:\n \ \ FIELD:\n path: \"CA10__created__c\"" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__lifetimeActions__c').isEmpty()", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "not(extract('CA10__lifetimeActions__c').contains('Rotate'))", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "extract('CA10__lifetimeActions__c').contains('Rotate')", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "extract('CA10__lifetimeActions__c').contains('Rotate')", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__enabledStatus__c') != 'Enabled'", "runtimeError" : null } }, { "Id" : "test7", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('CA10__created__c').beyondLastDays(730)", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureKeyVaultKey__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__disappearanceTime__c" : new Date("2024-11-12T19:14:41Z"), "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}\n{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Disabled", "CA10__lifetimeActions__c" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "Id" : "test6" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "CA10__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}\n{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"NOTIFY\"}}", "CA10__created__c" : new Date("2022-11-02T19:14:41Z"), "Id" : "test7" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureKeyVaultKey__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__enabledStatus__c STRING, CA10__lifetimeActions__c STRING, CA10__created__c TIMESTAMP, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var todayMinus730Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-730 * 86400000); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From Azure [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c); if (obj.CA10__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function fieldChecked4() { if (TextLib.isEmpty(obj.CA10__enabledStatus__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__enabledStatus__c.isEmpty()", currentStateMessage: "Corrupted data. Key State cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__enabledStatus__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Enabled Status [obj.CA10__enabledStatus__c]: ' + obj.CA10__enabledStatus__c); try { if (TextLib.notEqual(extract3.call(extract3), 'Enabled')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__enabledStatus__c') != 'Enabled'", currentStateMessage: "The key is not enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__lifetimeActions__c; } return this.out; }; references1.push('Lifetime Actions [obj.CA10__lifetimeActions__c]: ' + obj.CA10__lifetimeActions__c); if (TextLib.isEmpty(extract6.call(extract6))) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__lifetimeActions__c').isEmpty()", currentStateMessage: "The key rotation policy is not configured.", currentStateReferences: references1.join('\n'), remediation: "Configure automated key rotation.", runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract9() { if (!this.out) { this.out = obj.CA10__lifetimeActions__c; } return this.out; }; if (!TextLib.contains(extract9.call(extract9), 'Rotate')) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "not(extract('CA10__lifetimeActions__c').contains('Rotate'))", currentStateMessage: "The key rotation policy is not configured.", currentStateReferences: references1.join('\n'), remediation: "Configure automated key rotation.", runtimeError: null}; } // condition[4], conditionIndex:[400..499] function extract12() { if (!this.out) { this.out = obj.CA10__created__c; } return this.out; }; references1.push('Created [obj.CA10__created__c]: ' + obj.CA10__created__c); if (extract12.call(extract12) != null && extract12.call(extract12).getTime() < todayMinus730Day) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__created__c').beyondLastDays(730)", currentStateMessage: "This key has not been rotated in over two years.", currentStateReferences: references1.join('\n'), remediation: "Rotate the key and ensure automatic key rotation is scheduled at least every two years.", runtimeError: null}; } // condition[5], conditionIndex:[500..599] function extract16() { if (!this.out) { this.out = obj.CA10__lifetimeActions__c; } return this.out; }; if (TextLib.contains(extract16.call(extract16), 'Rotate')) { return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__lifetimeActions__c').contains('Rotate')", currentStateMessage: "The key rotation policy is configured.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__enabledStatus__c AS CA10__enabledStatus__c, sObject.CA10__lifetimeActions__c AS CA10__lifetimeActions__c, sObject.CA10__created__c AS CA10__created__c, sObject.Id AS Id, process_CA10__CaAzureKeyVaultKey__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__enabledStatus__c AS CA10__enabledStatus__c, sObject.CA10__lifetimeActions__c AS CA10__lifetimeActions__c, sObject.CA10__created__c AS CA10__created__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureKeyVaultKey__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;