Implement IaC scanning in CI pipelines
Implementation Effort: Medium – Enabling Defender for Cloud, connecting the DevOps connector, and adding Microsoft Security DevOps scanning with SARIF upload spans security and pipeline teams.
User Impact: Low – IaC scanning runs in the build and reports findings to reviewers; end users are not affected.
Lifecycle Stage: Build
Overview
Scan Infrastructure as Code templates in CI pipelines so misconfigurations are detected before deployment.
This requires Microsoft Defender for Cloud enabled in the relevant subscriptions, GitHub or Azure DevOps connected through a DevOps security connector when using Defender for Cloud DevOps, and verification of the current plan requirements for each feature.
Microsoft Defender CSPM is required for advanced Defender for Cloud DevOps posture capabilities such as code-to-cloud mapping. Basic CI scanning with Microsoft Security DevOps — the GitHub Action and Azure DevOps extension — runs open-source analyzers and does not require a Defender for Cloud plan. Confirm your required plan tier based on the specific Defender for Cloud features your organization intends to use beyond basic CI scanning. For GitHub repositories, GitHub code scanning and related pull request feedback use GitHub Code Security where required.
Infrastructure-as-code templates for Bicep, ARM, and Terraform define the cloud resources that production workloads depend on. When those templates contain misconfigurations — such as storage accounts with public access, databases without encryption at rest, or network security groups with overly broad inbound rules — the resulting deployed infrastructure inherits those weaknesses.
Scanning IaC files during the CI pipeline catches these issues at the point where they are cheapest and easiest to fix: in a pull request, before the code merges.
Microsoft Security DevOps provides a GitHub Action and an Azure DevOps extension that run open-source analyzers such as Checkov, Terrascan, and Trivy against IaC templates as part of a normal build.
Findings are reported in SARIF format, but SARIF upload and pull request feedback differ by platform.
GitHub Repositories
Upload SARIF results to GitHub code scanning to surface alerts and pull request feedback. Public repositories can use GitHub code scanning without GitHub Code Security, while private and internal repositories require GitHub Code Security.
Azure DevOps
Use AdvancedSecurity-Publish@1 to publish SARIF into GitHub Advanced Security for Azure DevOps, which creates code scanning alerts.