Snyk Executor¶
Category: Source Code Analysis
Script: snyk.py
Integration: CLI
Faraday Plugin: SnykPlugin
Website: https://snyk.io/
Description¶
Runs a Snyk scan (open source dependencies, container image, IaC or code) on a local path or a Git repository and imports the findings into Faraday.
Prerequisites¶
snykCLI installed and available in the agent'sPATH(checked withsnyk --version)- A Snyk account and API token (
SNYK_TOKEN) git, if you scan a repository by URL- Network access to Snyk
Configuration¶
Environment Variables (Setup)¶
| Variable | Required | Description |
|---|---|---|
SNYK_TOKEN |
No | Snyk API token used by the Snyk CLI. Not needed if the agent host is already authenticated with snyk auth. |
GIT_USERNAME |
No | Username for cloning private repositories over HTTPS (default: oauth2) |
GIT_TOKEN |
No | Access token for cloning private repositories over HTTPS |
Execution Arguments¶
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
SNYK_TARGET |
string | No | Path to scan, or the image name in container mode. When SNYK_GIT_URL is set, it is a subpath inside the cloned repository (e.g., src/). |
SNYK_MODE |
string | No | Scan type: test (open source dependencies), container, iac or code (default: test) |
SNYK_SEVERITY_THRESHOLD |
string | No | Only report issues at or above this severity: low, medium, high or critical |
SNYK_ORG |
string | No | Snyk organization ID or slug to run the scan under |
SNYK_FILE |
string | No | Manifest file to scan (e.g., package.json, requirements.txt) |
SNYK_ALL_PROJECTS |
boolean | No | Set to true to scan all projects found in the target directory |
SNYK_GIT_URL |
url | No | Git repository to clone and scan |
SNYK_GIT_REF |
string | No | Branch or tag to clone (default: the repository's default branch) |
YAML Configuration Example¶
executors:
snyk:
repo_executor: snyk.py
max_size: 65536
varenvs:
SNYK_TOKEN: "<snyk_token>"
GIT_USERNAME: "<git_username>"
GIT_TOKEN: "<git_token>"
params:
SNYK_TARGET:
mandatory: false
type: string
base: string
SNYK_MODE:
mandatory: false
type: string
base: string
SNYK_SEVERITY_THRESHOLD:
mandatory: false
type: string
base: string
SNYK_ORG:
mandatory: false
type: string
base: string
SNYK_FILE:
mandatory: false
type: string
base: string
SNYK_ALL_PROJECTS:
mandatory: false
type: boolean
base: boolean
SNYK_GIT_URL:
mandatory: false
type: url
base: string
SNYK_GIT_REF:
mandatory: false
type: string
base: string
How It Works¶
- If
SNYK_GIT_URLis set, makes a shallow clone of the repository (atSNYK_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates withGIT_USERNAME/GIT_TOKEN. - Runs
snyk test,snyk container test,snyk iac testorsnyk code test(depending onSNYK_MODE) with--jsonand the optional severity threshold, organization, file and all-projects flags - Parses the JSON output with
SnykPluginand sends the results to Faraday - Deletes the temporary clone when the run ends
Notes¶
- Set
SNYK_TARGET,SNYK_GIT_URL, or both. The run fails if neither is set. SNYK_TARGETmust point inside the cloned repository whenSNYK_GIT_URLis used. Paths that escape it (e.g.,../) are rejected.- Snyk exits with code 1 when it finds issues. The executor still imports the results in that case, and only fails when Snyk produces no output.
- The token is hidden in the agent log if the clone fails.
- Supports the shared agent parameters (
AGENT_CONFIG_*tags and severity filters).