---
policy: /ce/ca/azure/key-vault/public-network-access
logic: /ce/ca/azure/key-vault/public-network-access/prod.logic.yaml
executionTime: 2025-07-21T17:37:29.157600288Z
rows:
  - id: a7Z4x000000PJt5EAG
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__publicNetworkAccess__c') == 'Disabled'
      actual: extract('CA10__publicNetworkAccess__c') == 'Disabled'
    runtimeError: {}
  - id: a7Z4x000000PJkXEAW
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/key-vault/public-network-access/policy.yaml
    md5Hash: D1D113B519B602E653CE003B73D69298
    content: "---\nnames:\n  full: Azure Key Vault Public Network Access when using\
      \ Private Endpoint is enabled\n  contextual: Public Network Access is enabled\n\
      description: >\n  When a Private Endpoint is configured on a Key Vault, traffic\
      \ from resources \n  within the same subnet routes through the Vault's private\
      \ IP. However, the \n  public endpoint (mykeyvault.vault.azure.net) remains\
      \ accessible unless Public \n  network access is explicitly set to Disabled.\
      \ Disabling public network access \n  removes the public DNS entry, ensuring\
      \ all traffic is routed through the private \n  endpoint (mykeyvault.vault.privatelink.azure.net),\
      \ thereby reducing exposure \n  to the public internet.\ntype: COMPLIANCE_POLICY\n\
      categories:\n  - SECURITY\nframeworkMappings:\n  - \"/frameworks/cis-azure-v4.0.0/09/03/07\"\
      \n  - \"/frameworks/cloudaware/resource-security/secure-access\"\n"
  - path: /ce/ca/azure/key-vault/public-network-access/prod.logic.yaml
    md5Hash: D8A9CA2669572206226C61B69D46463C
    content: |
      ---
      inputType: "CA10__CaAzureKeyVault__c"
      importExtracts:
        - file: "/types/CA10__CaAzureKeyVault__c/object.extracts.yaml"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "COMPLIANT"
          currentStateMessage: "Public network access is disabled."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__publicNetworkAccess__c"
              right:
                TEXT: 'Disabled'
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "Public network access is not disabled."
        remediationMessage: "Consider disabling public network access."
  - path: /types/CA10__CaAzureKeyVault__c/object.extracts.yaml
    md5Hash: 120E8A73DCC969A90893ADC71C57D3FD
    content: "---\nextracts:\n# Values: Enabled, Disabled. Not Nullable. Can't have\
      \ no access, retrieved via Microsoft.KeyVault/vaults\n  - name: \"CA10__rbacAuthorization__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__rbacAuthorization__c\"\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. Key Vault RBAC\
      \ Authorization cannot be empty.\"\n# Values: Enabled, null. Nullable. Can't\
      \ have no access, retrieved via Microsoft.KeyVault/vaults\n  - name: \"CA10__purgeProtection__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__purgeProtection__c\"\n# Values:\
      \ Enabled, Disabled. Not Nullable. Can't have no access, retrieved via Microsoft.KeyVault/vaults\n\
      \  - name: \"CA10__softDelete__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__softDelete__c\"\n        undeterminedIf:\n          isEmpty: \"Corrupted\
      \ data. Soft Delete function cannot be empty.\"\n#\n  - name: \"CA10__publicNetworkAccess__c\"\
      \n    value:\n      FIELD:\n        path: \"CA10__publicNetworkAccess__c\"\n"
  - path: /ce/ca/azure/key-vault/public-network-access/test-data.json
    md5Hash: 68354E16D7D7C7D0B1FC0F8562389B3C
    content: |
      [
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__publicNetworkAccess__c') == 'Disabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "a7Z4x000000PJt5EAG",
          "CA10__disappearanceTime__c": null,
          "CA10__publicNetworkAccess__c": "Disabled"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "a7Z4x000000PJkXEAW",
          "CA10__disappearanceTime__c": null,
          "CA10__publicNetworkAccess__c": ""
        }
      ]
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" : "a7Z4x000000PJt5EAG",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__publicNetworkAccess__c') == 'Disabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "a7Z4x000000PJkXEAW",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureKeyVault__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__publicNetworkAccess__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "a7Z4x000000PJt5EAG",
    "CA10__publicNetworkAccess__c" : "Disabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "a7Z4x000000PJkXEAW",
    "CA10__publicNetworkAccess__c" : ""
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureKeyVault__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__publicNetworkAccess__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  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), 'Disabled')) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__publicNetworkAccess__c') == 'Disabled'", currentStateMessage: "Public network access is disabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Public network access is not disabled.", currentStateReferences: references1.join('\n'), remediation: "Consider disabling public network access.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__publicNetworkAccess__c AS CA10__publicNetworkAccess__c,
          process_CA10__CaAzureKeyVault__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__publicNetworkAccess__c AS CA10__publicNetworkAccess__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureKeyVault__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
