---
policy: /ce/ca/azure/databricks/customer-managed-virtual-network
logic: /ce/ca/azure/databricks/customer-managed-virtual-network/prod.logic.yaml
executionTime: 2025-07-21T17:37:23.298559827Z
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10Z1__disappearanceTime__c)
      actual: isDisappeared(CA10Z1__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
      actual: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
      actual: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
      actual: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isNotEmpty()
      actual: extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isNotEmpty()
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/databricks/customer-managed-virtual-network/policy.yaml
    md5Hash: 99F0728712C9E23B96E3DF0394288B8B
    content: "---\nnames:\n  full: Azure Databricks Workspace is not deployed in a\
      \ customer-managed virtual network (VNet)\n  contextual: Workspace is not deployed\
      \ in a customer-managed virtual network (VNet)\ndescription: >\n  Deploy Azure\
      \ Databricks Workspaces using customer-managed Virtual Network \n  injection\
      \ so that compute clusters and control-plane components reside securely \n \
      \ within your organization's network perimeter. The default Databricks-managed\
      \ \n  VNet offers only limited control over network security policies, firewall\
      \ \n  configurations and routing.\ntype: COMPLIANCE_POLICY\ncategories:\n  -\
      \ SECURITY\nframeworkMappings:\n  - \"/frameworks/cis-azure-v4.0.0/03/01/01\"\
      \n  - \"/frameworks/cloudaware/resource-security/threat-protection\"\n"
  - path: /ce/ca/azure/databricks/customer-managed-virtual-network/prod.logic.yaml
    md5Hash: 05D8CFF1B6F4E5B6B424091D77FD9E42
    content: |
      ---
      inputType: "CA10Z1__CaAzureDatabricksWorkspace__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10Z1__CaAzureDatabricksWorkspace__c/object.extracts.yaml"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "The Databricks Workspace is not deployed in a customer-managed virtual network."
          remediationMessage: "Consider deleting the existing Databricks workspace and\
            \ deploying a new Azure Databricks Workspace in a custom virtual network."
          check:
            IS_EMPTY:
              arg:
                EXTRACT: "caJsonText__parametersJsonCustomVirtualNetworkValue__c"
        - status: "COMPLIANT"
          currentStateMessage: "The Databricks Workspace is deployed in a customer-managed virtual network."
          check:
            NOT_EMPTY:
              arg:
                EXTRACT: "caJsonText__parametersJsonCustomVirtualNetworkValue__c"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected value in the field."
  - path: /ce/ca/azure/databricks/customer-managed-virtual-network/test-data.json
    md5Hash: 2C838A9C6E91A402ADCED8CF48344C05
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10Z1__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-11T04:12:25Z" },
          "Id": "001",
          "CA10Z1__disappearanceTime__c": "2025-07-02T14:15:13Z",
          "CA10Z1__parametersJson__c": "null"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-11T04:12:25Z" },
          "Id": "002",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__parametersJson__c": "null"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-11T04:12:25Z" },
          "Id": "003",
          "CA10Z1__disappearanceTime__c": null,
         "CA10Z1__parametersJson__c": "{\"customVirtualNetworkId\":{\"type\":\"STRING\",\"value\":\"\"},\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-11T04:12:25Z" },
          "Id": "004",
          "CA10Z1__disappearanceTime__c": null,
         "CA10Z1__parametersJson__c": "{\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isNotEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-11T04:12:25Z" },
          "Id": "005",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__parametersJson__c": "{\"customVirtualNetworkId\":{\"type\":\"STRING\",\"value\":\"/subscriptions/8064/resourceGroups/AZ-Network/providers/Microsoft.Network/virtualNetworks/AZ-prd\"},\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
        }
      ]
  - path: /types/CA10Z1__CaAzureDatabricksWorkspace__c/object.extracts.yaml
    md5Hash: 386013C014351948A2036C32C9D43AB2
    content: "---\n# Nullable. The encryption keySource (provider). Possible values\
      \ (case-insensitive):  Microsoft.Keyvault\nextracts:\n  - name: \"CA10Z1__encryptionManagedDisksKeySource__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__encryptionManagedDisksKeySource__c\"\
      \n  - name: \"CA10Z1__parametersJson__c\"\n    value:\n      FIELD:\n      \
      \  path: \"CA10Z1__parametersJson__c\"\n        returnType: BYTES\n  - name:\
      \ \"caJsonFrom__parametersJson__c\"\n    value:\n      JSON_FROM:\n        arg:\n\
      \          EXTRACT: \"CA10Z1__parametersJson__c\"\n        undeterminedIf:\n\
      \          isInvalid: \"DatabricsWorkspace parameters JSON is invalid\"\n\n\
      \  - name: \"caJsonText__parametersJsonCustomVirtualNetworkValue__c\"\n    value:\
      \ \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"caJsonFrom__parametersJson__c\"\
      \n        expression: \"customVirtualNetworkId.value\"\n        undeterminedIf:\
      \ \n          evaluationError: \"The JSON query has failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return a boolean.\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10Z1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isNotEmpty()",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureDatabricksWorkspace__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__parametersJson__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-11T04:12:25Z")
    },
    "Id" : "001",
    "CA10Z1__disappearanceTime__c" : new Date("2025-07-02T14:15:13Z"),
    "CA10Z1__parametersJson__c" : "null"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-11T04:12:25Z")
    },
    "Id" : "002",
    "CA10Z1__parametersJson__c" : "null"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-11T04:12:25Z")
    },
    "Id" : "003",
    "CA10Z1__parametersJson__c" : "{\"customVirtualNetworkId\":{\"type\":\"STRING\",\"value\":\"\"},\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-11T04:12:25Z")
    },
    "Id" : "004",
    "CA10Z1__parametersJson__c" : "{\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-11T04:12:25Z")
    },
    "Id" : "005",
    "CA10Z1__parametersJson__c" : "{\"customVirtualNetworkId\":{\"type\":\"STRING\",\"value\":\"/subscriptions/8064/resourceGroups/AZ-Network/providers/Microsoft.Network/virtualNetworks/AZ-prd\"},\"customPublicSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"customPrivateSubnetName\":{\"type\":\"STRING\",\"value\":\"Consumer-SN\"},\"enableNoPublicIp\":{\"type\":\"BOOL\",\"value\":false}}"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureDatabricksWorkspace__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__parametersJson__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function jsonQueryChecked4() {
          var input = extract6.call(extract6);
          var out;
          try {
              out = jmespath.search(input, 'customVirtualNetworkId.value');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "extract('caJsonFrom__parametersJson__c').jsonQueryText('customVirtualNetworkId.value').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a boolean.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "extract('caJsonFrom__parametersJson__c').jsonQueryText('customVirtualNetworkId.value').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked7() {
          var input = extract9.call(extract9);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "extract('CA10Z1__parametersJson__c').asJson().isInvalid()", currentStateMessage: "DatabricsWorkspace parameters JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract9() { if (!this.out) { this.out = obj.CA10Z1__parametersJson__c; } return this.out; };
      function extract6() { if (!this.out) { this.out = jsonChecked7(); } return this.out; };
      function extract3() { if (!this.out) { this.out = jsonQueryChecked4(); } return this.out; };
      references1.push('Parameters JSON [obj.CA10Z1__parametersJson__c]: ' + obj.CA10Z1__parametersJson__c);
      try {
          if (TextLib.isEmpty(extract3.call(extract3))) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isEmpty()", currentStateMessage: "The Databricks Workspace is not deployed in a customer-managed virtual network.", currentStateReferences: references1.join('\n'), remediation: "Consider deleting the existing Databricks workspace and deploying a new Azure Databricks Workspace in a custom virtual network.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked13() {
          var input = extract15.call(extract15);
          var out;
          try {
              out = jmespath.search(input, 'customVirtualNetworkId.value');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('caJsonFrom__parametersJson__c').jsonQueryText('customVirtualNetworkId.value').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a boolean.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom__parametersJson__c').jsonQueryText('customVirtualNetworkId.value').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked16() {
          var input = extract18.call(extract18);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extract('CA10Z1__parametersJson__c').asJson().isInvalid()", currentStateMessage: "DatabricsWorkspace parameters JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract18() { if (!this.out) { this.out = obj.CA10Z1__parametersJson__c; } return this.out; };
      function extract15() { if (!this.out) { this.out = jsonChecked16(); } return this.out; };
      function extract12() { if (!this.out) { this.out = jsonQueryChecked13(); } return this.out; };
      try {
          if (TextLib.isNotEmpty(extract12.call(extract12))) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonText__parametersJsonCustomVirtualNetworkValue__c').isNotEmpty()", currentStateMessage: "The Databricks Workspace is deployed in a customer-managed virtual network.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unexpected value 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.Id AS Id,
          sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
          sObject.CA10Z1__parametersJson__c AS CA10Z1__parametersJson__c,
          process_CA10Z1__CaAzureDatabricksWorkspace__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                  sObject.CA10Z1__parametersJson__c AS CA10Z1__parametersJson__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureDatabricksWorkspace__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
