Skip to content

Latest commit

 

History

History
402 lines (294 loc) · 10.5 KB

File metadata and controls

402 lines (294 loc) · 10.5 KB

Module 01: Introduction to Shift-Left Security

📋 Module Overview

Duration: 2 hours
Level: Basic
Prerequisites: Basic understanding of software development lifecycle

🎯 Learning Objectives

By the end of this module, you will:

  • Understand the concept and importance of shift-left security
  • Learn the cost implications of finding bugs at different stages
  • Identify key security practices for each development phase
  • Understand the DevSecOps culture and shared responsibility model
  • Set up your initial development environment

📚 Module Contents

  1. Introduction
  2. The Evolution of Security
  3. Understanding Shift-Left
  4. DevSecOps Fundamentals
  5. Exercises

Introduction

Security has traditionally been a gate at the end of the development process. This module explores why that approach is no longer sufficient and how shift-left security transforms the way we build secure applications.

The Evolution of Security

Traditional Security Model

graph LR
    A[Development] --> B[Testing]
    B --> C[Security Review]
    C --> D[Production]
    C -->|Issues Found| A
    
    style C fill:#f96,stroke:#333,stroke-width:2px
Loading

Problems with this approach:

  • Security issues found late are expensive to fix
  • Delays in release cycles
  • Security team becomes a bottleneck
  • Developers lack security context

Modern Shift-Left Approach

graph LR
    A[Secure Design] --> B[Secure Development]
    B --> C[Secure Testing]
    C --> D[Secure Deployment]
    D --> E[Secure Operations]
    
    subgraph "Continuous Security"
        A -.-> F[Security Scanning]
        B -.-> F
        C -.-> F
        D -.-> F
        E -.-> F
    end
    
    style F fill:#6f9,stroke:#333,stroke-width:2px
Loading

Understanding Shift-Left

The Cost of Security Issues

Research shows that fixing security issues becomes exponentially more expensive as they progress through the SDLC:

graph TB
    subgraph "Cost to Fix Security Issues"
        A[Design: $80] --> B[Development: $240]
        B --> C[Testing: $960]
        C --> D[QA: $7,600]
        D --> E[Production: $4.45M]
    end
    
    style E fill:#f66,stroke:#333,stroke-width:4px
Loading

Key Principles of Shift-Left Security

  1. Prevention over Detection

    • Secure coding practices
    • Security requirements in design
    • Threat modeling early
  2. Automation First

    • Automated security scanning
    • Policy as code
    • Continuous compliance
  3. Developer Empowerment

    • Security training
    • Developer-friendly tools
    • Fast feedback loops
  4. Shared Responsibility

    • Everyone owns security
    • Security champions in teams
    • Collaborative culture

DevSecOps Fundamentals

What is DevSecOps?

DevSecOps extends DevOps by embedding security practices throughout the entire software development lifecycle.

graph TB
    subgraph "DevSecOps Infinity Loop"
        A[Plan] --> B[Code]
        B --> C[Build]
        C --> D[Test]
        D --> E[Release]
        E --> F[Deploy]
        F --> G[Operate]
        G --> H[Monitor]
        H --> A
        
        I[Security] -.-> A
        I -.-> B
        I -.-> C
        I -.-> D
        I -.-> E
        I -.-> F
        I -.-> G
        I -.-> H
    end
    
    style I fill:#bbf,stroke:#333,stroke-width:2px
Loading

Cultural Transformation

Moving from traditional security to DevSecOps requires:

  1. Breaking Down Silos

    • Security teams collaborate with developers
    • Shared goals and metrics
    • Cross-functional teams
  2. Continuous Learning

    • Security training for developers
    • Development understanding for security
    • Regular knowledge sharing
  3. Fail Fast, Fix Fast

    • Embrace security findings
    • Quick remediation cycles
    • Learning from incidents

Building a Security-First Culture

Creating a security-first culture requires:

  1. Leadership Buy-In: Security starts at the top
  2. Developer Empowerment: Give teams the tools and training
  3. Continuous Learning: Security landscape constantly evolves
  4. Shared Responsibility: Everyone owns security
  5. Celebration of Success: Recognize security achievements

Continuous Security Feedback Cycle

Security Fundamentals for Developers

📝 Exercises

Exercise 1: Understanding the Impact (20 minutes)

Objective: Calculate the potential cost savings of shift-left security

  1. Consider a typical security vulnerability (e.g., SQL injection)

  2. Research the average time to fix at each stage:

    • During coding: 30 minutes
    • During testing: 3 hours
    • In production: 10 hours + incident response
  3. Calculate the cost difference using these hourly rates:

    • Developer: $100/hour
    • QA Engineer: $80/hour
    • Security Team: $150/hour
    • Incident Response: $500/hour
  4. Document your findings in exercises/01-cost-analysis.md

Expected Output: A cost comparison showing ROI of shift-left practices

Exercise 2: Security in Your SDLC (30 minutes)

Objective: Map security practices to your development lifecycle

  1. Create a diagram of your current (or ideal) SDLC phases

  2. For each phase, identify:

    • Current security practices (if any)
    • Potential security improvements
    • Tools that could help
  3. Use this template:

# SDLC Security Mapping

## Planning Phase
- **Current Practices**: [List current practices]
- **Improvements**: [List potential improvements]
- **Tools**: [List applicable tools]

## Development Phase
- **Current Practices**: [List current practices]
- **Improvements**: [List potential improvements]
- **Tools**: [List applicable tools]

[Continue for all phases...]
  1. Save as exercises/02-sdlc-mapping.md

Exercise 3: Setting Up Git Security (25 minutes)

Objective: Configure basic Git security settings

  1. Configure Git with security in mind:
# Set up Git identity
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

# Enable commit signing (optional but recommended)
git config --global commit.gpgsign true

# Set up credential helper
git config --global credential.helper cache
  1. Create a .gitignore file for security:
# Security-sensitive files
.env
.env.*
*.key
*.pem
*.p12
*.pfx
secrets/
credentials/

# IDE and system files
.vscode/
.idea/
.DS_Store
Thumbs.db
  1. Create pre-commit hooks for security:

Create .git/hooks/pre-commit:

#!/bin/bash
# Check for common security issues

# Check for AWS keys
if git diff --cached --name-only | xargs grep -E "AKIA[0-9A-Z]{16}" 2>/dev/null; then
    echo "ERROR: AWS Access Key detected in commit"
    exit 1
fi

# Check for private keys
if git diff --cached --name-only | xargs grep -E "BEGIN (RSA |DSA |EC |OPENSSH )?PRIVATE KEY" 2>/dev/null; then
    echo "ERROR: Private key detected in commit"
    exit 1
fi

echo "Security checks passed"
exit 0
  1. Make the hook executable:
chmod +x .git/hooks/pre-commit

Exercise 4: Create a Security Checklist (20 minutes)

Objective: Build a practical security checklist for development

  1. Create a security checklist for your team covering:

    • Code review security items
    • Pre-commit checks
    • Dependencies management
    • Secrets handling
  2. Use this template in exercises/04-security-checklist.md:

# Development Security Checklist

## Code Review
- [ ] No hardcoded secrets or credentials
- [ ] Input validation implemented
- [ ] SQL queries use parameterization
- [ ] Error messages don't expose sensitive info
- [ ] [Add more items...]

## Before Committing
- [ ] Run security linter
- [ ] Check for exposed secrets
- [ ] Update dependencies
- [ ] [Add more items...]

## Dependencies
- [ ] All dependencies from trusted sources
- [ ] No known vulnerabilities
- [ ] Licenses reviewed
- [ ] [Add more items...]

Exercise 5: Security Metrics Dashboard (25 minutes)

Objective: Design metrics for measuring security improvement

  1. Identify key security metrics:

    • Mean Time to Detect (MTTD)
    • Mean Time to Remediate (MTTR)
    • Number of vulnerabilities by severity
    • Security training completion rate
  2. Create a simple dashboard mockup showing these metrics

  3. Document how you would collect each metric

Save your design in exercises/05-metrics-dashboard.md

🎯 Module Summary

Key Takeaways

  1. Shift-left security moves security practices earlier in the development lifecycle
  2. Cost savings are dramatic when issues are caught early
  3. DevSecOps requires cultural change, not just tools
  4. Automation is key to scalable security
  5. Shared responsibility means everyone owns security

Skills Acquired

  • ✅ Understanding of shift-left principles
  • ✅ Basic Git security configuration
  • ✅ Security checklist creation
  • ✅ Cost-benefit analysis of security practices
  • ✅ SDLC security mapping

📚 Additional Resources

Required Reading

Recommended Videos

Tools to Explore

✅ Module Completion Checklist

Before moving to the next module, ensure you have:

  • Completed all 5 exercises
  • Created your security checklist
  • Configured Git security settings
  • Understood the cost implications of shift-left
  • Mapped security to SDLC phases

🚀 Next Steps

Ready to dive deeper? Continue to Module 02: GitHub Advanced Security Fundamentals where we'll explore powerful security tools built into GitHub.


Questions or Issues? Check our FAQ or open an issue.


🧭 Navigation

Previous Up Next
🚀 Quick Start Guide 📚 All Modules Module 02: GitHub Advanced Security →

Quick Links: 🏠 Home📖 Workshop Overview🛡️ Security FAQ