Scan dependencies and images in the pipeline
In this task you'll find vulnerable dependencies and images before they ship.
Most of your code is other people's: packages and base images. Dependabot watches dependencies and opens pull requests for security updates; code scanning (CodeQL) finds risky code; an image scanner (such as Trivy in the pipeline, or Defender for Containers in the registry) finds known vulnerabilities in images.
Fail the build on serious findings, and keep base images small and current.
Example. A Dependabot pull request at SS Kaiser patched a vulnerable logging library the same morning the advisory was published.
Before you start
You need: A GitHub repository. Time: 20 minutes.
Where to look
- Repository
- Settings
- Advanced Security
- Dependabot
Steps
- Turn on Dependabot alerts and security updates in Settings, Advanced Security.
- Add .github/dependabot.yml to check your package ecosystem and GitHub Actions weekly.
- Add an image scan step to your workflow that fails on HIGH or CRITICAL.
Commands
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule: { interval: "weekly" }
- package-ecosystem: "github-actions"
directory: "/"
schedule: { interval: "weekly" }
Watch out for
- Cost
- Free for public repositories.
- Security
- Pin actions and base images; scan what you build, not only what you write.
- Common mistakes
- Ignoring the pull requests until there are 40 of them.
Clean up
Nothing to clean up.
Words to know
- Dependabot
- GitHub's service for dependency alerts and update pull requests.
- CVE
- A public identifier for a known vulnerability.
- SBOM
- A list of everything inside your software.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On