--- policy: /ce/ca/azure/monitor/diagnostic-setting-categories logic: /ce/ca/azure/monitor/diagnostic-setting-categories/prod.logic.yaml executionTime: 2026-02-10T22:33:31.537911131Z generationMs: 77 executionMs: 827 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: RecordType.DeveloperName != 'caDiagnosticSettingOnAzureSubscription' actual: RecordType.DeveloperName != 'caDiagnosticSettingOnAzureSubscription' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category\ \ == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Security`].enabled | [0]'))" actual: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category ==\ \ `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Security`].enabled | [0]'))" runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test5 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category\ \ == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Security`].enabled | [0]'))" actual: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category ==\ \ `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[?\ \ category == `Security`].enabled | [0]'))" runtimeError: {} usedFiles: - path: /ce/ca/azure/monitor/diagnostic-setting-categories/policy.yaml md5Hash: 6717D14002CB25FB546A0C4007911D02 content: | --- names: full: "Azure Diagnostic Setting captures Administrative, Alert, Policy, and Security\ \ categories" contextual: "Diagnostic Setting captures Administrative, Alert, Policy, and Security\ \ categories" description: The diagnostic setting should be configured to log the appropriate activities from the control/management plane. type: COMPLIANCE_POLICY categories: - SECURITY - RELIABILITY frameworkMappings: - "/frameworks/cis-azure-v5.0.0/06/01/01/02" - "/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration" similarPolicies: internal: - dec-x-a193b20f - path: /ce/ca/azure/monitor/diagnostic-setting-categories/prod.logic.yaml md5Hash: 6BC88D251A51C85B2990D5B8B7C098D4 content: "inputType: \"CA10__CaAzureDiagnosticSetting__c\"\nimportExtracts:\n\ \ - file: \"/types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml\"\ \ntestData:\n - file: \"test-data.json\"\nconditions:\n - status: \"INAPPLICABLE\"\ \n currentStateMessage: \"This is not a subscription diagnostic setting.\"\ \n check:\n NOT_EQUAL:\n left:\n FIELD: \n \ \ path: \"RecordType.DeveloperName\"\n right:\n TEXT: \"caDiagnosticSettingOnAzureSubscription\"\ \n - status: \"INCOMPLIANT\"\n currentStateMessage: \"The diagnostic setting\ \ does not capture the appropriate activities from the management plane.\"\n\ \ remediationMessage: \"Capture the Administrative, Alert, Policy, and Security\ \ log categories in the diagnostic setting.\"\n check:\n NOT:\n \ \ arg:\n AND:\n args:\n - JSON_QUERY_BOOLEAN:\n\ \ arg: \n EXTRACT: \"caJsonFrom__logsJson__c\"\ \n expression: \"[? category == `Administrative`].enabled |\ \ [0]\"\n undeterminedIf: \n evaluationError:\ \ \"The JSON query has failed.\"\n resultTypeMismatch: \"\ The JSON query did not return boolean type.\"\n - JSON_QUERY_BOOLEAN:\n\ \ arg: \n EXTRACT: \"caJsonFrom__logsJson__c\"\ \n expression: \"[? category == `Alert`].enabled | [0]\"\n\ \ undeterminedIf: \n evaluationError: \"\ The JSON query has failed.\"\n resultTypeMismatch: \"The\ \ JSON query did not return boolean type.\"\n - JSON_QUERY_BOOLEAN:\n\ \ arg: \n EXTRACT: \"caJsonFrom__logsJson__c\"\ \n expression: \"[? category == `Policy`].enabled | [0]\"\n\ \ undeterminedIf: \n evaluationError: \"\ The JSON query has failed.\"\n resultTypeMismatch: \"The\ \ JSON query did not return boolean type.\"\n - JSON_QUERY_BOOLEAN:\n\ \ arg: \n EXTRACT: \"caJsonFrom__logsJson__c\"\ \n expression: \"[? category == `Security`].enabled | [0]\"\ \n undeterminedIf: \n evaluationError: \"\ The JSON query has failed.\"\n resultTypeMismatch: \"The\ \ JSON query did not return boolean type.\"\notherwise:\n status: \"COMPLIANT\"\ \n currentStateMessage: \"The diagnostic setting captures the appropriate activities\ \ from the management plane.\"\n" - path: /ce/ca/azure/monitor/diagnostic-setting-categories/test-data.json md5Hash: 7C5C255C035DF0312BE934B2B2729D36 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-05-29T03:06:28Z" }, "Id": "test1", "RecordTypeId": "RecordTypeId1", "CA10__disappearanceTime__c": "2024-05-28T19:31:51Z", "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "RecordTypeId1" }, "CA10__logsJson__c": "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "RecordType.DeveloperName != 'caDiagnosticSettingOnAzureSubscription'", "runtimeError": null }, "context": { "snapshotTime": "2024-05-29T03:06:28Z" }, "Id": "test2", "RecordTypeId": "RecordTypeId2", "CA10__disappearanceTime__c": null, "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureResource", "Id": "RecordTypeId2" }, "CA10__logsJson__c": "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]'))", "runtimeError": null }, "context": { "snapshotTime": "2024-05-29T03:06:28Z" }, "Id": "test3", "RecordTypeId": "RecordTypeId3", "CA10__disappearanceTime__c": null, "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "RecordTypeId3" }, "CA10__logsJson__c": "[{\"category\": \"Security\",\"enabled\": false},{\"category\": \"Alert\",\"enabled\": false},{\"category\": \"Administrative\",\"enabled\": false},{\"category\": \"Policy\",\"enabled\": false}]" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-05-29T03:06:28Z" }, "Id": "test4", "RecordTypeId": "RecordTypeId4", "CA10__disappearanceTime__c": null, "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "RecordTypeId4" }, "CA10__logsJson__c": "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]'))", "runtimeError": null }, "context": { "snapshotTime": "2024-05-29T03:06:28Z" }, "Id": "test5", "RecordTypeId": "RecordTypeId5", "CA10__disappearanceTime__c": null, "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "RecordTypeId5" }, "CA10__logsJson__c": "[{\"category\": \"Security\",\"enabled\": false},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]" } ] - path: /types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml md5Hash: 4AADFEBE59E43127A2529B2F0DB31297 content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\ \ Microsoft.Insights/diagnosticSettings/read\n - name: \"CA10__logsJson__c\"\ \n value: \n FIELD:\n path: \"CA10__logsJson__c\"\n returnType:\ \ BYTES\n undeterminedIf:\n isEmpty: \"Corrupted Data. Diagnostic\ \ Setting Logs JSON cannot be empty.\"\n - name: \"caJsonFrom__logsJson__c\"\ \n value: \n JSON_FROM:\n arg: \n EXTRACT: \"CA10__logsJson__c\"\ \n undeterminedIf:\n isInvalid: \"Logs JSON is invalid.\"\n\ # Nullable. Azure Log Analytics workspace\n - name: \"CA10__workspaceId__c\"\ \n value: \n FIELD:\n path: \"CA10__workspaceId__c\"\n# Nullable.\ \ Azure Storage Account\n - name: \"CA10__storageAccountId__c\"\n value:\ \ \n FIELD:\n path: \"CA10__storageAccountId__c\"\n# Nullable. Azure\ \ Event Hubs\n - name: \"CA10__eventHubAuthorizationRuleId__c\"\n value:\ \ \n FIELD:\n path: \"CA10__eventHubAuthorizationRuleId__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" : "RecordType.DeveloperName != 'caDiagnosticSettingOnAzureSubscription'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]'))", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]'))", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureDiagnosticSetting__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "CA10__disappearanceTime__c" : new Date("2024-05-28T19:31:51Z"), "CA10__logsJson__c" : "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]", "Id" : "test1", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "CA10__logsJson__c" : "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]", "Id" : "test2", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "CA10__logsJson__c" : "[{\"category\": \"Security\",\"enabled\": false},{\"category\": \"Alert\",\"enabled\": false},{\"category\": \"Administrative\",\"enabled\": false},{\"category\": \"Policy\",\"enabled\": false}]", "Id" : "test3", "RecordTypeId" : "RecordTypeId3" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "CA10__logsJson__c" : "[{\"category\": \"Security\",\"enabled\": true},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]", "Id" : "test4", "RecordTypeId" : "RecordTypeId4" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "CA10__logsJson__c" : "[{\"category\": \"Security\",\"enabled\": false},{\"category\": \"Alert\",\"enabled\": true},{\"category\": \"Administrative\",\"enabled\": true},{\"category\": \"Policy\",\"enabled\": true}]", "Id" : "test5", "RecordTypeId" : "RecordTypeId5" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureSubscription", "Id" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureResource", "Id" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureSubscription", "Id" : "RecordTypeId3" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureSubscription", "Id" : "RecordTypeId4" }, { "context" : { "snapshotTime" : new Date("2024-05-29T03:06:28Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureSubscription", "Id" : "RecordTypeId5" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureDiagnosticSetting__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__logsJson__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< DeveloperName STRING, Id STRING > >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 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 Azure [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 (TextLib.notEqual(obj.RecordType.DeveloperName, 'caDiagnosticSettingOnAzureSubscription')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "RecordType.DeveloperName != 'caDiagnosticSettingOnAzureSubscription'", currentStateMessage: "This is not a subscription diagnostic setting.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function jsonQueryChecked3() { var input = extract5.call(extract5); var out; try { out = jmespath.search(input, '[? category == `Administrative`].enabled | [0]'); if (out != null && typeof out != 'boolean') { throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked6() { var input = extract8.call(extract8); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('CA10__logsJson__c').asJson().isInvalid()", currentStateMessage: "Logs JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked9() { if (BytesLib.isEmpty(obj.CA10__logsJson__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__logsJson__c.isEmpty()", currentStateMessage: "Corrupted Data. Diagnostic Setting Logs JSON cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__logsJson__c; } function extract8() { if (!this.out) { this.out = fieldChecked9(); } return this.out; }; function extract5() { if (!this.out) { this.out = jsonChecked6(); } return this.out; }; function jsonQueryChecked10() { var input = extract5.call(extract5); var out; try { out = jmespath.search(input, '[? category == `Alert`].enabled | [0]'); if (out != null && typeof out != 'boolean') { throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:206", {cause: {status: 'UNDETERMINED', conditionIndex: 206, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonQueryChecked12() { var input = extract5.call(extract5); var out; try { out = jmespath.search(input, '[? category == `Policy`].enabled | [0]'); if (out != null && typeof out != 'boolean') { throw new Error("UNDETERMINED condition:207", {cause: {status: 'UNDETERMINED', conditionIndex: 207, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:208", {cause: {status: 'UNDETERMINED', conditionIndex: 208, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonQueryChecked14() { var input = extract5.call(extract5); var out; try { out = jmespath.search(input, '[? category == `Security`].enabled | [0]'); if (out != null && typeof out != 'boolean') { throw new Error("UNDETERMINED condition:209", {cause: {status: 'UNDETERMINED', conditionIndex: 209, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:210", {cause: {status: 'UNDETERMINED', conditionIndex: 210, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } references1.push('Logs JSON [obj.CA10__logsJson__c]: ' + obj.CA10__logsJson__c); try { if (!(jsonQueryChecked3() && jsonQueryChecked10() && jsonQueryChecked12() && jsonQueryChecked14())) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Administrative`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Alert`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Policy`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `Security`].enabled | [0]'))", currentStateMessage: "The diagnostic setting does not capture the appropriate activities from the management plane.", currentStateReferences: references1.join('\n'), remediation: "Capture the Administrative, Alert, Policy, and Security log categories in the diagnostic setting.", 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 diagnostic setting captures the appropriate activities from the management plane.", 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__logsJson__c AS CA10__logsJson__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, process_CA10__CaAzureDiagnosticSetting__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__logsJson__c AS CA10__logsJson__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureDiagnosticSetting__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id ) sObject ON sObject.Id = expectedResult.Id;