Run in CI pipelines
Run Vulnlog in your pipeline to check the Vulnlog file on every change, generate the suppression files before your scanner runs, and keep a current impact report.
Before you start
-
A Vulnlog file in your repository, for example
acme-shop.vl.yaml. -
For GitHub Actions, a workflow file in
.github/workflows.
Set up a GitHub Actions workflow
-
Install the CLI with the Setup Vulnlog CLI action, and pin the version. Every later step can then call
vulnlog. -
Check the file with
validate --strictandfmt --check. Both fail the job when there’s a problem. -
Generate the suppression file, then run the scanner with it.
-
Generate the impact report and upload it.
name: Vulnerabilities
on: [push, pull_request]
jobs:
vulnlog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Vulnlog CLI
uses: vulnlog/setup-vulnlog@v1
with:
version: 0.19.0
- name: Check the Vulnlog file
run: |
vulnlog validate --strict acme-shop.vl.yaml
vulnlog fmt --check acme-shop.vl.yaml
- name: Generate suppression files
run: |
vulnlog suppress acme-shop.vl.yaml --reporter trivy
[ -f .trivyignore.yaml ] || touch .trivyignore.yaml
- name: Scan
run: trivy fs --ignorefile .trivyignore.yaml .
- name: Generate impact report
if: always()
run: vulnlog report impact acme-shop.vl.yaml
- name: Upload impact report
if: always()
uses: actions/upload-artifact@v7
with:
name: vulnlog-impact-report
path: vulnlog-impact-report.html
The scan step assumes that Trivy is installed on the runner. Replace it with the scanner you use, and pass it the file Vulnlog generates for it. See Generate suppression files.
The suppression file is generated on every run, so you don’t need to commit it.
When no entry in the Vulnlog file names the scanner, vulnlog suppress writes no file and prints Unchanged: no suppression entries applicable.
The touch line then creates an empty file, so the scan step finds one.
For the action’s inputs, outputs, and supported runners, see GitHub Action.
Variants
If your pipeline runs Docker containers
Use the Vulnlog image, and mount the workspace to /work:
$ docker run --rm -v "$PWD:/work" ghcr.io/vulnlog/vulnlog:0.19.0 validate --strict acme-shop.vl.yaml
$ docker run --rm -v "$PWD:/work" ghcr.io/vulnlog/vulnlog:0.19.0 suppress acme-shop.vl.yaml --reporter trivy
If the container can’t write to the workspace, run it as your own user. For the user ID the container runs as, see Install Vulnlog.
If you use GitLab CI/CD
Run the job in the Vulnlog image. Clear the image’s entrypoint, so the runner can start a shell in it:
vulnlog:
image:
name: ghcr.io/vulnlog/vulnlog:0.19.0
entrypoint: [""]
script:
- vulnlog validate --strict acme-shop.vl.yaml
- vulnlog fmt --check acme-shop.vl.yaml
- vulnlog report impact acme-shop.vl.yaml
artifacts:
when: always
paths:
- vulnlog-impact-report.html
To pass suppression files to a scanner job, generate them in this job and add them to artifacts.
If you build with Gradle
Configure the files once and call the tasks in the pipeline:
vulnlog {
files.from("acme-shop.vl.yaml")
validate {
strict = true
}
}
$ ./gradlew vulnlogValidate vulnlogFormat --check
$ ./gradlew vulnlogSuppress vulnlogImpactReport
The suppression files go to build/vulnlog/suppressions, and the report to build/vulnlog/vulnlog-impact-report.html.
Point your scanner and your upload step there.
For all tasks, see Gradle plugin.
If you use another CI system
Install the CLI on the runner, and run the same commands as in the GitHub Actions workflow. See Install Vulnlog.
Check the result
-
Push a change that breaks the Vulnlog file, for example an entry with an undefined tag. The check step fails with exit code
2. A file that isn’t canonical fails with exit code3. -
Open the uploaded report from the workflow run, and check that it shows the current entries.
For all exit codes, see Exit codes and messages.