--- policy: /ce/ca/aws/sns/topic-encryption-with-kms logic: /ce/ca/aws/sns/topic-encryption-with-kms/prod.logic.yaml executionTime: 2026-06-06T12:03:27.238845119Z generationMs: 65 executionMs: 936 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: extract('CA10__kmsKeyId__c').isEmpty() actual: extract('CA10__kmsKeyId__c').isEmpty() runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/sns/topic-encryption-with-kms/policy.yaml md5Hash: 37A0660D72CDB8DD860EA331DEBFF433 content: "---\nnames:\n full: \"AWS SNS Topic is not encrypted with a KMS key\"\ \n contextual: \"Topic is not encrypted with a KMS key\"\ndescription: >\n\ \ Enable server-side encryption (SSE) for Amazon SNS topics to protect the\ \ contents \n of messages at rest using KMS keys. AWS KMS provides enhanced\ \ security and control \n over the keys used to encrypt data.\ntype: \"COMPLIANCE_POLICY\"\ \ncategories:\n - \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/data-encryption\"\ \n - \"/frameworks/aws-well-architected/sec/08/02\"\n - \"/frameworks/nist-sp-800-53-r5/ca/09/01\"\ \n - \"/frameworks/nist-sp-800-53-r5/cm/03/06\"\n - \"/frameworks/nist-sp-800-53-r5/sc/13\"\ \n - \"/frameworks/nist-sp-800-53-r5/sc/28\"\n - \"/frameworks/nist-sp-800-53-r5/sc/28/01\"\ \n - \"/frameworks/nist-sp-800-53-r5/sc/07\"\n - \"/frameworks/nist-sp-800-53-r5/sc/07/10\"\ \n - \"/frameworks/nist-sp-800-53-r5/si/07/06\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[SNS.1] SNS topics should be encrypted at-rest using AWS KMS\"\ \n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/sns-controls.html#sns-1\"" - path: /ce/ca/aws/sns/topic-encryption-with-kms/prod.logic.yaml md5Hash: D9FE14FF67B6BB0FDCCDCF048218520E content: | --- inputType: "CA10__CaAwsTopic__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsTopic__c/object.extracts.yaml" conditions: - status: "INCOMPLIANT" currentStateMessage: "The SNS topic is not encrypted with a KMS key." remediationMessage: "Enable server-side encryption (SSE) using a KMS key." check: IS_EMPTY: arg: EXTRACT: "CA10__kmsKeyId__c" otherwise: status: "COMPLIANT" currentStateMessage: "The SNS topic is encrypted with a KMS key." - path: /ce/ca/aws/sns/topic-encryption-with-kms/test-data.json md5Hash: 9B2E4DCC5D0256D503FD961124DD0604 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-11-09T19:32:58Z" }, "CA10__disappearanceTime__c": "2025-11-07T15:39:37Z", "CA10__kmsKeyId__c": "kmsKeyId", "Id": "test1" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10__kmsKeyId__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-11-09T19:32:58Z" }, "CA10__disappearanceTime__c": null, "CA10__kmsKeyId__c": "", "Id": "test2" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-11-09T19:32:58Z" }, "CA10__disappearanceTime__c": null, "CA10__kmsKeyId__c": "kmsKeyId", "Id": "test3" } ] - path: /types/CA10__CaAwsTopic__c/object.extracts.yaml md5Hash: 45386FEBF083828D3A2C75CB7251C2D6 content: "---\nextracts:\n# Nullable\n - name: CA10__kmsKeyId__c\n value:\ \ \n FIELD:\n path: CA10__kmsKeyId__c\n" 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" : "extract('CA10__kmsKeyId__c').isEmpty()", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsTopic__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-11-09T19:32:58Z") }, "CA10__disappearanceTime__c" : new Date("2025-11-07T15:39:37Z"), "CA10__kmsKeyId__c" : "kmsKeyId", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-11-09T19:32:58Z") }, "CA10__kmsKeyId__c" : "", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-11-09T19:32:58Z") }, "CA10__kmsKeyId__c" : "kmsKeyId", "Id" : "test3" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsTopic__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__kmsKeyId__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 [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__kmsKeyId__c; } return this.out; }; references1.push('KMS Key ID [obj.CA10__kmsKeyId__c]: ' + obj.CA10__kmsKeyId__c); if (TextLib.isEmpty(extract3.call(extract3))) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__kmsKeyId__c').isEmpty()", currentStateMessage: "The SNS topic is not encrypted with a KMS key.", currentStateReferences: references1.join('\n'), remediation: "Enable server-side encryption (SSE) using a KMS key.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The SNS topic 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__kmsKeyId__c AS CA10__kmsKeyId__c, sObject.Id AS Id, process_CA10__CaAwsTopic__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__kmsKeyId__c AS CA10__kmsKeyId__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsTopic__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;