🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

AppSec Testing: SAST, DAST, SCA and Regression Tests

AppSec TestingSecurity TestingđŸŸĸ Free Lesson

A security tool that reports findings nobody acts on is worse than no tool, because it creates the impression that testing happened. Application security testing only produces value when results feed a workflow: a finding is triaged, assigned, fixed or explicitly waived with an expiry, and the same class of defect is prevented from recurring. That means choosing tools for how they integrate rather than for how impressive their demonstration is, tuning them against your actual codebase, and owning a set of security tests that only you can write because they check your business logic.

What each testing type can and cannot see

Every technique observes the application from a different vantage point, and the overlaps matter as much as the gaps. Running one type and calling the program mature is the most common oversimplification in security testing today.

TypeVantage pointSees wellCannot seeTypical cost per run
SASTSource code, no executionInjection patterns, crypto misuse, unsafe APIsRuntime configuration, business logic abuseSeconds to minutes
DASTRunning system, black boxExposed headers, auth gaps, server misconfigSource-level flaws, dead code pathsMinutes to hours
IASTInside the running app with an agentPrecise line-level trace of exploited pathsCoverage outside instrumented flowsLow at runtime
SCAThird-party componentsKnown CVEs, license conflicts, outdated versionsYour own code's vulnerabilitiesSeconds
FuzzingInputs at speedCrashes, memory issues, unexpected statesLogic errors that return plausible answersMinutes to hours
Security unit testsYour business rulesAuthorization, validation, workflow abuseAnything you did not think to assertMilliseconds

A useful mental model: SAST protects you while code is being written, SCA protects you while dependencies are chosen, DAST protects you at release, and your own regression tests protect the decisions that are unique to your product.

Static analysis: fast feedback, only if the rules match your stack

Static analysis earns its place by running in seconds on every push. Its weaknesses are equally consistent: high false-positive rates on generated code, poor handling of framework-specific escaping, and configuration defaults that flag style issues alongside real flaws. The configuration below narrows a JavaScript project to security-relevant rules and fails the build only on high-severity findings, while still recording everything for trend tracking.

{
  "extends": ["eslint:recommended", "plugin:security/recommended-legacy"],
  "plugins": ["security"],
  "env": { "node": true, "es2024": true },
  "rules": {
    "security/detect-eval-with-expression": "error",
    "security/detect-non-literal-regexp": "warn",
    "security/detect-unsafe-regex": "error",
    "security/detect-possible-timing-attacks": "warn",
    "no-eval": "error",
    "no-implied-eval": "error",
    "no-new-func": "error"
  },
  "ignorePatterns": ["**/*.generated.js", "dist/**", "coverage/**"]
}
# Python: bandit focused on exploitable classes, output as JSON for triage
bandit -r src/ -f json -o bandit-report.json \
  --severity-level medium --skip B101

# Convert findings into reviewable annotations on the pull request
bandit -r src/ -f sarif -o bandit.sarif
upload-sarif bandit.sarif

# Baseline so legacy findings do not block every unrelated change
bandit -r src/ -f json -o /dev/null --baseline-path .bandit-baseline

Baselines deserve special mention: they let you adopt scanning in a large existing codebase without demanding that everything be fixed first, while still guaranteeing no new violations appear. Review the baseline quarterly and shrink it; a baseline that only ever grows is a backlog nobody intends to clear.

Dynamic analysis: the running system tells a different story

Dynamic scanners exercise the deployed application the way an attacker would, through HTTP, which means they catch what static analysis cannot see: missing security headers, verbose error pages, exposed admin interfaces, session cookies without HttpOnly, and endpoints that were never registered in a route inventory. The commands below run an authenticated baseline scan and store results for comparison between releases.

# Passive baseline scan: observe only, safe against production
zap-baseline.py -t https://staging.example.com \
  -r zap-baseline.html -J zap-baseline.json -I \
  -c rules-baseline.conf -z "-config api.key=$ZAP_API_KEY"

# Active scan against staging only, with an authenticated context
zap-full-scan.py -t https://staging.example.com \
  -a 1 -l High -r zap-full.html -J zap-full.json \
  -z "-config replacer.full_list(0).description=auth \
      -config replacer.full_list(0).enabled=true \
      -config replacer.full_list(0).matchtype=REQ_HEADER \
      -config replacer.full_list(0).matchstr=Cookie \
      -config replacer.full_list(0).replacement=Cookie=$SESSION_COOKIE"

# Compare against the previous release to catch regressions
jq '.site[0].alerts | length' zap-full.json

Two rules keep DAST trustworthy: scan staging with production-like data shapes, never production with active scanning; and authenticate, because an unauthenticated scan of an application with a login wall tests only the login page. Anything found by DAST that could have been caught statically should be converted into a lint rule so the class disappears rather than recurring.

Software composition analysis: the code you did not write

Most of the code in a modern application came from a package registry, and SCA is how you learn what is actually in the binary. The hard part is not detection — it is reachability. A CVE in a library that is installed but never invoked on the vulnerable path is not equally urgent, and treating all findings the same produces a queue that never empties.

# Inventory and scan dependencies with exploitability context
snyk test --severity-threshold=high --dev \
  --remote-repo-url=example.com/payments-api

# OWASP Dependency-Check for an offline, standards-mapped report
dependency-check --project "payments-api" \
  --scan ./ \
  --format HTML,JSON \
  --nvdApiKey "$NVD_API_KEY" \
  --enableRetireJS

# Produce an SBOM so downstream consumers can check their own exposure
syft dir:. -o spdx-json > sbom.spdx.json

# Fail only on vulnerabilities that are both severe and reachable
jq -e '[.vulnerabilities[] | select(.severity=="high" or .severity=="critical")
        | select(.reachable == true)] | length == 0' snyk.json

Generating an SBOM on every release costs almost nothing and pays off during the next Log4Shell-style disclosure: you can answer "are we affected" in minutes with a grep instead of an all-hands investigation across teams.

Dependency work is also where security meets engineering culture, because the finding almost never belongs to the team that receives it. A vulnerability introduced by a transitive dependency three years ago lands as a ticket on whoever last touched that module, who did not choose the package and cannot upgrade it without risking a behavioral change. The teams that handle this well treat dependency updates as routine maintenance with a defined service level, keep upgrades flowing continuously so no single bump is a leap across dozens of versions, and reserve the escalation path for findings that are both exploitable in their deployment context and already being used in the wild.

Security regression tests: assertions only you can write

Tools cannot know that a customer must never see another customer's invoice, or that a refund above a threshold needs a second approver. Those rules are your product's security model, and the only durable way to protect them is a test that fails the build when someone changes the behavior. The suite below covers the four checks that appear in almost every assessment.

python
import pytest

def test_cross_tenant_object_access_is_denied(second_user_client, first_user_order):
    resp = second_user_client.get(f"/api/orders/{first_user_order.id}")
    assert resp.status_code in (403, 404), "cross-tenant read must fail"
    # Do not leak existence: same code for missing and forbidden
    missing = second_user_client.get("/api/orders/99999999")
    assert missing.status_code == resp.status_code

def test_mass_assignment_cannot_set_privileged_fields(admin_client):
    payload = {"username": "newuser", "role": "admin", "is_verified": True}
    resp = admin_client.post("/api/users", json=payload)
    assert resp.status_code == 400
    assert "role" in resp.text or "unknown field" in resp.text

def test_stored_xss_is_neutralized(client):
    payload = "<script>alert(1)</script>"
    resp = client.post("/api/comments", json={"body": payload})
    assert resp.status_code == 201
    listed = client.get("/api/comments").get_data(as_text=True)
    assert "<script>" not in listed

def test_login_is_rate_limited(client):
    attempts = [client.post("/api/login", json={"user": "victim", "pass": f"guess{n}"})
                for n in range(12)]
    assert any(r.status_code == 429 for r in attempts)

def test_privileged_endpoint_requires_scope(admin_token, user_token):
    resp = client.get("/api/admin/exports", headers={"Authorization": f"Bearer {user_token}"})
    assert resp.status_code == 403

Write these tests next to the feature they protect. When an authorization test is filed in a separate repository that only the security team reads, it stops being a regression guard and starts being a report.

CI gates that survive contact with delivery pressure

A gate with no exception path gets disabled the first time a release is urgent, and disabling it is easier than fixing it. Design the pipeline so that severity determines the outcome, waivers are explicit and expire, and every gate writes a result artifact that survives for audit.

name: security-gates
on: [pull_request]

jobs:
  static-and-deps:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: SAST
        run: |
          bandit -r src/ -f json -o bandit.json --severity-level medium
          jq -e '.results | length == 0' bandit.json
      - name: Dependency gate
        uses: snyk/actions/node@master
        env: { SNYK_TOKEN: "${{ secrets.SNYK_TOKEN }}" }
        with:
          command: test
          args: --severity-threshold=high --fail-on=upgradable
      - name: Secret scan
        run: gitleaks detect --source . --redact --exit-code 1
      - name: Upload results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: security-reports
          path: "*.json"

--fail-on=upgradable is a deliberate choice: it blocks on issues you can fix by bumping a version, while waivable-but-unfixed issues are tracked separately with an owner. Pair the gate with a scheduled full scan, because pull-request runs never exercise code paths that nobody touched this week.

💡Tune before you enforce

Run every tool in report-only mode for two weeks against your real repository, measure the signal-to-noise ratio per rule, and disable the rules that produce nothing but noise. A gate built on tuned defaults earns trust; a gate built on stock configuration loses it in a fortnight.

Common Mistakes

Buying one scanner and treating its green report as application security

Fix: Combine static, dynamic, composition and your own regression tests; each covers what the others structurally cannot.

Enabling every rule on day one in a legacy codebase

Fix: Baseline existing findings, block new ones, and shrink the baseline on a fixed cadence.

Scanning staging without authenticating

Fix: Provide an authenticated session context so scanners exercise real functionality instead of a login wall.

Counting every dependency CVE as equally urgent

Fix: Prioritize by severity and reachability, and fail the gate only where a fix exists and is applied.

Keeping security tests in a repository nobody runs per pull request

Fix: Place authorization and workflow tests beside the feature code so failures block the change that caused them.

Best Practices

  • Run SAST and SCA in seconds on every push, DAST against staging per release, and full scans on a schedule.
  • Fail builds on new high-severity findings while tracking pre-existing ones in a shrinking baseline.
  • Generate an SBOM on every release so future disclosures can be answered in minutes.
  • Convert every DAST finding that static analysis could have caught into a lint rule to end the recurrence.
  • Publish gate results as artifacts and keep waivers explicit, owned, and time-limited.

Key Takeaways

  • Testing types are complementary vantage points, not interchangeable checkboxes.
  • Static analysis produces value only when rules match the stack and existing debt is baselined rather than ignored.
  • Dynamic scanning requires authentication and staging data to test anything beyond the login page.
  • Reachability changes dependency urgency; an SBOM turns crisis disclosure response into a search.
  • Only your own regression tests can assert business rules such as cross-tenant isolation and approval thresholds.
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-12

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Continue Learning

Suggested next tutorials based on this topic

Need Expert Cybersecurity Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement