Scope: Static code analysis (SAST), dynamic vulnerability scanning (DAST), software composition analysis (SCA), CSP validation, and security header verification.
flowchart TD
subgraph SCA_SAST [1. Pre-Build: Static Security]
A[Git Commit] --> B[SCA: npm audit / Snyk]
A --> C[SAST: Semgrep / SonarQube]
B & C -->|Finds Vulnerabilities| D[Block PR Merge]
end
subgraph DAST_Runtime [2. Post-Deploy: Dynamic Security]
E[Running Staging App] --> F[DAST: OWASP ZAP / Burp Suite]
F --> G[Simulates XSS / SQLi / CSRF Attacks]
end
// e2e/security-headers.spec.ts
import { test, expect } from '@playwright/test';
test('production responses include strict security headers', async ({ request }) => {
const response = await request.get('https://example.com');
const headers = response.headers();
expect(headers['strict-transport-security']).toContain('max-age=31536000; includeSubDomains; preload');
expect(headers['x-frame-options']).toBe('DENY');
expect(headers['x-content-type-options']).toBe('nosniff');
expect(headers['content-security-policy']).toContain("default-src 'self'");
});Integrate automated lockfile auditing into your CI pipeline to block known Common Vulnerabilities and Exposures (CVEs):
# Package manager security gate
npm audit --audit-level=highRun containerized OWASP ZAP baseline scans against staging environments:
docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py \
-t https://staging.example.com -g gen.conf -r zap-report.html| When to Use Security Testing | When NOT to Use Security Testing |
|---|---|
| ✅ Every PR build (SAST + Dependency SCA). | ❌ Pure frontend CSS styling verification. |
| ✅ Pre-release staging cutoffs (DAST + Pen-testing). | ❌ Mocked in-memory unit tests. |
| ✅ User authentication, payment, and sensitive PII input flows. | ❌ Static documentation blogs. |