How to Run a Dependency Security Scan in CircleCI
Scan dependencies in CircleCI with the Snyk orb for rich SCA, or a zero-dependency npm audit step.
Use the snyk/snyk orb to scan and optionally fail on a severity threshold, or run npm audit directly when you just need a lightweight dependency gate.
Snyk orb scan with a threshold
The orb runs a vulnerability scan and fails the job on high-or-worse findings.
.circleci/config.yml
version: 2.1
orbs:
snyk: snyk/snyk@2
jobs:
scan:
docker:
- image: cimg/node:20.11
steps:
- checkout
- run: npm ci
- snyk/scan:
severity-threshold: high
fail-on-issues: trueGotchas
- The Snyk orb needs
SNYK_TOKENset in a context or project env var. - Set
severity-thresholdso low-severity advisories do not block every build. - For a no-orb option,
npm audit --audit-level=highworks but lacks Snyk's fix advice and monitoring.
Verify it actually works
- Trigger the real event rather than a manual run. Manual dispatch populates a different context, so behaviour depending on the event will differ.
- Assert on the outcome, not on the step exiting zero. Many steps report success while producing nothing.
- Check it on a fresh runner with a cold cache once, so you are not testing warm state that will not exist on the next contributor machine.
Frequently asked questions
How do I run a Dependency Security Scan in CircleCI?
Use the snyk/snyk orb to scan and optionally fail on a severity threshold, or run npm audit directly when you just need a lightweight dependency gate.
Snyk orb scan with a threshold?
The orb runs a vulnerability scan and fails the job on high-or-worse findings.
Related guides
How to Cache with restore_keys in CircleCIUse CircleCI save_cache and restore_cache with layered keys so a partial cache hit on restore_keys still
How to Use setup_remote_docker in CircleCIGet a real Docker daemon inside a CircleCI docker-executor job with setup_remote_docker, so you can run