--- policy: /ce/ca/azure/key-vault/automatic-key-rotation logic: /ce/ca/azure/key-vault/automatic-key-rotation/prod.logic.yaml executionTime: 2026-02-10T22:33:28.365109064Z generationMs: 89 executionMs: 992 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: 199 actual: 199 conditionText: expected: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) actual: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) actual: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT) actual: CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT) runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT) actual: CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT) runtimeError: {} - id: test6 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test7 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test8 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test9 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) actual: CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT) runtimeError: {} usedFiles: - path: /ce/ca/azure/key-vault/automatic-key-rotation/policy.yaml md5Hash: 33E772D83E1959C51FE80F8FC4218314 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: - RELIABILITY frameworkMappings: - "/frameworks/cis-azure-v5.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: 8CABD0C86BC863D3DECC359E54B58CC1 content: "---\ninputType: \"CA10__CaAzureKeyVault__c\"\ntestData:\n - file: \"\ test-data.json\"\nconditions:\n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"The key rotation policy is not configured.\"\n remediationMessage: \"\ Configure automated key rotation.\"\n check:\n RELATED_LIST_HAS:\n \ \ status: \"INCOMPLIANT\"\n relationshipName: \"CA10__Azure_Key_Vault_Keys__r\"\ \n - status: \"COMPLIANT\"\n currentStateMessage: \"The key rotation policy\ \ is configured.\"\n check:\n RELATED_LIST_HAS:\n status: \"\ COMPLIANT\"\n relationshipName: \"CA10__Azure_Key_Vault_Keys__r\" \ \ \n - status: \"UNDETERMINED\"\n currentStateMessage: \"Unexpected\ \ values in the field.\"\n check:\n RELATED_LIST_HAS:\n status:\ \ \"UNDETERMINED\"\n relationshipName: \"CA10__Azure_Key_Vault_Keys__r\"\ \ \notherwise:\n status: \"COMPLIANT\"\n currentStateMessage: \"The\ \ Key Vault does not have active keys, or Cloudaware has insufficient access\ \ to list keys.\"\nrelatedLists:\n - relationshipName: \"CA10__Azure_Key_Vault_Keys__r\"\ \n importExtracts:\n - file: \"/types/CA10__CaAzureKeyVaultKey__c/object.extracts.yaml\"\ \n conditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage:\ \ \"The key is not enabled.\"\n check:\n NOT_EQUAL:\n \ \ left:\n EXTRACT: \"CA10__enabledStatus__c\"\n \ \ right:\n TEXT: \"Enabled\"\n - status: \"INCOMPLIANT\"\n\ \ currentStateMessage: \"The key rotation policy is not configured.\"\ \n remediationMessage: \"Configure automated key rotation.\"\n \ \ check:\n IS_EMPTY:\n arg:\n EXTRACT: \"\ CA10__lifetimeActions__c\" \n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"The key rotation policy is not configured.\"\n remediationMessage:\ \ \"Configure automated key rotation.\"\n check:\n NOT:\n \ \ arg:\n CONTAINS:\n arg:\n \ \ EXTRACT: \"CA10__lifetimeActions__c\"\n search:\n \ \ TEXT: \"Rotate\"\n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"Key rotation is enabled, but this key has not been rotated in over two years.\"\ \n remediationMessage: \"Set the rotation interval to under two years\ \ to align with best practices.\"\n check:\n NOT:\n \ \ arg:\n IS_WITHIN_LAST_DAYS:\n offsetDays: 730\n\ \ arg:\n EXTRACT: \"CA10__created__c\"\n \ \ - status: \"COMPLIANT\"\n currentStateMessage: \"The key rotation\ \ policy is configured.\"\n check:\n CONTAINS:\n \ \ arg:\n EXTRACT: \"CA10__lifetimeActions__c\"\n search:\n\ \ TEXT: \"Rotate\"\n otherwise:\n status: \"UNDETERMINED\"\ \n currentStateMessage: \"Unexpected values in the field.\"\n" - path: /ce/ca/azure/key-vault/automatic-key-rotation/test-data.json md5Hash: E64F1513F75300AAFDA81C6D27FDB75B 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__Azure_Key_Vault_Keys__r": [ { "Id": "test1_1", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test1" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test2_1", "CA10__disappearanceTime__c": null, "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test2" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test3_1", "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": "test3" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test4_1", "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": "test4" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test5_1", "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": "test5" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test6", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test7", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test7_1", "CA10__disappearanceTime__c": "2024-11-12T19:14:41Z", "CA10__enabledStatus__c": "Enabled", "CA10__lifetimeActions__c": "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c": "2024-03-27T14:50:58Z", "CA10__keyVault__c": "test7" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test8", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test8_1", "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": "test8" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-11-12T19:14:41Z" }, "Id": "test9", "CA10__disappearanceTime__c": null, "CA10__Azure_Key_Vault_Keys__r": [ { "Id": "test9_1", "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": "test9" } ] } ] - 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" : "199", "conditionText" : "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test7", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test8", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test9", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureKeyVault__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"), "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test6" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test7" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test8" }, { "context" : { "snapshotTime" : new Date("2024-11-12T19:14:41Z") }, "Id" : "test9" } ]; """; 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__enabledStatus__c" : "Enabled", "CA10__lifetimeActions__c" : "", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "CA10__keyVault__c" : "test1", "Id" : "test1_1" }, { "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"), "CA10__keyVault__c" : "test2", "Id" : "test2_1" }, { "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"), "CA10__keyVault__c" : "test3", "Id" : "test3_1" }, { "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"), "CA10__keyVault__c" : "test4", "Id" : "test4_1" }, { "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"), "CA10__keyVault__c" : "test5", "Id" : "test5_1" }, { "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" : "{\"trigger\":{\"timeBeforeExpiry\":\"P30D\"},\"action\":{\"type\":\"ROTATE\"}}", "CA10__created__c" : new Date("2024-03-27T14:50:58Z"), "CA10__keyVault__c" : "test7", "Id" : "test7_1" }, { "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"), "CA10__keyVault__c" : "test8", "Id" : "test8_1" }, { "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"), "CA10__keyVault__c" : "test9", "Id" : "test9_1" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureKeyVault__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, Id STRING, CA10__Azure_Key_Vault_Keys__r ARRAY >> >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" 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}; } var count_CA10__Azure_Key_Vault_Keys__r_INCOMPLIANT2 = 0; if (obj.CA10__Azure_Key_Vault_Keys__r != null) { for (var i3 = 0; i3 < obj.CA10__Azure_Key_Vault_Keys__r.length; i3++) { if (typeof(obj.CA10__Azure_Key_Vault_Keys__r[i3].status) !== 'undefined') { if (obj.CA10__Azure_Key_Vault_Keys__r[i3].status == 'INCOMPLIANT') { count_CA10__Azure_Key_Vault_Keys__r_INCOMPLIANT2 += obj.CA10__Azure_Key_Vault_Keys__r[i3].count; } } else { if (obj.CA10__Azure_Key_Vault_Keys__r[i3].result.status == 'INCOMPLIANT') { count_CA10__Azure_Key_Vault_Keys__r_INCOMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10__Azure_Key_Vault_Keys__r] ' + (count_CA10__Azure_Key_Vault_Keys__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status'); if (count_CA10__Azure_Key_Vault_Keys__r_INCOMPLIANT2 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__Azure_Key_Vault_Keys__r.has(INCOMPLIANT)", currentStateMessage: "The key rotation policy is not configured.", currentStateReferences: references1.join('\n'), remediation: "Configure automated key rotation.", runtimeError: null}; } var count_CA10__Azure_Key_Vault_Keys__r_COMPLIANT4 = 0; if (obj.CA10__Azure_Key_Vault_Keys__r != null) { for (var i5 = 0; i5 < obj.CA10__Azure_Key_Vault_Keys__r.length; i5++) { if (typeof(obj.CA10__Azure_Key_Vault_Keys__r[i5].status) !== 'undefined') { if (obj.CA10__Azure_Key_Vault_Keys__r[i5].status == 'COMPLIANT') { count_CA10__Azure_Key_Vault_Keys__r_COMPLIANT4 += obj.CA10__Azure_Key_Vault_Keys__r[i5].count; } } else { if (obj.CA10__Azure_Key_Vault_Keys__r[i5].result.status == 'COMPLIANT') { count_CA10__Azure_Key_Vault_Keys__r_COMPLIANT4 += 1; } } } } // condition[2], conditionIndex:[200..299] if (count_CA10__Azure_Key_Vault_Keys__r_COMPLIANT4 > 0) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__Azure_Key_Vault_Keys__r.has(COMPLIANT)", currentStateMessage: "The key rotation policy is configured.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10__Azure_Key_Vault_Keys__r_UNDETERMINED6 = 0; if (obj.CA10__Azure_Key_Vault_Keys__r != null) { for (var i7 = 0; i7 < obj.CA10__Azure_Key_Vault_Keys__r.length; i7++) { if (typeof(obj.CA10__Azure_Key_Vault_Keys__r[i7].status) !== 'undefined') { if (obj.CA10__Azure_Key_Vault_Keys__r[i7].status == 'UNDETERMINED') { count_CA10__Azure_Key_Vault_Keys__r_UNDETERMINED6 += obj.CA10__Azure_Key_Vault_Keys__r[i7].count; } } else { if (obj.CA10__Azure_Key_Vault_Keys__r[i7].result.status == 'UNDETERMINED') { count_CA10__Azure_Key_Vault_Keys__r_UNDETERMINED6 += 1; } } } } // condition[3], conditionIndex:[300..399] if (count_CA10__Azure_Key_Vault_Keys__r_UNDETERMINED6 > 0) { return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "CA10__Azure_Key_Vault_Keys__r.has(UNDETERMINED)", currentStateMessage: "Unexpected values in the field.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "The Key Vault does not have active keys, or Cloudaware has insufficient access to list keys.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__Azure_Key_Vault_Keys__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__enabledStatus__c STRING, CA10__lifetimeActions__c STRING, CA10__created__c TIMESTAMP, CA10__keyVault__c STRING, 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 todayPlus1Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (1 * 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 && extract12.call(extract12).getTime() < todayPlus1Day)) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "not(extract('CA10__created__c').withinLastDays(730))", currentStateMessage: "Key rotation is enabled, but this key has not been rotated in over two years.", currentStateReferences: references1.join('\n'), remediation: "Set the rotation interval to under two years to align with best practices.", 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 field.", 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.Id AS Id, `CA10__Azure_Key_Vault_Keys__r`.arr AS CA10__Azure_Key_Vault_Keys__r, process_CA10__CaAzureKeyVault__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.Id AS Id, `CA10__Azure_Key_Vault_Keys__r`.arr AS CA10__Azure_Key_Vault_Keys__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureKeyVault__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10__keyVault__c, ARRAY_AGG( 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.CA10__keyVault__c AS CA10__keyVault__c, sObject.Id AS Id, process_CA10__Azure_Key_Vault_Keys__r( 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.CA10__keyVault__c AS CA10__keyVault__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAzureKeyVaultKey__c()) AS sObject GROUP BY sObject.CA10__keyVault__c ) AS `CA10__Azure_Key_Vault_Keys__r` ON sObject.Id = `CA10__Azure_Key_Vault_Keys__r`.CA10__keyVault__c ) sObject ON sObject.Id = expectedResult.Id;