--- policy: /ce/ca/aws/ec2/ebs-volume-encryption logic: /ce/ca/aws/ec2/ebs-volume-encryption/prod.logic.yaml executionTime: 2026-06-06T12:02:41.178741273Z generationMs: 63 executionMs: 973 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: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__status__c') != 'in-use' actual: extract('CA10__status__c') != 'in-use' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: not(extract('CA10__encrypted__c')) actual: not(extract('CA10__encrypted__c')) runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__encrypted__c') == true actual: extract('CA10__encrypted__c') == true runtimeError: {} usedFiles: - path: /ce/ca/aws/ec2/ebs-volume-encryption/policy.yaml md5Hash: 3FAA45275092805E4C07D2CA19A95141 content: "---\nnames:\n full: \"AWS EBS Attached Volume is not encrypted\"\n\ \ contextual: \"EBS Attached Volume is not encrypted\"\ndescription: >\n Ensure\ \ that all attached EBS volumes are encrypted to protect data at rest. \n \ \ Encrypting EBS volumes adds a layer of security by rendering data unreadable\ \ \n to unauthorized users.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n -\ \ \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/data-encryption\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/ec2/03\"\n - \"/frameworks/aws-well-architected/sec/08/02\"\ \nsimilarPolicies:\n awsSecurityHub:\n - name: \"[EC2.3] Attached Amazon\ \ EBS volumes should be encrypted at-rest\"\n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-3\"" - path: /ce/ca/aws/ec2/ebs-volume-encryption/prod.logic.yaml md5Hash: DA5953B18711E0A79CEE9DB07509DA3C content: | inputType: "CA10__CaAwsVolume__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsVolume__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "This policy applies only to attached EBS volumes. This volume is not attached." check: NOT_EQUAL: left: EXTRACT: "CA10__status__c" right: TEXT: "in-use" - status: "INCOMPLIANT" currentStateMessage: "The attached EBS volume is not encrypted." remediationMessage: "Enable encryption for the volume." check: NOT: arg: EXTRACT: "CA10__encrypted__c" - status: "COMPLIANT" currentStateMessage: "The attached EBS volume is encrypted." check: IS_EQUAL: left: EXTRACT: "CA10__encrypted__c" right: BOOLEAN: true otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected values in the field." - path: /ce/ca/aws/ec2/ebs-volume-encryption/test-data.json md5Hash: 5D8A8BDAA59D406ED79660015FBC5EED 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-02T15:40:18Z", "CA10__status__c": "in-use", "CA10__encrypted__c": true }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__status__c') != 'in-use'", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__status__c": "available", "CA10__encrypted__c": false }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "not(extract('CA10__encrypted__c'))", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__status__c": "in-use", "CA10__encrypted__c": false }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "399", "conditionText": "extract('CA10__encrypted__c') == true", "runtimeError": null }, "context": { "snapshotTime": "2025-07-22T16:18:44Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__status__c": "in-use", "CA10__encrypted__c": true } ] - path: /types/CA10__CaAwsVolume__c/object.extracts.yaml md5Hash: D98F19A3E57995D503E82126277DD66A content: "# yaml-language-server: $schema=../../schema/Extracts.schema.json\n\ ---\nextracts:\n# Values: creating | available | in-use | deleting | deleted\ \ | error. Not nullable. Can't have no access, retrieved via ec2:DescribeVolumes\ \ \n - name: CA10__status__c\n value:\n FIELD: \n path: CA10__status__c\n\ # Checkbox\n - name: CA10__encrypted__c\n value:\n FIELD: \n \ \ path: CA10__encrypted__c\n# Date/Time. Nullable\n - name: CA10__attachmentAttachTime__c\n\ \ value:\n FIELD:\n path: CA10__attachmentAttachTime__c\n# Number.\ \ Nullable\n - name: CA10__throughputPercentMax30d__c\n value:\n FIELD:\n\ \ path: CA10__throughputPercentMax30d__c\n# Number. Nullable\n - name:\ \ CA10__readOpsSum30d__c\n value:\n FIELD:\n path: CA10__readOpsSum30d__c\n\ # Number. Nullable\n - name: CA10__writeOpsSum30d__c\n value:\n FIELD:\n\ \ path: CA10__writeOpsSum30d__c\n# Date/Time. Can't have no access, retrieved\ \ via ec2:DescribeVolumes\n - name: CA10__createTime__c\n value:\n \ \ FIELD:\n path: CA10__createTime__c\n# Number. Nullable\n - name: CA10__iops__c\n\ \ value:\n FIELD:\n path: CA10__iops__c\n# Number. Nullable\n\ \ - name: CA10__sumIopsOneMonth__c\n value:\n FIELD:\n path:\ \ CA10__sumIopsOneMonth__c\n# Text.\n - name: CA10__volumeType__c\n value:\n\ \ FIELD:\n path: CA10__volumeType__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" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__status__c') != 'in-use'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "not(extract('CA10__encrypted__c'))", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('CA10__encrypted__c') == true", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsVolume__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-02T15:40:18Z"), "CA10__status__c" : "in-use", "CA10__encrypted__c" : true, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__status__c" : "available", "CA10__encrypted__c" : false, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__status__c" : "in-use", "CA10__encrypted__c" : false, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-07-22T16:18:44Z") }, "CA10__status__c" : "in-use", "CA10__encrypted__c" : true, "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsVolume__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__status__c STRING, CA10__encrypted__c BOOLEAN, 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__status__c; } return this.out; }; references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c); if (TextLib.notEqual(extract3.call(extract3), 'in-use')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'in-use'", currentStateMessage: "This policy applies only to attached EBS volumes. This volume is not attached.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__encrypted__c; } return this.out; }; references1.push('Encrypted [obj.CA10__encrypted__c]: ' + obj.CA10__encrypted__c); if (!extract6.call(extract6)) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "not(extract('CA10__encrypted__c'))", currentStateMessage: "The attached EBS volume is not encrypted.", currentStateReferences: references1.join('\n'), remediation: "Enable encryption for the volume.", runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract9() { if (!this.out) { this.out = obj.CA10__encrypted__c; } return this.out; }; if (extract9.call(extract9) == true) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__encrypted__c') == true", currentStateMessage: "The attached EBS volume is encrypted.", 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__status__c AS CA10__status__c, sObject.CA10__encrypted__c AS CA10__encrypted__c, sObject.Id AS Id, process_CA10__CaAwsVolume__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__encrypted__c AS CA10__encrypted__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsVolume__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;