GitHub Actions
This workflow scans every push and pull request, uploads the results to GitHub code scanning, and fails the job on Critical or High findings.
name: vulkro
on:
push:
branches: [main]
pull_request:
jobs:
scan:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # to upload SARIF
env:
VULKRO_ACCOUNT_TOKEN: ${{ secrets.VULKRO_ACCOUNT_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Vulkro
run: |
curl -fsSL https://dist.vulkro.com/install.sh | VULKRO_BIN_DIR="$HOME/.local/bin" bash
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Scan
run: vulkro scan ci . --format sarif > vulkro.sarif
- name: Upload to code scanning
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: vulkro.sarif
Set the secret
Create a CI key in the customer portal (app.vulkro.com, Settings) and save it as a repository secret named VULKRO_ACCOUNT_TOKEN. The scan signs in with it, so no vulkro login step is needed. A CI key works during the 14-day trial and on paid plans, and uses no device seat. See CI keys.
What fails the build
The ci preset exits 1 when it finds Critical or High findings (or breaks the [quality_gate] thresholds in vulkro.toml, when you set them). The upload step still runs, so the findings appear in code scanning.
| Exit code | Meaning |
|---|---|
0 | No findings at the gate level |
1 | Findings at the gate level, or no licence (license_required on stderr) |
2 | Error: bad arguments, IO failure |
Fail only on new findings
To block a pull request only on findings it introduces, make the scan report-only and add vulkro gate:
- name: Scan
run: vulkro scan ci . --format sarif > vulkro.sarif || true
- name: Fail on new findings
if: github.event_name == 'pull_request'
run: vulkro gate --base origin/${{ github.base_ref }}
fetch-depth: 0 in the checkout step is what makes the base branch available.
Comment on the pull request
- name: Post a summary comment
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
vulkro scan ci . --format gh-pr > vulkro-comment.md || true
gh pr comment ${{ github.event.pull_request.number }} --body-file vulkro-comment.md
The job needs pull-requests: write in permissions for this step.
Air-gapped runners
A runner with no route out uses a licence file instead of a CI key. Save the base64 of your .lic file (base64 -w0 your.lic) as the secret VULKRO_LICENSE_B64, install from your internal mirror, and turn the network off:
env:
VULKRO_OFFLINE: "1"
VULKRO_LICENSE_B64: ${{ secrets.VULKRO_LICENSE_B64 }}
See Offline mode.
If this repository is connected to Vulkro Cloud, pull requests are scanned without any pipeline step: see Pull requests in Vulkro Cloud.