Dast Continuous Testing

Production-grade guide to dast continuous testing covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.

DAST Continuous Testing is a process that automatically identifies security vulnerabilities in running web applications by analyzing their behavior during regular CI/CD pipelines. It matters when a service is deployed daily, and each deployment must be checked for common flaws—like injection, misconfigurations, and session issues—without manual effort. It is the backbone of a responsive security posture in microservices environments where new endpoints, APIs, and user flows emerge constantly.

Automating DAST in CI/CD Pipelines

The core of DAST Continuous Testing is a recurring, automated scan of a deployed application, triggered on every merge to main, pull request, or scheduled interval. The scan runs against a live instance—typically a staging or preview environment—and outputs a report of discovered security issues.

A typical DAST CI job runs in a GitLab CI, GitHub Actions, or Jenkins pipeline, using standard tools to deploy and verify the application before scanning.


stages:
  - build
  - test
  - dast

dast-scan:
  stage: test
  image: python:3.11-slim
  before_script:
    - pip install requests
    - python -c "import requests; print(requests.__version__)"
  script:
    - python -c "
      import requests
      import json

      # Deploy app to staging
      resp = requests.post('https://deploy.example.com/api/deploy', json={
          'ref': '${CI_COMMIT_SHA}',
          'env': 'staging'
      })
      resp.raise_for_status()

      # Wait for app to be ready
      app_url = resp.json()['url']
      while True:
          try:
              resp = requests.get(app_url + '/health', timeout=5)
              if resp.status_code == 200:
                  break
          except requests.RequestException:
              time.sleep(10)

      # Run DAST scan
      scan_resp = requests.post('https://dast.example.com/api/scans', json={
          'target': app_url,
          'config': {
              'technologies': ['React', 'Node.js'],
              'scan_type': 'full',
              'crawl_depth': 3,
              'authentication': {
                  'method': 'cookie',
                  'login_url': app_url + '/login',
                  'credentials': {
                      'username': '[email protected]',
                      'password': 'secret'
                  }
              }
          }
      })
      scan_id = scan_resp.json()['id']

      # Poll for scan completion
      while True:
          status_resp = requests.get(f'https://dast.example.com/api/scans/{scan_id}/status')
          status = status_resp.json()['status']
          if status in ['completed', 'failed']:
              break
          time.sleep(30)

      # Fetch results
      results_resp = requests.get(f'https://dast.example.com/api/scans/{scan_id}/results')
      results = results_resp.json()

      # Write findings to file
      with open('dast-results.json', 'w') as f:
          json.dump(results, f, indent=2)
      "
  artifacts:
    paths:
      - dast-results.json
    expire_in: 1 week

Each run produces a JSON report with findings, which can be used for gating PRs, generating dashboards, or triggering follow-up tasks.

Configuring Scan Behavior

The behavior of a DAST scan is defined by a configuration object that controls crawling, authentication, and testing logic. It is passed as JSON to a scanning service or embedded in a CI job.

{
  "target": "https://staging.example.com",
  "scan_type": "full",
  "crawl_depth": 5,
  "include_paths": [
    "/api/*",
    "/admin/*"
  ],
  "exclude_paths": [
    "/admin/login",
    "/api/v1/health"
  ],
  "authentication": {
    "method": "cookie",
    "login_url": "/login",
    "credentials": {
      "username": "[email protected]",
      "password": "secret"
    },
    "session_cookie": "session_id",
    "login_success_pattern": "Welcome back, [email protected]"
  },
  "headers": {
    "User-Agent": "DAST-Scanner/1.0",
    "Accept": "application/json"
  },
  "timeout": 30000,
  "max_concurrent_requests": 16
}

The scan_type field determines the scope and depth of the scan. Valid values include:

Crawling depth controls how far the scanner follows links. A depth of 3 means: home → product list → product detail → related products. The scanner tracks state across pages, including cookies, form data, and JavaScript variables.

Authentication is critical for discovering issues that only appear after login. The scanner follows the login flow, extracts the session cookie, and uses it for subsequent requests. If the login page returns a Set-Cookie header with session_id, the scanner expects that cookie to be sent on all future requests.

Integrating DAST Results into Developer Workflows

After a scan completes, the results must be actionable. The output is a structured list of findings, each with a severity, description, URL, and evidence.

[
  {
    "id": "dast-2024-01",
    "title": "Cross-Site Scripting (XSS) in Search Query",
    "description": "The search endpoint accepts user input in the 'q' parameter and reflects it in the response without sanitization.",
    "url": "https://staging.example.com/search?q=attack",
    "severity": "high",
    "category": "xss",
    "evidence": [
      {
        "type": "request",
        "method": "GET",
        "url": "https://staging.example.com/search?q=alert%281%29",
        "headers": {
          "User-Agent": "DAST-Scanner/1.0",
          "Cookie": "session_id=abc123"
        },
        "body": ""
      },
      {
        "type": "response",
        "status": 200,
        "headers": {
          "Content-Type": "text/html"
        },
        "body": "<h1>Search results for alert(1)</h1><p>Result: <script>alert(1)</script></p>"
      }
    ],
    "recommendations": [
      "Sanitize user input before including in HTML",
      "Use Content Security Policy (CSP) headers"
    ],
    "metadata": {
      "scanner": "OWASP ZAP",
      "scan_id": "zap-2024-01",
      "timestamp": "2024-04-05T12:30:45Z"
    }
  },
  {
    "id": "dast-2024-02",
    "title": "Missing Security Headers",
    "description": "The application does not set several critical security headers.",
    "url": "https://staging.example.com",
    "severity": "medium",
    "category": "headers",
    "evidence": [
      {
        "type": "response",
        "status": 200,
        "headers": {
          "Content-Type": "text/html",
          "Server": "nginx/1.21.3",
          "X-Frame-Options": "DENY"
        }
      }
    ],
    "missing_headers": [
      "Content-Security-Policy",
      "X-Content-Type-Options",
      "Strict-Transport-Security"
    ],
    "recommendations": [
      "Add HSTS with 31536000 seconds (1 year)",
      "Define a comprehensive CSP policy"
    ]
  }
]

The evidence array captures the full request-response cycle that led to a finding. This enables developers to reproduce issues locally or in a debugger.

Using Findings to Gate Pull Requests

To enforce security quality, a CI job can fail the pipeline if a DAST scan reports a critical or high-severity issue.

# GitHub Actions: .github/workflows/dast.yml
name: DAST Scan

on:
  pull_request:
    branches: [ main ]

jobs:
  dast:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run DAST Scan
        run: |
          curl -X POST https://dast.example.com/api/scans \
            -H "Content-Type: application/json" \
            -d @dast-config.json \
            -o dast-results.json
          python3 -c "
          import json
          with open('dast-results.json') as f:
              results = json.load(f)
          critical = [f for f in results if f['severity'] == 'critical']
          high = [f for f in results if f['severity'] == 'high']
          if critical or high:
              print('❌ Critical or high issues found:')
              for f in critical + high:
                  print(f'  - {f['title']} ({f['url']})')
              exit(1)
          print('✅ All DAST checks passed')
          "

A failing job blocks the PR merge until all critical and high issues are resolved.

Common Failure Modes and Sharp Edges

DAST scans silently fail in production due to subtle misconfigurations. The most common pitfalls:

Handling Dynamic Content and API-Driven UIs

For SPAs and API-driven UIs, DAST scans must account for dynamic content. The scanner must:

{
  "scan_type": "full",
  "javascript_enabled": true,
  "wait_after_page_load": 5000,
  "interactions": [
    {
      "page": "/products",
      "actions": [
        {
          "type": "click",
          "selector": "button#filter-by-price",
          "delay": 1000
        },
        {
          "type": "wait",
          "for": "div#products-list",
          "timeout": 10000
        },
        {
          "type": "fill",
          "selector": "input#search",
          "value": "laptop"
        },
        {
          "type": "submit",
          "selector": "form#search-form"
        }
      ]
    }
  ]
}

These interactions are replayed during the scan, allowing the scanner to navigate through complex flows.

Reporting and Tracking Findings

A DAST scan produces a report that is consumed by multiple teams. The report is not just a list of findings, but a living artifact that evolves over time.

To track issues across scans, the system assigns a unique scan_id and associates it with the CI pipeline and deployment. The report can be stored in a database, a file system, or a version-controlled repository.

Each finding is assigned a id that remains stable across scans. This allows teams to:

A common pattern is to store the report in a dast/ directory in the repository, with one file per scan.

dast/
├── 2024-04-05-12-30-45.json
├── 2024-04-04-10-15-20.json
├── latest.json
└── summary.md

A summary.md file can be generated from the latest scan, providing a high-level overview.

# DAST Scan Summary: 2024-04-05

- **Target**: https://staging.example.com
- **Scan ID**: zap-2024-01
- **Duration**: 4m 32s
- **Total Findings**: 12
  - Critical: 3
  - High: 5
  - Medium: 4

## Top Issues

1. **Cross-Site Scripting (XSS) in Search Query**
   - Severity: High
   - URL: https://staging.example.com/search?q=alert%281%29
   - Evidence: Script tag in response

2. **Missing Security Headers**
   - Severity: Medium
   - Missing: Content-Security-Policy, X-Content-Type-Options, Strict-Transport-Security

This summary is used in sprint reviews, security dashboards, and release notes.

This page was rewritten on 15 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.