Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 2.97 KB

Security_Testing.md

File metadata and controls

84 lines (60 loc) · 2.97 KB

Security & Vulnerability Testing Architecture

Scope: Static code analysis (SAST), dynamic vulnerability scanning (DAST), software composition analysis (SCA), CSP validation, and security header verification.


Table of Contents


1. SAST vs. DAST vs. SCA Pipelines

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
Loading

2. Automated Security Headers & CSP Assertions

// 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'");
});

3. Automated Dependency Audits (SCA)

Integrate automated lockfile auditing into your CI pipeline to block known Common Vulnerabilities and Exposures (CVEs):

# Package manager security gate
npm audit --audit-level=high

4. Dynamic API Scanning with OWASP ZAP

Run 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

5. When to Use vs. When NOT to Use

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.