--- policy: /ce/ca/aws/backup/vault-contains-unencrypted-recovery-points logic: /ce/ca/aws/backup/vault-contains-unencrypted-recovery-points/prod.logic.yaml executionTime: 2026-02-10T22:32:34.392330409Z generationMs: 78 executionMs: 1030 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10A1__disappearanceTime__c) actual: isDisappeared(CA10A1__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10A1__AWS_Backup_Recovery_Points__r.has(INCOMPLIANT) actual: CA10A1__AWS_Backup_Recovery_Points__r.has(INCOMPLIANT) runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/backup/vault-contains-unencrypted-recovery-points/policy.yaml md5Hash: ED057226DCABF818CB329D20CFAAF4DB content: "---\nnames:\n full: AWS Backup Vault contains unencrypted Recovery\ \ Points\n contextual: Vault contains unencrypted Recovery Points\ndescription:\ \ >\n Ensure that all Recovery Points within an AWS Backup Vault are encrypted.\ \ \n Unencrypted recovery points can expose sensitive backup data to unauthorized\ \ access.\ncategories:\n - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n\ \ - \"/frameworks/cloudaware/resource-security/data-encryption\"\n - \"/frameworks/aws-fsbp-v1.0.0/backup/01\"\ \n - \"/frameworks/aws-well-architected/rel/09/02\"\n - \"/frameworks/aws-well-architected/sec/08/02\"\ \nsimilarPolicies:\n awsSecurityHub:\n - name: \"[Backup.1] AWS Backup recovery\ \ points should be encrypted at rest\"\n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/backup-controls.html#backup-1\"\ \n" - path: /ce/ca/aws/backup/vault-contains-unencrypted-recovery-points/prod.logic.yaml md5Hash: 09A47702D3E4F53707F0A491A3CF5239 content: "---\ninputType: \"CA10A1__CaAwsBackupBackupVault__c\"\ntestData:\n \ \ - file: \"test-data.json\" \nconditions:\n - status: \"INCOMPLIANT\"\n \ \ currentStateMessage: \"The Backup Vault contains one or more unencrypted\ \ Recovery Points.\"\n remediationMessage: \"Ensure all Recovery Points are\ \ encrypted. This may require configuring the source resource's encryption settings.\"\ \n check:\n RELATED_LIST_HAS:\n status: \"INCOMPLIANT\"\n \ \ relationshipName: \"CA10A1__AWS_Backup_Recovery_Points__r\"\notherwise:\n\ \ status: \"COMPLIANT\"\n currentStateMessage: \"All Recovery Points in this\ \ Backup Vault are encrypted.\"\nrelatedLists:\n - relationshipName: \"CA10A1__AWS_Backup_Recovery_Points__r\"\ \n importExtracts:\n - file: \"/types/CA10A1__CaAwsBackupRecoveryPoint__c/object.extracts.yaml\"\ \n conditions:\n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"The Recovery Point is not encrypted with a KMS key.\"\n remediationMessage:\ \ \"Encrypt this Recovery Point.\"\n check:\n IS_EMPTY:\n \ \ arg:\n EXTRACT: \"CA10A1__kmsMasterKeyId__c\"\n otherwise:\n\ \ status: \"COMPLIANT\"\n currentStateMessage: \"The Recovery Point\ \ is encrypted with a KMS key.\"\n" - path: /ce/ca/aws/backup/vault-contains-unencrypted-recovery-points/test-data.json md5Hash: 6E39716EE48F994F12AEA7F4AC5B9B22 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-05-10T18:55:17Z" }, "Id": "test1", "CA10A1__disappearanceTime__c": "2025-05-10T18:55:17Z", "CA10A1__AWS_Backup_Recovery_Points__r": [ { "Id": "test1_1", "CA10A1__disappearanceTime__c": "2025-05-06T06:38:15Z", "CA10A1__kmsMasterKeyId__c": "", "CA10A1__backupVault__c": "test1" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-05-10T18:55:17Z" }, "Id": "test2", "CA10A1__disappearanceTime__c": null, "CA10A1__AWS_Backup_Recovery_Points__r": [ { "Id": "test2_1", "CA10A1__disappearanceTime__c": "2025-05-06T06:38:15Z", "CA10A1__kmsMasterKeyId__c": "", "CA10A1__backupVault__c": "test2" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10A1__AWS_Backup_Recovery_Points__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-05-10T18:55:17Z" }, "Id": "test3", "CA10A1__disappearanceTime__c": null, "CA10A1__AWS_Backup_Recovery_Points__r": [ { "Id": "test3_1", "CA10A1__disappearanceTime__c": null, "CA10A1__kmsMasterKeyId__c": "", "CA10A1__backupVault__c": "test3" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-05-10T18:55:17Z" }, "Id": "test4", "CA10A1__disappearanceTime__c": null, "CA10A1__AWS_Backup_Recovery_Points__r": [] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-05-10T18:55:17Z" }, "Id": "test5", "CA10A1__disappearanceTime__c": null, "CA10A1__AWS_Backup_Recovery_Points__r": [ { "Id": "test5_1", "CA10A1__disappearanceTime__c": null, "CA10A1__kmsMasterKeyId__c": "kmsMasterKeyId5", "CA10A1__backupVault__c": "test5" } ] } ] - path: /types/CA10A1__CaAwsBackupRecoveryPoint__c/object.extracts.yaml md5Hash: 03645351ED418265EF3EFF8207F505A7 content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\ \ backup:ListRecoveryPointsByBackupVault\n - name: CA10A1__kmsMasterKeyId__c\n\ \ value: \n FIELD:\n path: CA10A1__kmsMasterKeyId__c\n# Values:\ \ COMPLETED | PARTIAL | DELETING | EXPIRED | AVAILABLE | STOPPED | CREATING\n\ # Not Nullable. Can't have no access, retrieved via backup:ListRecoveryPointsByBackupVault\n\ \ - name: CA10A1__status__c\n value: \n FIELD:\n path: CA10A1__status__c\n\ # Nullable. Can't have no access, retrieved via backup:ListRecoveryPointsByBackupVault\n\ \ - name: CA10A1__calcLifecycleDeleteAt__c\n value: \n FIELD:\n \ \ path: CA10A1__calcLifecycleDeleteAt__c\n# Not nullable.\n - name: \"\ CA10A1__creationDate__c\"\n value: \n FIELD:\n path: \"CA10A1__creationDate__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10A1__creationDate__c\"\n currentStateMessage: \"Backup Recovery\ \ Point creation date cannot be empty.\"" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10A1__AWS_Backup_Recovery_Points__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsBackupBackupVault__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "CA10A1__disappearanceTime__c" : new Date("2025-05-10T18:55:17Z"), "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "Id" : "test5" } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsBackupRecoveryPoint__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "CA10A1__disappearanceTime__c" : new Date("2025-05-06T06:38:15Z"), "CA10A1__kmsMasterKeyId__c" : "", "CA10A1__backupVault__c" : "test1", "Id" : "test1_1" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "CA10A1__disappearanceTime__c" : new Date("2025-05-06T06:38:15Z"), "CA10A1__kmsMasterKeyId__c" : "", "CA10A1__backupVault__c" : "test2", "Id" : "test2_1" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "CA10A1__kmsMasterKeyId__c" : "", "CA10A1__backupVault__c" : "test3", "Id" : "test3_1" }, { "context" : { "snapshotTime" : new Date("2025-05-10T18:55:17Z") }, "CA10A1__kmsMasterKeyId__c" : "kmsMasterKeyId5", "CA10A1__backupVault__c" : "test5", "Id" : "test5_1" } ]; """; CREATE TEMP FUNCTION process_CA10A1__CaAwsBackupBackupVault__c( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, Id STRING, CA10A1__AWS_Backup_Recovery_Points__r ARRAY >> >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c); if (obj.CA10A1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10A1__AWS_Backup_Recovery_Points__r_INCOMPLIANT2 = 0; if (obj.CA10A1__AWS_Backup_Recovery_Points__r != null) { for (var i3 = 0; i3 < obj.CA10A1__AWS_Backup_Recovery_Points__r.length; i3++) { if (typeof(obj.CA10A1__AWS_Backup_Recovery_Points__r[i3].status) !== 'undefined') { if (obj.CA10A1__AWS_Backup_Recovery_Points__r[i3].status == 'INCOMPLIANT') { count_CA10A1__AWS_Backup_Recovery_Points__r_INCOMPLIANT2 += obj.CA10A1__AWS_Backup_Recovery_Points__r[i3].count; } } else { if (obj.CA10A1__AWS_Backup_Recovery_Points__r[i3].result.status == 'INCOMPLIANT') { count_CA10A1__AWS_Backup_Recovery_Points__r_INCOMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10A1__AWS_Backup_Recovery_Points__r] ' + (count_CA10A1__AWS_Backup_Recovery_Points__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status'); if (count_CA10A1__AWS_Backup_Recovery_Points__r_INCOMPLIANT2 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10A1__AWS_Backup_Recovery_Points__r.has(INCOMPLIANT)", currentStateMessage: "The Backup Vault contains one or more unencrypted Recovery Points.", currentStateReferences: references1.join('\n'), remediation: "Ensure all Recovery Points are encrypted. This may require configuring the source resource's encryption settings.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "All Recovery Points in this Backup Vault are encrypted.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10A1__AWS_Backup_Recovery_Points__r( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__kmsMasterKeyId__c STRING, CA10A1__backupVault__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 references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c); if (obj.CA10A1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function extract3() { if (!this.out) { this.out = obj.CA10A1__kmsMasterKeyId__c; } return this.out; }; references1.push('KMS Master Key ID [obj.CA10A1__kmsMasterKeyId__c]: ' + obj.CA10A1__kmsMasterKeyId__c); if (TextLib.isEmpty(extract3.call(extract3))) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__kmsMasterKeyId__c').isEmpty()", currentStateMessage: "The Recovery Point is not encrypted with a KMS key.", currentStateReferences: references1.join('\n'), remediation: "Encrypt this Recovery Point.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The Recovery Point is encrypted with a KMS key.", 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.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.Id AS Id, `CA10A1__AWS_Backup_Recovery_Points__r`.arr AS CA10A1__AWS_Backup_Recovery_Points__r, process_CA10A1__CaAwsBackupBackupVault__c( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.Id AS Id, `CA10A1__AWS_Backup_Recovery_Points__r`.arr AS CA10A1__AWS_Backup_Recovery_Points__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10A1__CaAwsBackupBackupVault__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10A1__backupVault__c, ARRAY_AGG( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__kmsMasterKeyId__c AS CA10A1__kmsMasterKeyId__c, sObject.CA10A1__backupVault__c AS CA10A1__backupVault__c, sObject.Id AS Id, process_CA10A1__AWS_Backup_Recovery_Points__r( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__kmsMasterKeyId__c AS CA10A1__kmsMasterKeyId__c, sObject.CA10A1__backupVault__c AS CA10A1__backupVault__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10A1__CaAwsBackupRecoveryPoint__c()) AS sObject GROUP BY sObject.CA10A1__backupVault__c ) AS `CA10A1__AWS_Backup_Recovery_Points__r` ON sObject.Id = `CA10A1__AWS_Backup_Recovery_Points__r`.CA10A1__backupVault__c ) sObject ON sObject.Id = expectedResult.Id;