--- policy: /ce/ca/aws/dynamodb/table-point-in-time-recovery logic: /ce/ca/aws/dynamodb/table-point-in-time-recovery/prod.logic.yaml executionTime: 2026-06-06T12:02:40.107201507Z generationMs: 68 executionMs: 1313 rows: - id: test1 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT) actual: CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__pointInTimeRecoveryStatus__c') == 'DISABLED' actual: extract('CA10__pointInTimeRecoveryStatus__c') == 'DISABLED' runtimeError: {} - id: test3 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__tableStatus__c') != 'ACTIVE' actual: extract('CA10__tableStatus__c') != 'ACTIVE' runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10__pointInTimeRecoveryStatus__c') == 'ENABLED' actual: extract('CA10__pointInTimeRecoveryStatus__c') == 'ENABLED' runtimeError: {} - id: test5 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT) actual: CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT) runtimeError: {} usedFiles: - path: /ce/ca/aws/dynamodb/table-point-in-time-recovery/policy.yaml md5Hash: 3E7AC5403389C5EA48E8C0DBB036F85A content: "---\nnames:\n full: \"AWS DynamoDB Table Point In Time Recovery is\ \ not enabled\"\n contextual: \"Table Point In Time Recovery is not enabled\"\ \ndescription: >\n Ensure that Point-in-Time Recovery (PITR) is enabled for\ \ your Amazon DynamoDB \n tables to protect against accidental writes or deletes.\ \ PITR provides continuous \n backups, allowing you to restore your table to\ \ any point in time during \n the last 35 days.\ntype: \"COMPLIANCE_POLICY\"\ \ncategories:\n - \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/data-protection-and-recovery\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/dynamodb/02\"\n - \"/frameworks/aws-well-architected/rel/09/01\"\ \n - \"/frameworks/aws-well-architected/rel/09/03\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[DynamoDB.2] DynamoDB tables should have point-in-time recovery\ \ enabled\"\n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/dynamodb-controls.html#dynamodb-2\"\ \n internal:\n - \"dec-x-a822159a\"" - path: /ce/ca/aws/dynamodb/table-point-in-time-recovery/prod.logic.yaml md5Hash: 81A4B10A0690B951BB9A6303394B2564 content: "inputType: \"CA10__CaAwsDynamoDbTable__c\"\ntestData:\n - file: \"\ test-data.json\"\nimportExtracts:\n - file: /types/CA10__CaAwsDynamoDbTable__c/object.extracts.yaml\n\ conditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage: \"The table\ \ is not active.\"\n check:\n NOT_EQUAL:\n left:\n EXTRACT:\ \ \"CA10__tableStatus__c\"\n right:\n TEXT: \"ACTIVE\"\n -\ \ status: \"INAPPLICABLE\"\n currentStateMessage: \"On-demand backup is enabled\ \ for this DynamoDB table.\"\n check:\n OR:\n args:\n \ \ - RELATED_LIST_HAS:\n status: \"COMPLIANT\"\n \ \ relationshipName: \"CA10__AWS_DynamoDB_Backups__r\"\n - RELATED_LIST_HAS:\n\ \ status: \"COMPLIANT\"\n relationshipName: \"CA10A1__AWS_Backup_Recovery_Points__r\"\ \n - status: \"INCOMPLIANT\"\n currentStateMessage: \"Point-in-Time Recovery\ \ is not enabled for this DynamoDB table.\"\n remediationMessage: \"Enable\ \ point-in-time recovery for the DynamoDB table to allow granular data restoration.\"\ \n check:\n IS_EQUAL:\n left:\n EXTRACT: \"CA10__pointInTimeRecoveryStatus__c\"\ \n right:\n TEXT: \"DISABLED\"\n - status: \"COMPLIANT\"\n\ \ currentStateMessage: \"Point-in-time recovery is enabled for this DynamoDB\ \ table.\"\n check:\n IS_EQUAL:\n left:\n EXTRACT: \"\ CA10__pointInTimeRecoveryStatus__c\"\n right:\n TEXT: \"ENABLED\"\ \notherwise:\n status: \"UNDETERMINED\"\n currentStateMessage: \"Unexpected\ \ values in the field.\"\nrelatedLists:\n - relationshipName: \"CA10__AWS_DynamoDB_Backups__r\"\ \n importExtracts:\n - file: /types/CA10__CaAwsDynamoDbBackup__c/object.extracts.yaml\n\ \ conditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage:\ \ \"The DynamoDB Backup is not available.\"\n check:\n NOT_EQUAL:\n\ \ left:\n EXTRACT: \"CA10__status__c\"\n \ \ right:\n TEXT: \"AVAILABLE\"\n - status: \"INCOMPLIANT\"\ \n currentStateMessage: \"The DynamoDB Backup is active but was created\ \ more than 90 days ago.\"\n remediationMessage: \"Rotate the DynamoDB\ \ backup by creating a new one and deleting the old one.\"\n check:\n\ \ IS_BEYOND_LAST_DAYS:\n offsetDays: 90\n arg:\n\ \ EXTRACT: \"CA10__creationDateTime__c\"\n otherwise: \n \ \ status: \"COMPLIANT\"\n currentStateMessage: \"The backup exists and\ \ was created within the last 90 days.\"\n - relationshipName: \"CA10A1__AWS_Backup_Recovery_Points__r\"\ \n importExtracts:\n - file: /types/CA10A1__CaAwsBackupRecoveryPoint__c/object.extracts.yaml\n\ \ conditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage:\ \ \"The recovery point is not completed or available.\"\n check:\n \ \ AND:\n args:\n - NOT_EQUAL:\n \ \ left:\n EXTRACT: \"CA10A1__status__c\"\n \ \ right:\n TEXT: \"COMPLETED\"\n - NOT_EQUAL:\n\ \ left:\n EXTRACT: \"CA10A1__status__c\"\ \n right:\n TEXT: \"AVAILABLE\"\n -\ \ status: \"INCOMPLIANT\"\n currentStateMessage: \"The recovery point\ \ is active but was created more than 90 days ago.\"\n remediationMessage:\ \ \"Rotate the backup recovery point by creating a new one and deleting the\ \ old one.\"\n check:\n IS_BEYOND_LAST_DAYS:\n offsetDays:\ \ 90\n arg:\n EXTRACT: \"CA10A1__creationDate__c\"\n\ \ otherwise: \n status: \"COMPLIANT\"\n currentStateMessage: \"\ The backup recovery point exists.\"\n" - path: /ce/ca/aws/dynamodb/table-point-in-time-recovery/test-data.json md5Hash: CA228015ECC590C4A5D33855C1B25214 content: | [ { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-01-28T23:10:46Z" }, "CA10__disappearanceTime__c": null, "CA10__tableStatus__c": "ACTIVE", "CA10__pointInTimeRecoveryStatus__c": "DISABLED", "Id": "test1", "CA10__AWS_DynamoDB_Backups__r": [ { "CA10__disappearanceTime__c": null, "CA10__status__c": "AVAILABLE", "CA10__creationDateTime__c": "2022-11-04T15:29:39Z", "CA10__table__c": "test1", "Id": "test1_1" } ], "CA10A1__AWS_Backup_Recovery_Points__r": [ { "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "COMPLETED", "CA10A1__creationDate__c": "2026-01-20T23:10:46Z", "CA10A1__dynamoDbTable__c": "test1", "Id": "test1_2" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "extract('CA10__pointInTimeRecoveryStatus__c') == 'DISABLED'", "runtimeError": null }, "context": { "snapshotTime": "2026-01-28T23:10:46Z" }, "CA10__disappearanceTime__c": null, "CA10__tableStatus__c": "ACTIVE", "CA10__pointInTimeRecoveryStatus__c": "DISABLED", "Id": "test2", "CA10__AWS_DynamoDB_Backups__r": [], "CA10A1__AWS_Backup_Recovery_Points__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__tableStatus__c') != 'ACTIVE'", "runtimeError": null }, "context": { "snapshotTime": "2026-01-28T23:10:46Z" }, "CA10__disappearanceTime__c": null, "CA10__tableStatus__c": "DELETING", "CA10__pointInTimeRecoveryStatus__c": "DISABLED", "Id": "test3", "CA10__AWS_DynamoDB_Backups__r": [ { "CA10__disappearanceTime__c": null, "CA10__status__c": "AVAILABLE", "CA10__creationDateTime__c": "2022-11-04T15:29:39Z", "CA10__table__c": "test3", "Id": "test3_1" } ], "CA10A1__AWS_Backup_Recovery_Points__r": [ { "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "COMPLETED", "CA10A1__creationDate__c": "2025-12-21T05:00:00Z", "CA10A1__dynamoDbTable__c": "test3", "Id": "test3_2" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "499", "conditionText": "extract('CA10__pointInTimeRecoveryStatus__c') == 'ENABLED'", "runtimeError": null }, "context": { "snapshotTime": "2026-01-28T23:10:46Z" }, "CA10__disappearanceTime__c": null, "CA10__tableStatus__c": "ACTIVE", "CA10__pointInTimeRecoveryStatus__c": "ENABLED", "Id": "test4", "CA10__AWS_DynamoDB_Backups__r": [ { "CA10__disappearanceTime__c": null, "CA10__status__c": "AVAILABLE", "CA10__creationDateTime__c": "2022-11-04T15:29:39Z", "CA10__table__c": "test4", "Id": "test4_1" } ], "CA10A1__AWS_Backup_Recovery_Points__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-01-28T23:10:46Z" }, "CA10__disappearanceTime__c": null, "CA10__tableStatus__c": "ACTIVE", "CA10__pointInTimeRecoveryStatus__c": "DISABLED", "Id": "test5", "CA10__AWS_DynamoDB_Backups__r": [ { "CA10__disappearanceTime__c": null, "CA10__status__c": "AVAILABLE", "CA10__creationDateTime__c": "2026-01-20T23:10:46Z", "CA10__table__c": "test5", "Id": "test5_1" } ], "CA10A1__AWS_Backup_Recovery_Points__r": [ { "CA10A1__disappearanceTime__c": null, "CA10A1__status__c": "COMPLETED", "CA10A1__creationDate__c": "2025-12-21T05:00:00Z", "CA10A1__dynamoDbTable__c": "test5", "Id": "test5_2" } ] } ] - path: /types/CA10__CaAwsDynamoDbBackup__c/object.extracts.yaml md5Hash: 7A95CBE1796D4FCEB869F5CDD935E516 content: |- --- extracts: # Not nullable. - name: "CA10__creationDateTime__c" value: FIELD: path: "CA10__creationDateTime__c" undeterminedIf: noAccessDelegate: path: "CA10__creationDateTime__c" currentStateMessage: "Dynamo DB Table Backup creation date cannot be empty." # Nullable. - name: "CA10__status__c" value: FIELD: path: "CA10__status__c" - 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.\"" - path: /types/CA10__CaAwsDynamoDbTable__c/object.extracts.yaml md5Hash: EC959FF9A6572890388AA7C1C47122EF content: "---\nextracts:\n# Nullable, null is equal to PROVISIONED\n - name:\ \ \"CA10__billingMode__c\"\n value:\n FIELD:\n path: CA10__billingMode__c\n\ \ # undeterminedIf:\n # noAccessDelegate:\n # path:\ \ \"CA10__billingMode__c\"\n # currentStateMessage: \"Unable to determine\ \ Table Billing Mode. Possible permission issue with dynamodb:DescribeTable.\"\ \n# Values: ENABLED | DISABLED. Not nullable. \n - name: \"CA10__pointInTimeRecoveryStatus__c\"\ \n value:\n FIELD:\n path: CA10__pointInTimeRecoveryStatus__c\n\ \ # undeterminedIf:\n # noAccessDelegate:\n # path:\ \ \"CA10__pointInTimeRecoveryStatus__c\"\n # currentStateMessage:\ \ \"Unable to determine Point In Time Recovery Status. Possible permission issue\ \ with dynamodb:DescribeTable.\"\n# Nullable.\n - name: \"CA10__regionName2__c\"\ \n value:\n FIELD:\n path: \"CA10__regionName2__c\"\n# Values:\ \ CREATING | UPDATING | DELETING | ACTIVE | INACCESSIBLE_ENCRYPTION_CREDENTIALS\ \ | \n# ARCHIVING | ARCHIVED | REPLICATION_NOT_AUTHORIZED\n# Not nullable. Possible\ \ permission issue with dynamodb:DescribeTable.\n - name: \"CA10__tableStatus__c\"\ \n value:\n FIELD:\n path: \"CA10__tableStatus__c\"\n# Values:\ \ ENABLED | null. Possible permission issue with dynamodb:DescribeTable.\n \ \ - name: \"CA10__sseDescriptionStatus__c\"\n value:\n FIELD:\n \ \ path: \"CA10__sseDescriptionStatus__c\"\n# Not nullable. Number\n - name:\ \ \"CA10__itemCount__c\"\n value:\n FIELD:\n path: \"CA10__itemCount__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__itemCount__c\"\n currentStateMessage: \"Dynamo DB Table item\ \ count cannot be empty. Possible permission issue with dynamodb:DescribeTable\"\ \n# Not nullable.\n - name: \"CA10__creationDateTime__c\"\n value:\n \ \ FIELD:\n path: \"CA10__creationDateTime__c\"\n undeterminedIf:\n\ \ noAccessDelegate:\n path: \"CA10__creationDateTime__c\"\ \n currentStateMessage: \"Dynamo DB Table creation date cannot be\ \ empty. Possible permission issue with dynamodb:DescribeTable\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('CA10__pointInTimeRecoveryStatus__c') == 'DISABLED'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__tableStatus__c') != 'ACTIVE'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('CA10__pointInTimeRecoveryStatus__c') == 'ENABLED'", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT)", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsDynamoDbTable__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__tableStatus__c" : "ACTIVE", "CA10__pointInTimeRecoveryStatus__c" : "DISABLED", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__tableStatus__c" : "ACTIVE", "CA10__pointInTimeRecoveryStatus__c" : "DISABLED", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__tableStatus__c" : "DELETING", "CA10__pointInTimeRecoveryStatus__c" : "DISABLED", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__tableStatus__c" : "ACTIVE", "CA10__pointInTimeRecoveryStatus__c" : "ENABLED", "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__tableStatus__c" : "ACTIVE", "CA10__pointInTimeRecoveryStatus__c" : "DISABLED", "Id" : "test5" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsDynamoDbBackup__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__status__c" : "AVAILABLE", "CA10__creationDateTime__c" : new Date("2022-11-04T15:29:39Z"), "CA10__table__c" : "test1", "Id" : "test1_1" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__status__c" : "AVAILABLE", "CA10__creationDateTime__c" : new Date("2022-11-04T15:29:39Z"), "CA10__table__c" : "test3", "Id" : "test3_1" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__status__c" : "AVAILABLE", "CA10__creationDateTime__c" : new Date("2022-11-04T15:29:39Z"), "CA10__table__c" : "test4", "Id" : "test4_1" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10__status__c" : "AVAILABLE", "CA10__creationDateTime__c" : new Date("2026-01-20T23:10:46Z"), "CA10__table__c" : "test5", "Id" : "test5_1" } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsBackupRecoveryPoint__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10A1__status__c" : "COMPLETED", "CA10A1__creationDate__c" : new Date("2026-01-20T23:10:46Z"), "CA10A1__dynamoDbTable__c" : "test1", "Id" : "test1_2" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10A1__status__c" : "COMPLETED", "CA10A1__creationDate__c" : new Date("2025-12-21T05:00:00Z"), "CA10A1__dynamoDbTable__c" : "test3", "Id" : "test3_2" }, { "context" : { "snapshotTime" : new Date("2026-01-28T23:10:46Z") }, "CA10A1__status__c" : "COMPLETED", "CA10A1__creationDate__c" : new Date("2025-12-21T05:00:00Z"), "CA10A1__dynamoDbTable__c" : "test5", "Id" : "test5_2" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsDynamoDbTable__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__tableStatus__c STRING, CA10__pointInTimeRecoveryStatus__c STRING, CA10__AWS_DynamoDB_Backups__r ARRAY >>, CA10A1__AWS_Backup_Recovery_Points__r ARRAY >>, 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 [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 extract3() { if (!this.out) { this.out = obj.CA10__tableStatus__c; } return this.out; }; references1.push('Table Status [obj.CA10__tableStatus__c]: ' + obj.CA10__tableStatus__c); if (TextLib.notEqual(extract3.call(extract3), 'ACTIVE')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__tableStatus__c') != 'ACTIVE'", currentStateMessage: "The table is not active.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10__AWS_DynamoDB_Backups__r_COMPLIANT5 = 0; if (obj.CA10__AWS_DynamoDB_Backups__r != null) { for (var i7 = 0; i7 < obj.CA10__AWS_DynamoDB_Backups__r.length; i7++) { if (typeof(obj.CA10__AWS_DynamoDB_Backups__r[i7].status) !== 'undefined') { if (obj.CA10__AWS_DynamoDB_Backups__r[i7].status == 'COMPLIANT') { count_CA10__AWS_DynamoDB_Backups__r_COMPLIANT5 += obj.CA10__AWS_DynamoDB_Backups__r[i7].count; } } else { if (obj.CA10__AWS_DynamoDB_Backups__r[i7].result.status == 'COMPLIANT') { count_CA10__AWS_DynamoDB_Backups__r_COMPLIANT5 += 1; } } } } var count_CA10A1__AWS_Backup_Recovery_Points__r_COMPLIANT6 = 0; if (obj.CA10A1__AWS_Backup_Recovery_Points__r != null) { for (var i8 = 0; i8 < obj.CA10A1__AWS_Backup_Recovery_Points__r.length; i8++) { if (typeof(obj.CA10A1__AWS_Backup_Recovery_Points__r[i8].status) !== 'undefined') { if (obj.CA10A1__AWS_Backup_Recovery_Points__r[i8].status == 'COMPLIANT') { count_CA10A1__AWS_Backup_Recovery_Points__r_COMPLIANT6 += obj.CA10A1__AWS_Backup_Recovery_Points__r[i8].count; } } else { if (obj.CA10A1__AWS_Backup_Recovery_Points__r[i8].result.status == 'COMPLIANT') { count_CA10A1__AWS_Backup_Recovery_Points__r_COMPLIANT6 += 1; } } } } // condition[2], conditionIndex:[200..299] references1.push('Related list [CA10__AWS_DynamoDB_Backups__r] ' + (count_CA10__AWS_DynamoDB_Backups__r_COMPLIANT5 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); references1.push('Related list [CA10A1__AWS_Backup_Recovery_Points__r] ' + (count_CA10A1__AWS_Backup_Recovery_Points__r_COMPLIANT6 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10__AWS_DynamoDB_Backups__r_COMPLIANT5 > 0 || count_CA10A1__AWS_Backup_Recovery_Points__r_COMPLIANT6 > 0) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "CA10__AWS_DynamoDB_Backups__r.has(COMPLIANT) || CA10A1__AWS_Backup_Recovery_Points__r.has(COMPLIANT)", currentStateMessage: "On-demand backup is enabled for this DynamoDB table.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract10() { if (!this.out) { this.out = obj.CA10__pointInTimeRecoveryStatus__c; } return this.out; }; references1.push('Point In Time Recovery Status [obj.CA10__pointInTimeRecoveryStatus__c]: ' + obj.CA10__pointInTimeRecoveryStatus__c); if (TextLib.equal(extract10.call(extract10), 'DISABLED')) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__pointInTimeRecoveryStatus__c') == 'DISABLED'", currentStateMessage: "Point-in-Time Recovery is not enabled for this DynamoDB table.", currentStateReferences: references1.join('\n'), remediation: "Enable point-in-time recovery for the DynamoDB table to allow granular data restoration.", runtimeError: null}; } // condition[4], conditionIndex:[400..499] function extract13() { if (!this.out) { this.out = obj.CA10__pointInTimeRecoveryStatus__c; } return this.out; }; if (TextLib.equal(extract13.call(extract13), 'ENABLED')) { return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__pointInTimeRecoveryStatus__c') == 'ENABLED'", currentStateMessage: "Point-in-time recovery is enabled for this DynamoDB table.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "Unexpected values in the field.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__AWS_DynamoDB_Backups__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__status__c STRING, CA10__creationDateTime__c TIMESTAMP, CA10__table__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); 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 todayMinus90Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-90 * 86400000); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [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 extract3() { if (!this.out) { this.out = obj.CA10__status__c; } return this.out; }; references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c); if (TextLib.notEqual(extract3.call(extract3), 'AVAILABLE')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'AVAILABLE'", currentStateMessage: "The DynamoDB Backup is not available.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function fieldChecked7() { if (IsEmptyLib.simpleIsEmpty(obj.CA10__creationDateTime__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__creationDateTime__c.delegatedTo(CA10__creationDateTime__c).isEmpty()", currentStateMessage: "Dynamo DB Table creation date cannot be empty. Possible permission issue with dynamodb:DescribeTable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__creationDateTime__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; references1.push('Creation Date Time [obj.CA10__creationDateTime__c]: ' + obj.CA10__creationDateTime__c); try { if (extract6.call(extract6) != null && extract6.call(extract6).getTime() < todayMinus90Day) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__creationDateTime__c').beyondLastDays(90)", currentStateMessage: "The DynamoDB Backup is active but was created more than 90 days ago.", currentStateReferences: references1.join('\n'), remediation: "Rotate the DynamoDB backup by creating a new one and deleting the old one.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The backup exists and was created within the last 90 days.", 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__status__c STRING, CA10A1__creationDate__c TIMESTAMP, CA10A1__dynamoDbTable__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); 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 todayMinus90Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-90 * 86400000); 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__status__c; } return this.out; }; references1.push('Status [obj.CA10A1__status__c]: ' + obj.CA10A1__status__c); if (TextLib.notEqual(extract3.call(extract3), 'COMPLETED') && TextLib.notEqual(extract3.call(extract3), 'AVAILABLE')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10A1__status__c') != 'COMPLETED' && extract('CA10A1__status__c') != 'AVAILABLE'", currentStateMessage: "The recovery point is not completed or available.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function fieldChecked8() { if (IsEmptyLib.simpleIsEmpty(obj.CA10A1__creationDate__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10A1__creationDate__c.delegatedTo(CA10A1__creationDate__c).isEmpty()", currentStateMessage: "Backup Recovery Point creation date cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__creationDate__c; } function extract7() { if (!this.out) { this.out = fieldChecked8(); } return this.out; }; references1.push('Creation Date [obj.CA10A1__creationDate__c]: ' + obj.CA10A1__creationDate__c); try { if (extract7.call(extract7) != null && extract7.call(extract7).getTime() < todayMinus90Day) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10A1__creationDate__c').beyondLastDays(90)", currentStateMessage: "The recovery point is active but was created more than 90 days ago.", currentStateReferences: references1.join('\n'), remediation: "Rotate the backup recovery point by creating a new one and deleting the old one.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The backup recovery point exists.", 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__tableStatus__c AS CA10__tableStatus__c, sObject.CA10__pointInTimeRecoveryStatus__c AS CA10__pointInTimeRecoveryStatus__c, `CA10__AWS_DynamoDB_Backups__r`.arr AS CA10__AWS_DynamoDB_Backups__r, `CA10A1__AWS_Backup_Recovery_Points__r`.arr AS CA10A1__AWS_Backup_Recovery_Points__r, sObject.Id AS Id, process_CA10__CaAwsDynamoDbTable__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__tableStatus__c AS CA10__tableStatus__c, sObject.CA10__pointInTimeRecoveryStatus__c AS CA10__pointInTimeRecoveryStatus__c, `CA10__AWS_DynamoDB_Backups__r`.arr AS CA10__AWS_DynamoDB_Backups__r, `CA10A1__AWS_Backup_Recovery_Points__r`.arr AS CA10A1__AWS_Backup_Recovery_Points__r, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsDynamoDbTable__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10__table__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__creationDateTime__c AS CA10__creationDateTime__c, sObject.CA10__table__c AS CA10__table__c, sObject.Id AS Id, process_CA10__AWS_DynamoDB_Backups__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__creationDateTime__c AS CA10__creationDateTime__c, sObject.CA10__table__c AS CA10__table__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAwsDynamoDbBackup__c()) AS sObject GROUP BY sObject.CA10__table__c ) AS `CA10__AWS_DynamoDB_Backups__r` ON sObject.Id = `CA10__AWS_DynamoDB_Backups__r`.CA10__table__c LEFT JOIN ( SELECT sObject.CA10A1__dynamoDbTable__c, ARRAY_AGG( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__status__c AS CA10A1__status__c, sObject.CA10A1__creationDate__c AS CA10A1__creationDate__c, sObject.CA10A1__dynamoDbTable__c AS CA10A1__dynamoDbTable__c, sObject.Id AS Id, process_CA10A1__AWS_Backup_Recovery_Points__r( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__status__c AS CA10A1__status__c, sObject.CA10A1__creationDate__c AS CA10A1__creationDate__c, sObject.CA10A1__dynamoDbTable__c AS CA10A1__dynamoDbTable__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10A1__CaAwsBackupRecoveryPoint__c()) AS sObject GROUP BY sObject.CA10A1__dynamoDbTable__c ) AS `CA10A1__AWS_Backup_Recovery_Points__r` ON sObject.Id = `CA10A1__AWS_Backup_Recovery_Points__r`.CA10A1__dynamoDbTable__c ) sObject ON sObject.Id = expectedResult.Id;