Automating security and compliance scanning

AZ-400 DevOps EngineerSecurity and compliance planAbout 25 minutesBy Cloud Hands On

Dependency, code, secret and licence scanning, GitHub Advanced Security, Defender for Cloud DevOps security, container scanning and Dependabot.

In this lesson you'll learn

1. A scanning strategy

ScanFindsTools
Dependency (SCA)Known vulnerabilities in open-source packagesDependabot, dependency review, Mend, Snyk
Code (SAST)Security bugs in your own codeCodeQL, SonarQube
SecretKeys and passwords committed to codeSecret scanning with push protection
LicenceDependencies whose licences your organisation can't acceptDependency review action, licence scanners
Container imageVulnerable OS packages and libraries in imagesDefender for Containers, Trivy

Scan early (pull requests, so problems never merge), scan again on a schedule (new vulnerabilities appear in old code), and fail builds only on findings you've agreed to block.

2. GitHub Advanced Security

On GitHub, Advanced Security features are code scanning (CodeQL, results as alerts and pull request annotations), secret scanning with push protection (blocks a push containing a known secret pattern), and dependency review (shows vulnerable or disallowed licences in a pull request's dependency changes). Microsoft now sells these as Secret Protection and Code Security.

GitHub Advanced Security for Azure DevOps brings the same scanning to Azure Repos and Azure Pipelines: secret scanning push protection on Azure Repos, and pipeline tasks for dependency scanning and CodeQL (AdvancedSecurity-Codeql-Init, -Autobuild, -Analyze, and AdvancedSecurity-Dependency-Scanning), with results on the repository's Advanced Security tab.

3. Defender for Cloud DevOps security

Microsoft Defender for Cloud connects to GitHub, Azure DevOps and GitLab through connectors. It brings code, secret, dependency and infrastructure-as-code findings into one view, maps code to the cloud resources it deploys, and can add pull request annotations. Integrating GitHub Advanced Security means its alerts show in Defender for Cloud next to cloud misconfigurations, so security teams see one picture.

4. Containers and Dependabot

  • Container scanning: scan images in the pipeline before pushing (for example Trivy) and in the registry (Defender for Containers scans Azure Container Registry images and reports vulnerabilities).
  • CodeQL in a container: run the analysis inside the build container by setting the job's container:, so the code is built with the same toolchain it ships with.
  • Dependabot alerts tell you when a dependency has a known vulnerability; Dependabot security updates open pull requests to fix them; version updates (configured in .github/dependabot.yml) keep dependencies current on a schedule.

Example

Fernhill Cloud turned on push protection across its organisation; in the first month it blocked 11 secrets. Dependabot security updates open pull requests automatically, and Defender for Cloud shows the security team which of those vulnerable packages run in production.

Exam traps to remember

  • Push protection blocks secrets before they're committed to the remote; secret scanning alerts on ones already there.
  • Dependabot alerts warn; security updates open fix pull requests; version updates use dependabot.yml.
  • Defender for Cloud uses connectors to GitHub and Azure DevOps.

Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-400 DevOps Engineer app.

Practise in the app

Keep going