OWASP ZAP CI/CD integration with Snapsec VM
Use OWASP ZAP in your CI/CD pipeline to perform dynamic application security testing (DAST) against your web application and then push the discovered vulnerabilities into Snapsec VM using a simple webhook. This guide shows you, step by step, how to:- Run OWASP ZAP in your GitHub Actions or GitLab CI pipeline.
- Generate a JSON report.
- Send that JSON report directly to Snapsec VM using a webhook.
1. Prerequisites
- A running test/staging instance of your web application that OWASP ZAP can scan (HTTP/HTTPS URL).
- Basic understanding of which endpoints and environments are safe to scan.
- Snapsec:
- An Assessment in Snapsec VM where ZAP findings will be stored.
- Assessment ID (
<assessment-id>) - API key (
<your-api-key>)
- CI environment with:
- Docker (for the ZAP Docker image), and
curlavailable.
Important: Run ZAP against non-production environments unless you are confident your app and infrastructure can handle active scanning.
2. Create an assessment in Snapsec VM
Before you send any results, create a dedicated assessment in Snapsec VM that will hold the ZAP findings:- Log in to the Snapsec UI.
- Go to the VM / Assessments section.
- Click New Assessment and give it a clear name, for example:
OWASP ZAP - Staging
- Save the assessment and copy its Assessment ID value.
3. Generate OWASP ZAP JSON report (locally or in CI)
You can use the official ZAP Docker image in baseline or full scan mode.Here is an example baseline scan that outputs JSON:
- Runs a passive + lightweight active scan against
https://staging.example.com. - Produces a JSON report file called
zap-report.jsonin the container.
zap-report.json will then appear in the current directory on your machine/CI runner.
You can test this locally first before wiring it into CI.
4. Push OWASP ZAP JSON directly to Snapsec VM via webhook
Once you havezap-report.json, post it to Snapsec VM:
Important: ReplaceBelow are ready-to-use examples for GitHub Actions and GitLab CI.<assessment-id>with your actual Assessment ID and<your-api-key>with your API key. Note on the-kflag: This flag tellscurlto perform an “insecure” SSL transfer, which bypasses certificate validation. You may need this for local or development environments. Remove it if your endpoint has a valid SSL certificate.
5. GitHub Actions example
- Create
.github/workflows/zap-to-snapsec.ymlin your repository. - Copy the YAML above into that file.
- In your GitHub repository settings, create secrets:
ZAP_TARGET_URL(e.g.https://staging.example.com)SNAPSEC_ASSESSMENT_IDSNAPSEC_API_KEY
- Push your changes. GitHub Actions will run the workflow on each push or pull request.
6. GitLab CI example
- Create or edit
.gitlab-ci.ymlin the root of your repository. - Add the
zap_to_snapsecjob shown above. - In your GitLab project, go to Settings → CI/CD → Variables and add:
ZAP_TARGET_URLSNAPSEC_ASSESSMENT_IDSNAPSEC_API_KEY
- Commit and push your changes. GitLab will run the job on merge requests and on the
mainbranch.
- Run OWASP ZAP scans automatically in your pipeline.
- Upload the
zap-report.jsonvulnerability report directly to Snapsec VM using the provided webhook.