Skip to main content

Lesson 3 of 10

DevSecOps & Shift-Left Security

DevSecOps integrates security testing throughout the software development lifecycle rather than treating it as a final gate before deployment. Finding vulnerabilities in development is 100x cheaper than finding them in production.

50 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Secure CI/CD Pipeline

Secure CI/CD Pipeline
# GitHub Actions pipeline with security gates
name: Secure CI/CD Pipeline

on: [push, pull_request]

jobs:
  security-checks:
    runs-on: ubuntu-latest
    steps:
    
    # 1. SAST - Static Application Security Testing
    # Analyze source code for vulnerabilities WITHOUT running it
    - name: Run Semgrep SAST
      uses: returntocorp/semgrep-action@v1
      with:
        config: p/security-audit p/owasp-top-ten
    # Detects: SQL injection, XSS, insecure deserialization, hardcoded secrets

    # 2. Secret Scanning - find hardcoded credentials in code
    - name: Scan for secrets with TruffleHog
      uses: trufflesecurity/trufflehog@main
      with:
        path: ./
        extra_args: --only-verified
    # Detects: AWS keys, GitHub tokens, private keys, API credentials
    
    # 3. SCA - Software Composition Analysis (vulnerable dependencies)
    - name: Dependency audit (npm)
      run: npm audit --audit-level=high
      # Fails build if HIGH or CRITICAL CVEs in node_modules
    
    - name: Check Python dependencies
      run: pip install safety && safety check
    
    # 4. Container image scanning
    - name: Scan Docker image for CVEs
      uses: aquasecurity/trivy-action@master
      with:
        image-ref: myapp:${{ github.sha }}
        severity: CRITICAL,HIGH
        exit-code: 1    # Fail pipeline if critical vulns found
    
    # 5. IaC Scanning - Terraform/CloudFormation security checks
    - name: Scan Terraform with tfsec
      uses: aquasecurity/tfsec-action@v1.0.0
      # Detects: open security groups, unencrypted S3, public RDS

  deploy:
    needs: security-checks    # Deployment BLOCKED if security checks fail
    runs-on: ubuntu-latest
    steps:
    - name: Deploy to production
      run: ./deploy.sh

SAST vs DAST vs IAST

  • SAST (Static Application Security Testing): Analyzes source code, bytecode, or binary without executing the application. Fast, finds issues early in development. High false-positive rate. Tools: Semgrep, SonarQube, Checkmarx, CodeQL (GitHub). Best for: code review automation, developer feedback loops
  • DAST (Dynamic Application Security Testing): Tests the running application by sending external attacks - black-box testing. Fewer false positives (actual running code). Finds runtime-only issues (authentication, session management). Tools: OWASP ZAP, Burp Suite Pro (in automation mode), Nuclei. Best for: pre-production testing of deployed applications
  • IAST (Interactive Application Security Testing): Instruments the application at runtime to observe internal behavior during functional testing. Most accurate - sees both source code context and runtime behavior. Tools: Contrast Security, Seeker. Best for: QA testing phase with real traffic
  • SCA (Software Composition Analysis): Identifies vulnerable open-source dependencies. Critical given 80%+ of modern code is third-party libraries. Tools: Snyk, Dependabot, OWASP Dependency-Check. Automate: weekly scans, automated PRs for dependency updates

Common Mistakes

  • Only running security scans at the end of the development cycle - fix costs increase 100x from development to production; integration in every PR is essential
  • Not triaging false positives - untriaged SAST alerts cause developer alert fatigue; dedicate time to suppresssing false positives with explanations
  • Using SCA without tracking transitive dependencies - a direct dependency with no known CVEs may use a transitive dependency with a critical CVE

Tip

Tip

Practice DevSecOps ShiftLeft Security in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

DevSecOps & Shift-Left Security

Practice Task

Note

Practice Task - (1) Write a working example of DevSecOps ShiftLeft Security from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with DevSecOps ShiftLeft Security is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • DevSecOps integrates security testing throughout the software development lifecycle rather than treating it as a final gate before deployment.
  • SAST (Static Application Security Testing): Analyzes source code, bytecode, or binary without executing the application. Fast, finds issues early in development. High false-positive rate. Tools: Semgrep, SonarQube, Checkmarx, CodeQL (GitHub). Best for: code review automation, developer feedback loops
  • DAST (Dynamic Application Security Testing): Tests the running application by sending external attacks - black-box testing. Fewer false positives (actual running code). Finds runtime-only issues (authentication, session management). Tools: OWASP ZAP, Burp Suite Pro (in automation mode), Nuclei. Best for: pre-production testing of deployed applications
  • IAST (Interactive Application Security Testing): Instruments the application at runtime to observe internal behavior during functional testing. Most accurate - sees both source code context and runtime behavior. Tools: Contrast Security, Seeker. Best for: QA testing phase with real traffic

Finished this lesson?

0 of 10 in Module 10
Sign in to save progress

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done