Bylaw

Gallery › Security Center › Azure built-in policies

Machines should have secret findings resolved

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.2

Audits virtual machines to detect whether they contain secret findings from the secret scanning solutions on your virtual machines.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONASC_ServerSecretAssessment_Audit.json · 55 lines
{
  "properties": {
    "displayName": "Machines should have secret findings resolved",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Audits virtual machines to detect whether they contain secret findings from the secret scanning solutions on your virtual machines.",
    "metadata": {
      "version": "1.0.2",
      "category": "Security Center"
    },
    "version": "1.0.2",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "Microsoft.Compute/virtualMachines",
          "Microsoft.ClassicCompute/virtualMachines"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "17618b1a-ed14-49bb-b37f-9f8ba967be8b",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3ac7c827-eea2-4bde-acc7-9568cd320efa",
  "name": "3ac7c827-eea2-4bde-acc7-9568cd320efa"
}
Bylaw3ac7c827-eea2-4bde-acc7-9568cd320efa.bylaw.ps1 · 33 lines
# Converted from ASC_ServerSecretAssessment_Audit.json by ConvertTo-Bylaw.
Policy '3ac7c827-eea2-4bde-acc7-9568cd320efa' {

    Properties @{
        DisplayName   = 'Machines should have secret findings resolved'
        Description   = 'Audits virtual machines to detect whether they contain secret findings from the secret scanning solutions on your virtual machines.'
        Version       = '1.0.2'
        Category      = 'Security Center'
        PolicyVersion = '1.0.2'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource * {

        Require 'type is not one of 2 values' {
            Field type | Must -Not -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.ClassicCompute/virtualMachines') -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '17618b1a-ed14-49bb-b37f-9f8ba967be8b' -Effect (Param Effect) {
        Require 'status.code is one of 2 values' {
            Field status.code | Must -BeIn @('NotApplicable', 'Healthy')
        }
    }
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_ServerSecretAssessment_Audit.json in Azure/azure-policy, under the MIT licence.