Security Scanning: GHAS, Defender & Dependabot
Automate security scanning with GitHub Advanced Security, Microsoft Defender for Cloud DevOps, CodeQL, Dependabot, and container scanning. Design compliance strategies for open-source governance.
Why automated security scanning is non-negotiable
Think of airport security.
Every passenger walks through a metal detector. Every bag goes through an X-ray. This happens automatically, for every flight, every time. Nobody skips it because they are in a hurry. Nobody says βI checked my bag myself, it is fine.β
Security scanning in DevOps is the same idea. Every code change goes through automated scanners β looking for vulnerable dependencies, insecure code patterns, leaked secrets, and dodgy open-source licences. It happens automatically in the pipeline, every time, for every PR. Nobody skips it.
The scanning strategy landscape
Before diving into individual tools, understand the five categories of scanning the exam expects you to design for:
| Scan Type | What It Finds | Key Tool | When It Runs |
|---|---|---|---|
| Dependency scanning | Known vulnerabilities (CVEs) in third-party packages | Dependabot, npm audit, OWASP Dependency-Check | PR, push, scheduled |
| Code scanning (SAST) | Vulnerabilities in YOUR code β SQL injection, XSS, insecure deserialization | CodeQL, SonarQube, Semgrep | PR, push |
| Secret scanning | Accidentally committed credentials β API keys, tokens, passwords | GHAS Secret Scanning, git-secrets | Push, historical scan |
| Licence scanning | Open-source licence compliance β GPL, AGPL restrictions in commercial software | FOSSA, Snyk, GitHub licence detection | PR, scheduled |
| Container scanning | Vulnerabilities in container base images and layers | Defender for Containers, Trivy, Aqua | Build, registry push, scheduled |
GitHub Advanced Security (GHAS)
GHAS is GitHubβs integrated security suite. It includes three core capabilities.
1. Code scanning with CodeQL
CodeQL is a semantic code analysis engine that treats code as data. You write queries (or use GitHubβs default query suites) that find vulnerability patterns.
How it works:
- CodeQL builds a database from your source code (compiles it into a queryable format)
- Query suites run against the database β hundreds of checks for common vulnerability patterns
- Results appear as alerts on the Security tab and inline on PRs
Supported languages: C/C++, C#, Go, Java/Kotlin, JavaScript/TypeScript, Python, Ruby, Swift
Configuration: Add a workflow file .github/workflows/codeql-analysis.yml:
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * 1' # Weekly Monday 6am
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
security-events: write
strategy:
matrix:
language: ['javascript', 'python']
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
2. Secret scanning
Secret scanning detects over 200 token patterns from service providers (AWS, Azure, GitHub, Slack, Stripe, etc.).
Two modes:
- Push protection (recommended) β blocks the push BEFORE the secret enters the repository. The developer sees a warning and must either remove the secret or provide a justification to bypass.
- Alert mode β scans existing repository history and alerts on found secrets. Does not block pushes.
Custom patterns: You can define custom regex patterns for organisation-specific secrets (internal API keys, custom token formats).
3. Dependabot
Dependabot provides three services:
| Service | What It Does | Configuration |
|---|---|---|
| Dependabot alerts | Notifies you when a dependency has a known vulnerability | Enabled per-repo (no config file needed) |
| Dependabot security updates | Automatically creates PRs to update vulnerable dependencies to the minimum safe version | Enable in repo settings |
| Dependabot version updates | Automatically creates PRs to keep ALL dependencies up to date (not just vulnerable ones) | Requires dependabot.yml config file |
The dependabot.yml file lives in .github/dependabot.yml:
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
GHAS for Azure DevOps
GitHub Advanced Security is also available for Azure DevOps repositories β it is not GitHub-exclusive.
GHAS for Azure DevOps includes:
- Dependency scanning β scans package manifests (NuGet, npm, Maven, pip, Go) for known CVEs
- Secret scanning β detects committed credentials with push protection
- Code scanning β CodeQL analysis integrated into Azure Pipelines
Configuration: Enable GHAS at the organisation level in Azure DevOps, then per-repository. Add the GHAS tasks to your pipeline:
steps:
- task: AdvancedSecurity-Codeql-Init@1
inputs:
languages: 'csharp'
- task: AdvancedSecurity-Codeql-Autobuild@1
- task: AdvancedSecurity-Codeql-Analyze@1
- task: AdvancedSecurity-Dependency-Scanning@1
- task: AdvancedSecurity-Publish@1
Results appear in the Advanced Security tab within the Azure DevOps repository, similar to the GitHub Security tab.
Microsoft Defender for Cloud DevOps Security
Defender for Cloud DevOps Security provides a unified security posture view across multiple DevOps environments β GitHub, Azure DevOps, and GitLab.
What it does
- Connects to your GitHub orgs and Azure DevOps projects via connectors in Defender for Cloud
- Aggregates security findings from GHAS, Dependabot, and CodeQL into the Defender for Cloud dashboard
- Provides recommendations for DevOps security posture (e.g., enable branch protection, enable secret scanning)
- Maps findings to resources β correlates code vulnerabilities with the Azure resources they deploy to
Integration with GHAS
When GHAS and Defender for Cloud are both enabled:
- GHAS scans the code and generates alerts in GitHub / Azure DevOps
- Defender for Cloud ingests these alerts via the DevOps connector
- The Defender dashboard shows a unified view: code vulnerabilities, infrastructure misconfigurations, and runtime threats β all correlated
Scenario: Amira builds a unified security view
ποΈ Dr. Amira Hassanβs new client has 40 GitHub repositories and 25 Azure DevOps repositories across three business units. Each unit manages security independently β no central visibility.
Amiraβs implementation:
- Enables GHAS on all GitHub repos (code scanning, secret scanning, Dependabot)
- Enables GHAS for Azure DevOps on all Azure Repos (dependency, secret, and code scanning)
- Creates Defender for Cloud connectors for both the GitHub org and all three Azure DevOps orgs
- Configures Defender for Cloud DevOps Security recommendations
- Creates a single Defender dashboard showing all findings across all 65 repos
Result: Farah (junior consultant) can now triage all security findings from one dashboard instead of checking 65 repositories individually. Severity-based prioritisation means critical vulnerabilities are addressed first.
Container scanning
Container image scanning
Container images often contain vulnerable packages in their base layers. Scanning should happen at two points:
- Build time β scan the image in the CI pipeline before pushing to a registry
- Registry level β continuous scanning of images already stored in the registry
Tools for container scanning
| Tool | Where It Runs | Integration | Best For |
|---|---|---|---|
| Microsoft Defender for Containers | Azure Container Registry, AKS | Native Azure integration, continuous scanning | Azure-native teams needing registry + runtime scanning |
| Trivy | CI pipeline (GitHub Actions, Azure Pipelines) | Open-source, fast, wide format support | Teams wanting free, fast build-time scanning |
| Aqua Security | CI pipeline, registry, runtime | Enterprise, policy-based | Large enterprises with complex compliance needs |
| Snyk Container | CI pipeline, registry | Developer-friendly, fix suggestions | Developer teams wanting actionable fix guidance |
CodeQL in containers
You can run CodeQL analysis inside a container to ensure a consistent build environment:
jobs:
analyze:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:8.0
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: 'csharp'
- run: dotnet build
- uses: github/codeql-action/analyze@v3
This is useful when your project requires specific SDKs or compilers that are not on the GitHub-hosted runner image.
Open-source governance and licence compliance
Why licences matter
Open-source dependencies come with licences that impose legal obligations:
| Licence Type | Obligation | Commercial Risk |
|---|---|---|
| MIT, Apache 2.0, BSD | Attribution only | Low β permissive, business-friendly |
| LGPL | Must share modifications to the library itself | Medium β dynamic linking usually safe |
| GPL | Must open-source your entire derivative work | High β can force open-sourcing proprietary code |
| AGPL | GPL obligations extend to network use (SaaS) | Very high β even server-side use triggers obligations |
| No licence | No permissions granted (all rights reserved) | Very high β legally you cannot use it |
Governance approach
- Define an approved licence list β MIT, Apache 2.0, BSD, ISC are typically safe
- Automate licence detection β tools like FOSSA, Snyk, or the GitHub dependency graph detect licences
- Block risky licences in the pipeline β fail the build if a GPL or AGPL dependency is introduced
- Maintain a Software Bill of Materials (SBOM) β track all dependencies and their licences for audit
Exam tip: Scanning strategy design
The exam may ask you to design a complete scanning strategy. Cover all five pillars:
- Dependencies β Dependabot alerts + security updates for known CVEs
- Code β CodeQL in PR and push workflows for SAST
- Secrets β GHAS secret scanning with push protection enabled
- Licences β Automated licence detection with policy enforcement
- Containers β Build-time scanning (Trivy/Defender) + registry continuous scanning
Remember: scanning should be shift-left (catch issues in PRs, not in production) and automated (no manual steps that developers can skip).
Knowledge check
Amira needs to prevent developers from accidentally pushing API keys into any repository in the organisation. She wants the push to be blocked before the secret enters Git history. What should she enable?
Kai's startup uses npm packages heavily. He wants to be alerted when a dependency has a known CVE AND automatically receive PRs that update to the patched version. He also wants all dependencies kept current, not just vulnerable ones. What Dependabot features does he need?
Jordan's team runs Defender for Cloud and GHAS. Where does Jordan see a UNIFIED view of security findings across both GitHub and Azure DevOps repositories?
π¬ Video coming soon
Security Scanning: GHAS, Defender & Dependabot
Next up: Monitoring for DevOps: Azure Monitor and App Insights