--- policy: /ce/ca/aws/ec2/ebs-snapshot-public logic: /ce/ca/aws/ec2/ebs-snapshot-public/prod.logic.yaml executionTime: 2026-02-10T22:32:40.997952872Z generationMs: 63 executionMs: 888 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__publicAccessible__c') == 'Yes' actual: extract('CA10__publicAccessible__c') == 'Yes' runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__publicAccessible__c') == 'No' actual: extract('CA10__publicAccessible__c') == 'No' runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__publicAccessible__c').isEmpty() actual: extract('CA10__publicAccessible__c').isEmpty() runtimeError: {} usedFiles: - path: /ce/ca/aws/ec2/ebs-snapshot-public/policy.yaml md5Hash: 9201B596962CAE4F4E2192B8459642A1 content: "---\nnames:\n full: \"AWS EBS Snapshot is publicly accessible\"\n \ \ contextual: \"EBS Snapshot is publicly accessible\"\ndescription: >\n Ensure\ \ that Amazon EBS snapshots are not publicly accessible to prevent \n unauthorized\ \ access to data. Snapshots should be shared only with specific, \n trusted\ \ AWS accounts.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n - \"SECURITY\"\n\ frameworkMappings:\n - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/ec2/01\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[EC2.1] Amazon EBS snapshots should not be publicly restorable\"\ \n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-1\"" - path: /ce/ca/aws/ec2/ebs-snapshot-public/prod.logic.yaml md5Hash: 93ACB4701866BC54EF7EF19514C813F9 content: | inputType: "CA10__CaAwsSnapshot__c" testData: - file: "test-data.json" importExtracts: - file: /types/CA10__CaAwsSnapshot__c/object.extracts.yaml conditions: - status: "INCOMPLIANT" currentStateMessage: "The EBS snapshot is publicly accessible." remediationMessage: "Make the snapshot private or restrict access to specific AWS accounts." check: IS_EQUAL: left: EXTRACT: "CA10__publicAccessible__c" right: TEXT: "Yes" - status: "COMPLIANT" currentStateMessage: "The EBS snapshot is not publicly accessible." check: IS_EQUAL: left: EXTRACT: "CA10__publicAccessible__c" right: TEXT: "No" - status: "COMPLIANT" currentStateMessage: "The EBS snapshot is not publicly accessible." check: IS_EMPTY: arg: EXTRACT: "CA10__publicAccessible__c" otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected values in the field." - path: /ce/ca/aws/ec2/ebs-snapshot-public/test-data.json md5Hash: FD071E743B5093BD86D1CFFF40A9A122 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2025-07-22T00:06:58Z", "CA10__publicAccessible__c": "No" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10__publicAccessible__c') == 'Yes'", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__publicAccessible__c": "Yes" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__publicAccessible__c') == 'No'", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__publicAccessible__c": "No" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "399", "conditionText": "extract('CA10__publicAccessible__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__publicAccessible__c": "" } ] - path: /types/CA10__CaAwsSnapshot__c/object.extracts.yaml md5Hash: 44D70F8730901DA3EFD8E736EDA9E616 content: "# yaml-language-server: $schema=../../schema/Extracts.schema.json\n\ ---\nextracts:\n# Values: Yea | No. Nullable null is equal to No. \n - name:\ \ CA10__publicAccessible__c\n value:\n FIELD: \n path: CA10__publicAccessible__c\n\ \ # undeterminedIf:\n # noAccessDelegate:\n # path:\ \ \"CA10__publicAccessible__c\"\n # currentStateMessage: \"Unable\ \ to determined Public Access. Possible Permissions issues with ec2:DescribeSnapshotAttribute.\"\ \n# Not Nullable. Can't have no access retrieved via ec2:DescribeSnapshots.\n\ \ - name: \"CA10__startTime__c\"\n value:\n FIELD:\n path: \"\ CA10__startTime__c\"\n undeterminedIf:\n isEmpty: \"Corrupted\ \ data. Snapshot Start Time cannot be empty.\"\n# Values: pending | completed\ \ | error | recoverable | recovering \n# Not Nullable. Can't have no access\ \ retrieved via ec2:DescribeSnapshots.\n - name: \"CA10__state__c\"\n value:\n\ \ FIELD:\n path: \"CA10__state__c\"\n undeterminedIf:\n \ \ isEmpty: \"Corrupted data. Snapshot Start Time cannot be empty.\"\n\ # Not Nullable.\n - name: \"CA10__encrypted__c\"\n value:\n FIELD:\n\ \ path: \"CA10__encrypted__c\"\n undeterminedIf:\n isEmpty:\ \ \"Corrupted data. Snapshot `Encrypted` state 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(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10__publicAccessible__c') == 'Yes'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__publicAccessible__c') == 'No'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('CA10__publicAccessible__c').isEmpty()", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsSnapshot__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__disappearanceTime__c" : new Date("2025-07-22T00:06:58Z"), "CA10__publicAccessible__c" : "No", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__publicAccessible__c" : "Yes", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__publicAccessible__c" : "No", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__publicAccessible__c" : "", "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsSnapshot__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__publicAccessible__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__publicAccessible__c; } return this.out; }; references1.push('Public Accessible [obj.CA10__publicAccessible__c]: ' + obj.CA10__publicAccessible__c); if (TextLib.equal(extract3.call(extract3), 'Yes')) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__publicAccessible__c') == 'Yes'", currentStateMessage: "The EBS snapshot is publicly accessible.", currentStateReferences: references1.join('\n'), remediation: "Make the snapshot private or restrict access to specific AWS accounts.", runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__publicAccessible__c; } return this.out; }; if (TextLib.equal(extract6.call(extract6), 'No')) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__publicAccessible__c') == 'No'", currentStateMessage: "The EBS snapshot is not publicly accessible.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract9() { if (!this.out) { this.out = obj.CA10__publicAccessible__c; } return this.out; }; if (TextLib.isEmpty(extract9.call(extract9))) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__publicAccessible__c').isEmpty()", currentStateMessage: "The EBS snapshot is not publicly accessible.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 400, 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.CA10__publicAccessible__c AS CA10__publicAccessible__c, sObject.Id AS Id, process_CA10__CaAwsSnapshot__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__publicAccessible__c AS CA10__publicAccessible__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsSnapshot__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;