Security in the DevOps Context

The DevSecOps Mindset


Secure Coding and Vulnerability Scanning

Secure Coding Principles

  1. Input Validation & Output Encoding
  2. Principle of Least Privilege
  3. Dependency Management
  4. Error Handling & Logging
  5. Cryptography Best Practices

Automated Vulnerability Scanning

Scan Type Tools & Techniques When to Run
SAST SonarQube, Checkmarx, Fortify, GitHub CodeQL On every PR / commit
DAST OWASP ZAP, Burp Suite, Nikto Against deployed staging
SCA Snyk, Dependabot, OWASP Dependency-Check, Trivy On every build / PR
IAST Contrast Security, Seeker During integration tests
RASP Signal Sciences, Waratek In production live traffic

Example: Integrating SAST in Jenkins Pipeline

pipeline {
  agent any
  stages {
    stage('Static Analysis') {
      steps {
        // Run SonarQube scanner
        withSonarQubeEnv('MySonarServer') {
          sh 'mvn clean verify sonar:sonar'
        }
      }
    }
    stage('Quality Gate') {
      steps {
        timeout(time: 2, unit: 'MINUTES') {
          waitForQualityGate abortPipeline: true
        }
      }
    }
  }
}

Example: Adding DAST with OWASP ZAP in GitLab CI

stages:
  - build
  - test
  - security

security_scan:
  image: owasp/zap2docker-stable
  stage: security
  script:
    - zap-baseline.py -t <http://web-app:8080> -r zap-report.html
  artifacts:
    paths:
      - zap-report.html