Microsoft Defender for Cloud
Cloud and workloads

Scan for misconfigurations in Infrastructure as Code

In brief

The article adds prerequisites, corrects a GitHub link, clarifies YAML steps for enabling IaC scanning, and explains where scan results appear with or without a GHAS license.

What Defender admins need to know

Use the updated guidance when configuring IaC scans and locating results.

Summaries are generated from the documentation change itself.

Documentation change

The comparison below shows only the changed extract. Use the full-page view for complete context.

You can set up Microsoft Security DevOps to scan your connected GitHub repository or Azure DevOps project. Use a GitHub action or an Azure DevOps extension to run Microsoft Security DevOps only on your Infrastructure as Code (IaC) source code, and help reduce your pipeline runtime.

This article shows you how to apply a template YAML configuration file to scan your connected repository or project specifically for IaC security issues by using Microsoft Security DevOps rules. Before you begin, make sure you have a connected GitHub repository or Azure DevOps project and review the prerequisites.

Prerequisites

  1. In the file directory, select .github > workflows > msdevopssec.yml.

    For more information about working with an action in GitHub, see PrerequisitesPrerequisites.

  2. Select the Edit this file (pencil) icon.

    :::image type="content" source="media/tutorial-iac-vulnerabilities/workflow-yaml.png" alt-text="Screenshot that highlights the Edit this file icon for the msdevopssec.yml file." lightbox="media/tutorial-iac-vulnerabilities/workflow-yaml.png":::

  3. In the Run analyzers section of the YAML file, add this code:the following code to enable Infrastructure as Code scanning:

    with:
    

The following screenshot shows an example of the updated YAML configuration:

:::image type="content" source="media/tutorial-iac-vulnerabilities/add-to-yaml.png" alt-text="Screenshot that shows the information to add to the YAML file.":::

  1. Select the workflow to see the action status.

  2. To view the results of the scan, use one of the following options:

    • Go to Defender for Cloud > DevOps security. This option doesn't require a GitHub Advanced Security (GHAS) license.
    • If you have a GitHub Advanced Security (GHAS) license, go to Security > Code scanning alerts natively in GitHub.

Set up and run an Azure DevOps extension to scan your connected IaC source code

  1. Select Edit pipeline.

  2. In the pipeline YAML configuration file, below the displayName line for the MicrosoftSecurityDevOps@1 task, add the following code to enable Infrastructure as Code scanning:

    inputs:
        categories: 'IaC'
    

    The following screenshot shows an example of the pipeline YAML configuration with the IaC category added:

    :::image type="content" source="media/tutorial-iac-vulnerabilities/addition-to-yaml.png" alt-text="Screenshot that shows where to add the IaC categories line in the pipeline configuration YAML file.":::