Overview
DAST scans a running application over HTTP - unlike SAST/SCA, it needs a live, reachable deployment. So the DAST stage belongs after your pipeline has deployed the app to a staging or test environment. The stage downloads a helper script (dast.sh), triggers a scan against your
deployed URL, polls until it completes, and fails the build when findings exceed your chosen
severity threshold.
Prerequisite - verify the target domain. Because DAST sends real attack traffic, CodeAnt only
scans domains your organization has proven it owns. Add and verify the target’s domain once on the
DAST → Domains page before adding this stage. If the domain isn’t verified, the scan returns
403 needs_verification and the build fails with a message telling you to verify it.Jenkins Pipeline
Add the following stage to yourJenkinsfile. Place it after the stage that deploys your app to
staging:
Important:
- In Manage Jenkins → Credentials, add a Secret text credential with ID
ACCESS_TOKENcontaining your CodeAnt token (cdt_…). See API Tokens for how to create one.- Set
TARGET_URLto the deployed app/staging URL produced by your pipeline. Its host must be a verified domain (see the prerequisite above).dast.shruns the scan start → poll → gate in a single command and writes adast_results.jsonyou can archive.
How it works
- Deploy first An earlier stage deploys your application to a reachable staging/test environment.
-
Download script
The stage fetches the DAST runner (
dast.sh) from the CodeAnt API endpoint. -
Start scan
dast.shtriggers a scan againstTARGET_URLand receives ascan_id/domain_id. -
Poll for results
It polls until the scan completes, using:
- Timeout: 600 seconds (10 minutes) - DAST is slower than static scans
- Poll interval: 30 seconds
-
Gate the build
When the scan finishes, the build fails if any severity at or above
--fail-on(defaulthigh) has findings, and passes otherwise.
Script Parameters
Thedast.sh script accepts the following parameters:
What DAST checks
DAST actively probes your running application for runtime vulnerabilities, including:- SQL injection (including blind SQLi)
- Cross-site scripting (reflected & stored)
- CSRF, open redirects, and CRLF injection
- Command execution, file inclusion, SSRF, and XXE
- Missing/weak security headers, CSP, and cookie flags
critical / high / medium / low) - that rollup is what the --fail-on gate evaluates.
The Jenkins flow scans the target URL with default settings. For OpenAPI/Swagger-aware API
scans (which add coverage of your REST endpoints), run the scan from the DAST → Domains page
in the dashboard, where you can attach an OpenAPI spec to the domain.
Best Practices
- Scan after deploy: Always run the DAST stage against a freshly deployed staging environment.
- Start with
--fail-on high: Block oncritical/highfirst, then tighten tomediumonce your app is clean. - Archive results: Keep
dast_results.jsonas a build artifact for auditability. - Keep tokens secure: Never commit access tokens - always use Jenkins Credentials.
- Give scans time: DAST is slower than static analysis; raise
-tfor large applications.
Jenkins Built-in Variables
Troubleshooting
Domain not verified
If the scan fails withdomain not verified / needs_verification:
- Add and verify the target’s domain on the DAST → Domains page (apex verification also covers subdomains).
- Make sure
TARGET_URL’s host matches the verified domain.
Scan times out
If the scan doesn’t complete within the timeout:- Increase the timeout, e.g.
-t 1200(20 minutes), for larger applications. - Confirm the target URL is reachable from the CodeAnt scanner.
Authentication failures
If you see “Access token invalid”:- Verify your
ACCESS_TOKENcredential holds a valid CodeAnt token (cdt_…) that hasn’t been revoked. - Ensure the token belongs to the same organization as the repository.
- Check that the credential ID matches exactly.
Target not reachable
If the scan can’t reach your app:- Ensure the staging deployment finished successfully before the DAST stage runs.
- Confirm the URL is publicly reachable (or reachable from your CodeAnt scanner network).
Token permission
This pipeline authenticates with a CodeAnt API token (cdt_…). If the token is scoped, give it the Codeant CI/CD role - it covers scans, quality gates, and test-coverage upload - scoped to the repositories this pipeline runs on (or All repositories). A token missing the required permission is rejected with an HTTP 403 token_scope_forbidden error that names the permission it needs. See API token permissions.