GitLab CI/CD Integration
This guide explains how to integrate Wisec into your GitLab pipelines using the two-stage setup: notarization + policy enforcement.
1. Prerequisites
- A Wisec account and project.
- Your Project ID from the dashboard.
- Your Agent Signing Key (private key) generated from Settings → Signing Keys.
2. Configure GitLab CI/CD Variables
Settings > CI/CD > Variables - add the following, marking sensitive values as Masked:
| Variable | Value | Masked |
|---|---|---|
WISEC_PROJECT_ID | Your numeric project ID | No |
AGENT_PRIVATE_KEY_HEX | Your Ed25519 private key | Yes |
WISEC_API_ENDPOINT | https://api.wisec.io/api/v1/events | No |
3. Two-stage setup
The agent works in two independent steps with distinct roles:
| Step | Stage | What it does |
|---|---|---|
wisec_notify | build | Notarizes the build (SLSA, Rekor, dashboard) and starts CVE analysis in the background. Never blocks. |
wisec_gate | security | Waits for the analysis, then enforces your policies - fails the job (exit 1) if a policy is violated. |
The wisec_gate step is required for policy enforcement. Policies (secrets, CVE, risk score…) are evaluated and recorded by wisec_notify, but they only ever block your pipeline through the gate. If you omit the gate step, a build that violates a block policy will still pass. Keep the gate if you rely on policies; wisec_notify alone gives you notarization only.
While wisec_notify runs alongside your build and tests, the CVE scan completes in the background. By the time wisec_gate runs at the end of the pipeline, the analysis is usually already done - added latency is close to zero.
stages:
- build
- test
- security
# Step 1 - Submit build record (runs early, non-blocking)
wisec_notify:
stage: build
image: alpine:latest
before_script:
- apk add --no-cache git curl
- curl -fsSLO https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64
- curl -fsSL https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64.sha256 | sha256sum -c -
- mv wisec-agent-v1.5.0-linux-amd64 wisec-agent
- chmod +x wisec-agent
script:
- ./wisec-agent
only:
- main
- merge_requests
# Step 2 - Policy gate (runs last, blocking)
wisec_gate:
stage: security
image: alpine:latest
before_script:
- apk add --no-cache git curl
- curl -fsSLO https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64
- curl -fsSL https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64.sha256 | sha256sum -c -
- mv wisec-agent-v1.5.0-linux-amd64 wisec-agent
- chmod +x wisec-agent
script:
- ./wisec-agent --gate
variables:
WISEC_GATE_TIMEOUT: "120" # seconds to wait for analysis
WISEC_STRICT: "false" # set to "true" to fail if Wisec is unreachable
only:
- main
- merge_requests
Gate environment variables
| Variable | Default | Description |
|---|---|---|
WISEC_GATE_TIMEOUT | 120 | Max seconds to wait for analysis to complete |
WISEC_STRICT | false | If true, fails the gate when analysis times out. If false, passes silently (recommended - your CI is never broken by a Wisec outage) |
Policies evaluated in the gate
Post-analysis policies (cve_severity, risk_threshold) are evaluated once the CVE scan completes and their result is returned by wisec_gate. Configure them in Dashboard → Policies.
4. Gitleaks (secret scanning)
Add gitleaks to the wisec_notify step to enable hardcoded secret detection:
wisec_notify:
stage: build
image: alpine:latest
before_script:
- apk add --no-cache git curl tar
- wget -q https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
- tar -xzf gitleaks_8.30.1_linux_x64.tar.gz && chmod +x gitleaks && mv gitleaks /usr/local/bin/
- curl -fsSLO https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64
- curl -fsSL https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64.sha256 | sha256sum -c -
- mv wisec-agent-v1.5.0-linux-amd64 wisec-agent
- chmod +x wisec-agent
script:
- ./wisec-agent
Secrets found by gitleaks appear as CRITICAL alerts in the dashboard and can trigger a secrets_detected policy. The secret's value is withheld by the agent and never reaches Wisec (since v1.2.0).
5. SARIF report import
Pass findings from CodeQL, Semgrep, Snyk, Trivy or any SARIF-compatible scanner to Wisec:
wisec_notify:
stage: build
variables:
WISEC_SCAN_REPORT_PATH: "$CI_PROJECT_DIR/results.sarif"
script:
# - semgrep --sarif --output results.sarif .
- ./wisec-agent
6. Binding the proof to the delivered artifact (optional)
By default, the provenance identifies the build by its source commit. To have it name the file you deliver, run the agent after the build and set WISEC_BINARY_PATH to that file. The installation guide explains what this changes, and its limits. Container images your build pushes can be named as well, with WISEC_IMAGE_DIGESTS (agent v1.3.0 or later): see Container images.
build:
stage: build
script:
- make build # produces dist/myapp
artifacts:
paths:
- dist/myapp
wisec_notify:
stage: test
needs: [build]
image: alpine:latest
variables:
WISEC_BINARY_PATH: "dist/myapp"
before_script:
- apk add --no-cache git curl
- curl -fsSLO https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64
- curl -fsSL https://wisec-downloads.s3.fr-par.scw.cloud/wisec-agent-v1.5.0-linux-amd64.sha256 | sha256sum -c -
- mv wisec-agent-v1.5.0-linux-amd64 wisec-agent
- chmod +x wisec-agent
script:
- ./wisec-agent
wisec_notify moves from the build stage to the test stage: needs: [build] starts it as soon as the build finishes (alongside your tests) and fetches the file declared in artifacts. wisec_gate is unchanged.
If you also import a SARIF report, list the job that produces it in needs as well (for example needs: [build, semgrep]). needs restricts the files a job receives to the jobs it lists: without it, the report is silently missing and its findings never reach Wisec.
To check it worked, open the attestation from the dashboard: its subject reads artifact sha256:…. If it reads source commit …, the agent did not find the file.
Container images
If your build pushes images, write their digest to a dotenv report: GitLab exposes it as a variable to the jobs that need the build job.
build_image:
stage: build
image: docker:27
services: [docker:27-dind]
variables:
# the daemon runs in the dind service, not in the job container
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
# recent Docker attaches its own attestation and pushes an image index,
# which the GitLab registry rejects ("blob unknown to registry")
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
- echo "WISEC_IMAGE_DIGESTS=$(docker inspect --format '{{index .RepoDigests 0}}' "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA")" > image.env
artifacts:
reports:
dotenv: image.env
wisec_notify:
stage: test
needs: [build_image] # receives WISEC_IMAGE_DIGESTS from image.env
# ... same as above
For several images, put them all on the same line, separated by spaces. Requires agent v1.3.0 or later; the installation guide lists the commands for buildx, Kaniko and crane.