DevSecOps: Shifting Security Left into Pipelines
Embed SAST, DAST, container scanning, and IaC security checks into CI/CD pipelines so security gates are enforced automatically on every commit.
DevSecOps: Shifting Security Left into Pipelines is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is Shifting Security Left?
Shifting security left means integrating security activities earlier in the software development lifecycle — in the developer's IDE, code review, and CI/CD pipeline — rather than testing for security as a final gate before deployment. Traditional security reviews occurred at the end of the development cycle, making fixes expensive and time-consuming. Finding a vulnerability during development costs roughly 100x less to fix than discovering it in production after a breach.
What Is DevSecOps?
DevSecOps extends the DevOps model by integrating security as a shared responsibility across development, operations, and security teams throughout the entire SDLC. The goal is to automate security testing so it runs at every stage without slowing delivery. Security becomes a continuous property of the pipeline rather than a one-time checkpoint. In mature DevSecOps programs, developers receive security feedback within seconds of writing code, not weeks after a manual review.
SAST: Static Application Security Testing
SAST (Static Application Security Testing) analyzes source code, bytecode, or binary without executing the application. SAST tools scan for patterns that indicate vulnerabilities: SQL concatenation, unsanitized output, use of banned functions, hardcoded credentials, and insecure cryptographic usage. SAST runs in the CI pipeline on every commit, catching issues before they reach QA or production. Popular tools include Semgrep, SonarQube, Checkmarx, and Veracode.
# Semgrep SAST rule example:
# Detect raw SQL string concatenation (SQL injection risk):
# rules:
# - id: sql-injection-string-concat
# pattern: |
# $QUERY = '...' + $USER_INPUT
# $DB.execute($QUERY)
# message: 'SQL injection risk: use parameterized queries'
# severity: ERROR
# languages: [python]
# Running Semgrep in CI:
# semgrep --config auto --error src/
# -> Fails build if ERROR severity findings foundDAST: Dynamic Application Security Testing
DAST (Dynamic Application Security Testing) tests a running application by sending malicious payloads and observing responses — simulating real attacker behavior. Unlike SAST, DAST finds vulnerabilities that only appear at runtime: authentication flaws, session management issues, business logic bugs, and injection vulnerabilities in complex data flows. Popular DAST tools include OWASP ZAP (free), Burp Suite Enterprise, and Acunetix. DAST runs against a staging environment in the pipeline.
# OWASP ZAP automated DAST in CI pipeline:
# docker run -t owasp/zap2docker-stable zap-baseline.py \
# -t https://staging.myapp.com \
# -r zap-report.html \
# -I (do not fail on alerts, report only)
# For blocking builds on high findings:
# zap-full-scan.py -t https://staging.myapp.com \
# -l HIGH (fail if HIGH or CRITICAL alerts found)
# ZAP tests for:
# SQL injection, XSS, CSRF, insecure headers,
# path traversal, broken authentication, open redirectsContainer Image Scanning
Container images are built from base images containing OS packages, language runtimes, and application dependencies — all potential sources of known vulnerabilities. Container image scanning tools analyze image layers and identify vulnerable packages. Trivy (free, fast), Grype (Anchore), and Clair are widely used. Scans run as part of the image build pipeline, blocking promotion of images with critical CVEs to production registries.
# Trivy container scan in CI pipeline:
# trivy image --severity HIGH,CRITICAL \
# --exit-code 1 \
# myapp:latest
# Output example:
# library/python:3.9-slim (debian 11.6)
# ===================================
# CVE-2023-1234 CRITICAL openssl 1.1.1n-0+deb11u3 -> 1.1.1t
# CVE-2023-5678 HIGH libssl 1.1.1n -> 1.1.1t
# --exit-code 1 causes pipeline to fail
# on any HIGH or CRITICAL finding -> blocks push to registryInfrastructure as Code (IaC) Security Scanning
IaC security scanning analyzes Terraform, CloudFormation, Kubernetes manifests, and Helm charts for security misconfigurations before they are applied. Tools like Checkov and tfsec check for violations like: S3 buckets without server-side encryption, security groups allowing all inbound traffic, IAM roles with wildcard permissions, and Kubernetes pods running as root. IaC scanning prevents cloud misconfigurations before they reach any environment.
# Checkov IaC scan example:
# checkov -d ./terraform/ --compact
# Findings example:
# FAILED: CKV_AWS_20: S3 Bucket has an ACL defined which allows public access
# File: /terraform/s3.tf, Line: 15
# FAILED: CKV_AWS_57: S3 Bucket has server access logging disabled
# File: /terraform/s3.tf, Line: 15
# FAILED: CKV_AWS_24: Ensure no security groups allow all ingress traffic
# File: /terraform/sg.tf, Line: 8
# Passed checks: 47, Failed: 3, Skipped: 0Secret Scanning in Pipelines
Secret scanning tools check source code and commits for accidentally included credentials. Tools like truffleHog, GitLeaks, and detect-secrets scan git history and new commits for patterns matching API keys, connection strings, private keys, and JWT tokens. As a pre-commit hook, secret scanning blocks commits that include credentials. As a CI gate, it scans all files in the repository on every push and fails the build if secrets are detected.
# GitLeaks pre-commit hook configuration:
# .gitleaks.toml:
# [allowlist]
# description = 'Known false positives'
# paths = ['test/fixtures/fake_key.txt']
# Install as pre-commit hook:
# gitleaks protect --staged
# (scans staged files before commit is created)
# In CI pipeline:
# gitleaks detect --source=. --report-format=json \
# --report-path=gitleaks-report.json
# exit code 1 = secrets found -> blocks pipelineThreat Modeling in the SDLC
Threat modeling is a structured process for identifying security requirements and design flaws before code is written. The STRIDE model (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege) helps teams systematically enumerate threats against a system's data flow diagram. Threat modeling sessions occur during design, producing a prioritized list of threats that drive security requirements and inform SAST/DAST rule selection.
# STRIDE threat categories applied to a web login API:
# S - Spoofing: Attacker impersonates valid user
# Control: Strong authentication, MFA
# T - Tampering: Attacker modifies login request
# Control: TLS, HMAC, input validation
# R - Repudiation: User denies actions taken
# Control: Audit logging with tamper-evident storage
# I - Info Disclosure: Password exposed in logs
# Control: Never log sensitive fields
# D - Denial of Service: Flood login endpoint
# Control: Rate limiting, CAPTCHA
# E - Elevation of Privilege: Bypass authorization
# Control: Server-side authorization checksSecurity Gates: Blocking vs Advisory
DevSecOps pipelines implement security checks as either blocking gates (fail the build, prevent deployment) or advisory checks (report findings, allow deployment to continue). Critical and high severity findings from SAST, container scanning, and secret detection typically block. Medium and low findings generate notifications or tickets without blocking. This balance prevents security from halting all delivery while ensuring truly dangerous conditions cannot reach production automatically.
Security Metrics in DevSecOps
DevSecOps programs should be measured with clear metrics. Key metrics include: Mean Time to Remediate (MTTR) high-severity findings, vulnerability density (findings per 1,000 lines of code over time), escape rate (percentage of vulnerabilities found post-production vs pre-production), and pipeline security gate pass rate. Trending these metrics over time demonstrates the program's effectiveness and guides investment decisions for additional tooling or training.
Culture: Security as a Shared Responsibility
The hardest part of DevSecOps is cultural, not technical. Security must become every developer's responsibility, not just the security team's. This requires: developer security training (secure coding awareness), security champions embedded within development teams, blameless post-mortems when vulnerabilities reach production (focus on process improvement, not punishment), and executive commitment to allowing velocity trade-offs when genuine security risk requires it. Technology without culture change produces scanning tools that developers learn to ignore.
Quick Check
Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.
Lesson Recap
In this lesson you learned: DevSecOps integrates SAST, DAST, secret scanning, container scanning, and IaC scanning as automated pipeline gates, blocking high-severity findings prevents dangerous conditions from reaching production, and shifting security left reduces fix costs dramatically by catching vulnerabilities during development rather than after deployment. Next up we explore physical security controls for facilities and data centers.
Frequently asked questions
Is the “DevSecOps: Shifting Security Left into Pipelines” lesson free?
Yes — the full text of “DevSecOps: Shifting Security Left into Pipelines” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.
What will I learn in “DevSecOps: Shifting Security Left into Pipelines”?
Embed SAST, DAST, container scanning, and IaC security checks into CI/CD pipelines so security gates are enforced automatically on every commit. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cloud & IT Cert Prep?
No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “DevSecOps: Shifting Security Left into Pipelines” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cloud & IT Cert Prep lesson?
Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Input Validation and Output Encoding
- Secure Secret Management and Environment Variables
- Dependency Security and Software Composition Analysis
- DevSecOps: Shifting Security Left into Pipelines