--- policy: /ce/ca/aws/cloudfront/distribution-waf-integration logic: /ce/ca/aws/cloudfront/distribution-waf-integration/prod.logic.yaml executionTime: 2026-06-06T12:02:34.451578801Z generationMs: 60 executionMs: 1327 rows: - id: test1 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: isEmptyLookup('CA10__wafV2WebAcl__r') && isEmptyLookup('CA10__webAcl__r') actual: isEmptyLookup('CA10__wafV2WebAcl__r') && isEmptyLookup('CA10__webAcl__r') runtimeError: {} - id: test2 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/cloudfront/distribution-waf-integration/policy.yaml md5Hash: 64153C0F853B5C368847E1C2F2DB2435 content: "---\nnames:\n full: \"AWS CloudFront Web Distribution is not integrated\ \ with AWS WAF\"\n contextual: \"Web Distribution is not integrated with AWS\ \ WAF\"\ndescription: >\n Ensure that AWS CloudFront Web Distributions are\ \ integrated with AWS WAF (Web Application Firewall). \n AWS WAF helps protect\ \ your web applications from common web exploits that could \n affect application\ \ availability, compromise security, or consume excessive resources.\ncategories:\n\ \ - \"SECURITY\"\ntype: \"BEST_PRACTICE\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/threat-protection\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/cloudfront/06\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[CloudFront.6] CloudFront distributions should have WAF enabled\"\ \n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/cloudfront-controls.html#cloudfront-6\"\ \n cloudConformity:\n - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/CloudFront/cloudfront-integrated-with-waf.html\n\ \ name: CloudFront Integrated With WAF\n" - path: /ce/ca/aws/cloudfront/distribution-waf-integration/prod.logic.yaml md5Hash: 72E479784144E46D7BD01BA1FAED5008 content: "---\ninputType: \"CA10__CaAwsDistribution__c\"\ntestData:\n - file:\ \ \"test-data.json\" \nrecordTypes:\n - \"caWebDistribution\"\nconditions:\n\ \ - status: \"INCOMPLIANT\"\n currentStateMessage: \"The CloudFront web\ \ distribution isn't integrated with either AWS WAF Classic or AWS WAF web ACLs.\"\ \n remediationMessage: \"Associate a WAF web ACL with the CloudFront distribution.\"\ \n check:\n AND:\n args:\n - IS_EMPTY_LOOKUP: \"CA10__wafV2WebAcl__r\"\ \n - IS_EMPTY_LOOKUP: \"CA10__webAcl__r\"\notherwise:\n status: \"\ COMPLIANT\"\n currentStateMessage: \"The CloudFront distribution is integrated\ \ with AWS WAF.\"\n" - path: /ce/ca/aws/cloudfront/distribution-waf-integration/test-data.json md5Hash: C3C63DB635EAE7B45C0D7F0974613A0B content: |- [ { "RecordType": { "Id": "RecordType1", "DeveloperName": "caWebDistribution" }, "expectedResult": { "runtimeError": null, "conditionText": "isEmptyLookup('CA10__wafV2WebAcl__r') && isEmptyLookup('CA10__webAcl__r')", "conditionIndex": 299, "status": "INCOMPLIANT" }, "CA10__webAcl__r": { "Id": null, "CA10__disappearanceTime__c": null }, "context": { "snapshotTime": "2026-01-23T14:00:42Z" }, "RecordTypeId": "RecordType1", "CA10__webAcl__c": "", "CA10__wafV2WebAclArn__c": "", "CA10__webAacId__c": "", "Id": "test1", "CA10__disappearanceTime__c": null, "CA10__wafV2WebAcl__c": "", "CA10__wafV2WebAcl__r": { "Id": null, "CA10__disappearanceTime__c": null } }, { "RecordType": { "Id": "RecordType1", "DeveloperName": "caWebDistribution" }, "expectedResult": { "runtimeError": null, "conditionText": "otherwise", "conditionIndex": 300, "status": "COMPLIANT" }, "CA10__webAcl__r": { "Id": null, "CA10__disappearanceTime__c": null }, "context": { "snapshotTime": "2026-01-23T14:00:42Z" }, "RecordTypeId": "RecordType1", "CA10__webAcl__c": "", "CA10__wafV2WebAclArn__c": "wafV2WebAclArn", "CA10__webAacId__c": "", "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__wafV2WebAcl__c": "test2_1", "CA10__wafV2WebAcl__r": { "Id": "test2_1", "CA10__disappearanceTime__c": null } }, { "RecordType": { "Id": "RecordType1", "DeveloperName": "caWebDistribution" }, "expectedResult": { "runtimeError": null, "conditionText": "otherwise", "conditionIndex": 300, "status": "COMPLIANT" }, "CA10__webAcl__r": { "Id": "test3_1", "CA10__disappearanceTime__c": null }, "context": { "snapshotTime": "2026-01-23T14:00:42Z" }, "RecordTypeId": "RecordType1", "CA10__webAcl__c": "test3_1", "CA10__wafV2WebAclArn__c": "", "CA10__webAacId__c": "webAacId", "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__wafV2WebAcl__c": "", "CA10__wafV2WebAcl__r": { "Id": null, "CA10__disappearanceTime__c": null } } ] script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "runtimeError" : null, "conditionText" : "isEmptyLookup('CA10__wafV2WebAcl__r') && isEmptyLookup('CA10__webAcl__r')", "conditionIndex" : 299, "status" : "INCOMPLIANT" } }, { "Id" : "test2", "expectedResult" : { "runtimeError" : null, "conditionText" : "otherwise", "conditionIndex" : 300, "status" : "COMPLIANT" } }, { "Id" : "test3", "expectedResult" : { "runtimeError" : null, "conditionText" : "otherwise", "conditionIndex" : 300, "status" : "COMPLIANT" } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsDistribution__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "CA10__wafV2WebAcl__c" : "", "CA10__wafV2WebAclArn__c" : "", "CA10__webAcl__c" : "", "CA10__webAacId__c" : "", "Id" : "test1", "RecordTypeId" : "RecordType1" }, { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "CA10__wafV2WebAcl__c" : "test2_1", "CA10__wafV2WebAclArn__c" : "wafV2WebAclArn", "CA10__webAcl__c" : "", "CA10__webAacId__c" : "", "Id" : "test2", "RecordTypeId" : "RecordType1" }, { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "CA10__wafV2WebAcl__c" : "", "CA10__wafV2WebAclArn__c" : "", "CA10__webAcl__c" : "test3_1", "CA10__webAacId__c" : "webAacId", "Id" : "test3", "RecordTypeId" : "RecordType1" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "DeveloperName" : "caWebDistribution", "Id" : "RecordType1" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsWafWebAcl__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "Id" : null }, { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "Id" : "test2_1" }, { "context" : { "snapshotTime" : new Date("2026-01-23T14:00:42Z") }, "Id" : "test3_1" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsDistribution__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, RecordType STRUCT< DeveloperName STRING, Id STRING >, CA10__wafV2WebAcl__r STRUCT< Id STRING, CA10__disappearanceTime__c TIMESTAMP >, CA10__wafV2WebAcl__c STRING, CA10__wafV2WebAclArn__c STRING, CA10__webAcl__r STRUCT< Id STRING, CA10__disappearanceTime__c TIMESTAMP >, CA10__webAcl__c STRING, CA10__webAacId__c STRING, Id STRING, RecordTypeId STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var BytesLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg; }; 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 CollectionLib = new function () { this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) { if (arg == null) return []; let parts = arg.split(separator); return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize); }; this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) { if (arr == null) return []; let result = []; let seen = new Set(); arr.forEach(el => { let normalized = normalize ? TextLib.normalize(el) : BytesLib.normalize(el); if (!skipEmpty || (normalize ? TextLib.isNotEmpty(el) : BytesLib.isNotEmpty(el))) { if (!skipDuplicates || !seen.has(normalized)) { if (skipDuplicates) seen.add(normalized); result.push(normalized); } } }); if (sort) result.sort(); return result; }; this.equal = function(left, right) { left = left == null ? [] : left; right = right == null ? [] : right; if (left.length !== right.length) return false; for (let i = 0; i < left.length; i++) { if (left[i] !== right[i]) return false; } return true; }; this.notEqual = function(left, right) { return !this.equal(left, right); }; this.size = function(collection) { return collection == null ? 0 : collection.length; }; this.startsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[0] === normalizedSearch; }; this.endsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[collection.length - 1] === normalizedSearch; }; this.contains = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; return collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)); }; this.containsAll = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.every(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; this.containsAny = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.some(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; }(); 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] references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName); if (!CollectionLib.contains(CollectionLib.fromArray(['caWebDistribution'], true, true, true, true), obj.RecordType.DeveloperName, true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['caWebDistribution']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] if ((TextLib.isEmpty(obj.CA10__wafV2WebAclArn__c) || TextLib.isEmpty(obj.CA10__wafV2WebAcl__c) || obj.CA10__wafV2WebAcl__r.CA10__disappearanceTime__c != null) && (TextLib.isEmpty(obj.CA10__webAacId__c) || TextLib.isEmpty(obj.CA10__webAcl__c) || obj.CA10__webAcl__r.CA10__disappearanceTime__c != null)) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "isEmptyLookup('CA10__wafV2WebAcl__r') && isEmptyLookup('CA10__webAcl__r')", currentStateMessage: "The CloudFront web distribution isn't integrated with either AWS WAF Classic or AWS WAF web ACLs.", currentStateReferences: references1.join('\n'), remediation: "Associate a WAF web ACL with the CloudFront distribution.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The CloudFront distribution is integrated with AWS WAF.", 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, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, STRUCT ( `CA10__wafV2WebAcl__r`.Id AS Id, `CA10__wafV2WebAcl__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__wafV2WebAcl__r, sObject.CA10__wafV2WebAcl__c AS CA10__wafV2WebAcl__c, sObject.CA10__wafV2WebAclArn__c AS CA10__wafV2WebAclArn__c, STRUCT ( `CA10__webAcl__r`.Id AS Id, `CA10__webAcl__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__webAcl__r, sObject.CA10__webAcl__c AS CA10__webAcl__c, sObject.CA10__webAacId__c AS CA10__webAacId__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, process_CA10__CaAwsDistribution__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, STRUCT ( `CA10__wafV2WebAcl__r`.Id AS Id, `CA10__wafV2WebAcl__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__wafV2WebAcl__r, sObject.CA10__wafV2WebAcl__c AS CA10__wafV2WebAcl__c, sObject.CA10__wafV2WebAclArn__c AS CA10__wafV2WebAclArn__c, STRUCT ( `CA10__webAcl__r`.Id AS Id, `CA10__webAcl__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c ) AS CA10__webAcl__r, sObject.CA10__webAcl__c AS CA10__webAcl__c, sObject.CA10__webAacId__c AS CA10__webAacId__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsDistribution__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id LEFT JOIN UNNEST(mock_CA10__CaAwsWafWebAcl__c()) AS `CA10__wafV2WebAcl__r` ON sObject.CA10__wafV2WebAcl__c = `CA10__wafV2WebAcl__r`.Id LEFT JOIN UNNEST(mock_CA10__CaAwsWafWebAcl__c()) AS `CA10__webAcl__r` ON sObject.CA10__webAcl__c = `CA10__webAcl__r`.Id ) sObject ON sObject.Id = expectedResult.Id;