--- policy: /ce/ca/azure/sql-database/disable-server-public-network-access logic: /ce/ca/azure/sql-database/disable-server-public-network-access/prod.logic.yaml executionTime: 2026-02-10T22:33:36.166685275Z generationMs: 59 executionMs: 1168 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__publicNetworkAccess__c') == 'Enabled' actual: extract('CA10__publicNetworkAccess__c') == 'Enabled' runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__publicNetworkAccess__c') == 'Disabled' actual: extract('CA10__publicNetworkAccess__c') == 'Disabled' runtimeError: {} - id: test4 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/azure/sql-database/disable-server-public-network-access/policy.yaml md5Hash: 98387BD9EA395CEC3660B357E59B9C60 content: "---\nnames:\n full: Azure SQL Server Public Network Access is not disabled\n\ \ contextual: Server Public Network Access is not disabled\ndescription: Public\ \ Network Access tends to be overly permissive and introduces unintended vectors\ \ for \n threat activity.\ntype: COMPLIANCE_POLICY\ncategories:\n - SECURITY\n\ frameworkMappings:\n - \"/frameworks/cis-azure-v3.0.0/05/01/07\"\n - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\ \nsimilarPolicies:\n internal:\n - dec-x-4f30f24e" - path: /ce/ca/azure/sql-database/disable-server-public-network-access/prod.logic.yaml md5Hash: 53D5B0C2990BA2FE18D5CE7AF226F666 content: | --- inputType: "CA10__CaAzureSqlServer__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAzureSqlServer__c/object.extracts.yaml" conditions: - status: "INCOMPLIANT" currentStateMessage: "SQL Server public network access is enabled." remediationMessage: "Disable SQL Server public network access." check: IS_EQUAL: left: EXTRACT: "CA10__publicNetworkAccess__c" right: TEXT: "Enabled" - status: "COMPLIANT" currentStateMessage: "SQL Server public network access is disabled." check: IS_EQUAL: left: EXTRACT: "CA10__publicNetworkAccess__c" right: TEXT: "Disabled" otherwise: status: "UNDETERMINED" currentStateMessage: "Unable to determine public network access." - path: /ce/ca/azure/sql-database/disable-server-public-network-access/test-data.json md5Hash: 0CA7F2993BBCC898B1A1EDF651D9EAF1 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-06-12T19:31:46Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2024-06-12T19:31:46Z", "CA10__publicNetworkAccess__c": "Enabled" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10__publicNetworkAccess__c') == 'Enabled'", "runtimeError": null }, "context": { "snapshotTime": "2024-06-12T19:31:46Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__publicNetworkAccess__c": "Enabled" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__publicNetworkAccess__c') == 'Disabled'", "runtimeError": null }, "context": { "snapshotTime": "2024-06-12T19:31:46Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__publicNetworkAccess__c": "Disabled" }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-06-12T19:31:46Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__publicNetworkAccess__c": "" } ] - path: /types/CA10__CaAzureSqlServer__c/object.extracts.yaml md5Hash: C096245468858A9F41067AD8FA5D8D0E content: "---\nextracts:\n# Values: Enabled, Disabled. Not Nullable.\n - name:\ \ \"CA10__auditing__c\"\n value: \n FIELD:\n path: \"CA10__auditing__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__auditing__c\"\n currentStateMessage: \"Unable to determine\ \ Server auditing settings. Possible permission issue with Microsoft.Sql/servers/auditingSettings/read\"\ \n isEmpty: \"SQL Server auditing settings are not populated yet\"\n\ # Number field\n - name: \"CA10__auditingRetentionDays__c\"\n value: \n\ \ FIELD:\n path: \"CA10__auditingRetentionDays__c\"\n undeterminedIf:\n\ \ noAccessDelegate:\n path: \"CA10__auditingRetentionDays__c\"\ \n currentStateMessage: \"Unable to determine Server auditing settings.\ \ Possible permission issue with Microsoft.Sql/servers/auditingSettings/read\"\ \n# Values: servicemanaged, azurekeyvault. Not Nullable. \n - name: \"CA10__encryptionProtectorKind__c\"\ \n value: \n FIELD:\n path: \"CA10__encryptionProtectorKind__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__encryptionProtectorKind__c\"\n currentStateMessage: \"Unable\ \ to determine Server Encryption Protectors. Possible permission issue with\ \ Microsoft.Sql/servers/encryptionProtector/read\"\n isEmpty: \"SQL\ \ Server Encryption Protectors are not populated yet\"\n# Values: ServiceManaged,\ \ AzureKeyVault. Not Nullable. \n - name: \"CA10__encryptionProtectorServerKeyType__c\"\ \n value: \n FIELD:\n path: \"CA10__encryptionProtectorServerKeyType__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__encryptionProtectorServerKeyType__c\"\n currentStateMessage:\ \ \"Unable to determine Server Encryption Protectors. Possible permission issue\ \ with Microsoft.Sql/servers/encryptionProtector/read\"\n isEmpty:\ \ \"SQL Server Encryption Protectors are not populated yet\"\n# Nullable. \n\ \ - name: \"CA10__encryptionProtectorUri__c\"\n value: \n FIELD:\n\ \ path: \"CA10__encryptionProtectorUri__c\"\n undeterminedIf:\n\ \ noAccessDelegate:\n path: \"CA10__encryptionProtectorUri__c\"\ \n currentStateMessage: \"Unable to determine Server Encryption Protectors.\ \ Possible permission issue with Microsoft.Sql/servers/encryptionProtector/read\"\ \n# Values: ActiveDirectory, null. Nullable. \n - name: \"CA10__activeDirectoryAdminType__c\"\ \n value: \n FIELD:\n path: \"CA10__activeDirectoryAdminType__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__activeDirectoryAdminType__c\"\n currentStateMessage: \"Unable\ \ to determine Server AD Administrator type. Possible permission issue with\ \ Microsoft.Sql/servers/administrators\"\n - name: \"CA10__firewallRulesJson__c\"\ \n value: \n FIELD:\n path: \"CA10__firewallRulesJson__c\"\n\ \ returnType: BYTES\n undeterminedIf:\n noAccessDelegate:\n\ \ path: \"CA10__firewallRulesJson__c\"\n currentStateMessage:\ \ \"Unable to determine Firewall Rules. Possible permission issue with Microsoft.Sql/servers/firewallRules/read\"\ \n - name: \"caJsonFrom__firewallRulesJson__c\"\n value: \n JSON_FROM:\n\ \ arg: \n EXTRACT: \"CA10__firewallRulesJson__c\"\n undeterminedIf:\n\ \ isInvalid: \"Firewall Rules JSON is invalid.\"\n# Nullable. Values:\ \ Enabled, Disabled, Can't have no access, retrieved via Microsoft.Sql/servers\n\ \ - name: \"CA10__publicNetworkAccess__c\"\n value: \n FIELD:\n \ \ path: \"CA10__publicNetworkAccess__c\"\n# Text\n - name: \"CA10__locationName__c\"\ \n value: \n FIELD:\n path: \"CA10__locationName__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__publicNetworkAccess__c') == 'Enabled'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__publicNetworkAccess__c') == 'Disabled'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureSqlServer__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-06-12T19:31:46Z") }, "CA10__disappearanceTime__c" : new Date("2024-06-12T19:31:46Z"), "CA10__publicNetworkAccess__c" : "Enabled", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2024-06-12T19:31:46Z") }, "CA10__publicNetworkAccess__c" : "Enabled", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2024-06-12T19:31:46Z") }, "CA10__publicNetworkAccess__c" : "Disabled", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2024-06-12T19:31:46Z") }, "CA10__publicNetworkAccess__c" : "", "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureSqlServer__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__publicNetworkAccess__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 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] function extract3() { if (!this.out) { this.out = obj.CA10__publicNetworkAccess__c; } return this.out; }; references1.push('Public Network Access [obj.CA10__publicNetworkAccess__c]: ' + obj.CA10__publicNetworkAccess__c); if (TextLib.equal(extract3.call(extract3), 'Enabled')) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__publicNetworkAccess__c') == 'Enabled'", currentStateMessage: "SQL Server public network access is enabled.", currentStateReferences: references1.join('\n'), remediation: "Disable SQL Server public network access.", runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__publicNetworkAccess__c; } return this.out; }; if (TextLib.equal(extract6.call(extract6), 'Disabled')) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__publicNetworkAccess__c') == 'Disabled'", currentStateMessage: "SQL Server public network access is disabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unable to determine public network access.", 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__publicNetworkAccess__c AS CA10__publicNetworkAccess__c, sObject.Id AS Id, process_CA10__CaAzureSqlServer__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__publicNetworkAccess__c AS CA10__publicNetworkAccess__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureSqlServer__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;