josavicentevw

devsecops

0
0
# Install this skill:
npx skills add josavicentevw/ai-agent-skills --skill "devsecops"

Install specific skill from multi-skill repository

# Description

DevSecOps skill for security automation, vulnerability management, secure CI/CD pipelines, container security, secrets management, compliance, and security testing. Use when implementing security in development workflows, scanning for vulnerabilities, securing infrastructure, or when user mentions security automation, SAST, DAST, container scanning, or compliance.

# SKILL.md


name: devsecops
description: DevSecOps skill for security automation, vulnerability management, secure CI/CD pipelines, container security, secrets management, compliance, and security testing. Use when implementing security in development workflows, scanning for vulnerabilities, securing infrastructure, or when user mentions security automation, SAST, DAST, container scanning, or compliance.


DevSecOps

A comprehensive DevSecOps skill that helps integrate security practices throughout the software development lifecycle, from code to production.

Quick Start

Basic DevSecOps workflow:

# Shift security left
# Automate security checks in CI/CD
# Scan code, dependencies, containers, infrastructure
# Monitor and respond to security incidents
# Maintain compliance and audit trails

Core Capabilities

1. Security Scanning

Static Application Security Testing (SAST)
- Code analysis for security vulnerabilities
- Pattern detection for common flaws (SQL injection, XSS, etc.)
- Security code review automation
- Tools: SonarQube, Checkmarx, Semgrep, CodeQL

Dynamic Application Security Testing (DAST)
- Runtime security testing
- API security testing
- Penetration testing automation
- Tools: OWASP ZAP, Burp Suite, Acunetix

Software Composition Analysis (SCA)
- Dependency vulnerability scanning
- License compliance checking
- Open source security
- Tools: Snyk, Dependabot, WhiteSource, Black Duck

2. Container Security

Image Scanning
- Vulnerability scanning for base images
- Malware detection
- Configuration analysis
- Tools: Trivy, Clair, Anchore, Aqua Security

Runtime Security
- Container behavior monitoring
- Anomaly detection
- Runtime policy enforcement
- Tools: Falco, Sysdig, Aqua, Twistlock

Kubernetes Security
- Pod security policies
- Network policies
- RBAC configuration
- Admission controllers
- Tools: OPA, Kyverno, Falco, KubeSec

3. Infrastructure Security

Infrastructure as Code (IaC) Scanning
- Terraform security analysis
- CloudFormation scanning
- Kubernetes manifests validation
- Tools: Checkov, tfsec, Terrascan, kube-score

Cloud Security Posture Management (CSPM)
- AWS/Azure/GCP security configuration
- Compliance monitoring
- Misconfiguration detection
- Tools: AWS Security Hub, Azure Security Center, Prowler

Network Security
- Firewall rules analysis
- Network segmentation
- Traffic monitoring
- Security groups validation

4. Secrets Management

Secret Scanning
- Detect hardcoded credentials in code
- Git history scanning
- Configuration file analysis
- Tools: GitGuardian, TruffleHog, git-secrets, Gitleaks

Secret Storage & Rotation
- Centralized secret management
- Automated rotation
- Access control and auditing
- Tools: HashiCorp Vault, AWS Secrets Manager, Azure Key Vault

5. CI/CD Pipeline Security

Pipeline Hardening
- Secure pipeline configuration
- Build environment isolation
- Artifact signing and verification
- Supply chain security

Security Gates
- Automated security checks in pipeline
- Quality gates based on severity
- Break the build on critical issues
- Exception management

Compliance Automation
- SOC 2, HIPAA, PCI-DSS checks
- Policy as code
- Automated evidence collection
- Audit trail generation

6. Application Security

API Security
- API authentication and authorization
- Rate limiting and throttling
- Input validation
- API gateway security

Authentication & Authorization
- OAuth2/OIDC implementation
- JWT validation
- RBAC and ABAC
- Multi-factor authentication

Data Security
- Encryption at rest and in transit
- Data masking and anonymization
- Key management
- PII/PHI protection

7. Monitoring & Incident Response

Security Monitoring
- SIEM integration
- Log aggregation and analysis
- Threat detection
- Tools: ELK Stack, Splunk, Datadog Security

Vulnerability Management
- CVE tracking and prioritization
- Patch management
- Vulnerability disclosure
- SLA management

Incident Response
- Security incident playbooks
- Automated remediation
- Post-incident analysis
- Lessons learned documentation

8. Compliance & Governance

Compliance Frameworks
- SOC 2 Type II
- ISO 27001
- HIPAA
- PCI-DSS
- GDPR

Policy Management
- Security policies as code
- Policy enforcement
- Exception tracking
- Regular audits

Risk Assessment
- Threat modeling
- Risk scoring
- Attack surface analysis
- Security metrics and KPIs

Workflows

Secure SDLC Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    SECURE SDLC                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1. PLAN & DESIGN
   β”œβ”€β”€ Threat modeling
   β”œβ”€β”€ Security requirements
   └── Architecture security review

2. DEVELOP
   β”œβ”€β”€ Secure coding guidelines
   β”œβ”€β”€ IDE security plugins
   β”œβ”€β”€ Pre-commit hooks (secret scanning)
   └── Security-focused code reviews

3. BUILD
   β”œβ”€β”€ SAST (static code analysis)
   β”œβ”€β”€ SCA (dependency scanning)
   β”œβ”€β”€ Container image scanning
   └── IaC security scanning

4. TEST
   β”œβ”€β”€ DAST (dynamic testing)
   β”œβ”€β”€ API security testing
   β”œβ”€β”€ Penetration testing
   └── Security regression testing

5. DEPLOY
   β”œβ”€β”€ Container runtime security
   β”œβ”€β”€ Infrastructure security validation
   β”œβ”€β”€ Secrets injection
   └── Security configuration checks

6. OPERATE
   β”œβ”€β”€ Runtime monitoring
   β”œβ”€β”€ Vulnerability management
   β”œβ”€β”€ Incident response
   └── Compliance monitoring

7. MONITOR
   β”œβ”€β”€ Security logging
   β”œβ”€β”€ Threat detection
   β”œβ”€β”€ Anomaly detection
   └── Security metrics

CI/CD Security Pipeline

# Example: Security-Integrated Pipeline

stages:
  - security-scan
  - build
  - test
  - security-test
  - deploy

# Stage 1: Pre-build Security
security-scan:
  stage: security-scan
  script:
    # Secret scanning
    - trufflehog --regex --entropy=False .
    # SAST scanning
    - semgrep --config=auto --sarif > sast-results.sarif
    # Dependency scanning
    - snyk test --severity-threshold=high
    # IaC scanning
    - checkov -d . --framework terraform
  artifacts:
    reports:
      sast: sast-results.sarif

# Stage 2: Build with security
build:
  stage: build
  script:
    - docker build -t myapp:$CI_COMMIT_SHA .
    # Sign container image
    - cosign sign myapp:$CI_COMMIT_SHA

# Stage 3: Container scanning
container-scan:
  stage: test
  script:
    - trivy image --severity HIGH,CRITICAL myapp:$CI_COMMIT_SHA
    - docker scan myapp:$CI_COMMIT_SHA
  allow_failure: false  # Break build on critical issues

# Stage 4: Dynamic security testing
dast:
  stage: security-test
  script:
    # Deploy to staging
    - kubectl apply -f k8s/staging/
    # Run DAST
    - zap-baseline.py -t https://staging.example.com
    # API security test
    - postman collection run security-tests.json

# Stage 5: Deploy with security
deploy:
  stage: deploy
  script:
    # Verify image signature
    - cosign verify myapp:$CI_COMMIT_SHA
    # Apply security policies
    - kubectl apply -f k8s/policies/
    # Deploy application
    - kubectl apply -f k8s/production/
    # Verify deployment security
    - kube-bench run --targets master,node

Vulnerability Management Process

1. DISCOVERY
   └── Scan code, dependencies, containers, infrastructure

2. PRIORITIZATION
   β”œβ”€β”€ Severity assessment (CVSS score)
   β”œβ”€β”€ Exploitability analysis
   β”œβ”€β”€ Business impact evaluation
   └── Risk scoring

3. TRIAGE
   β”œβ”€β”€ Assign ownership
   β”œβ”€β”€ Set SLA based on severity
   β”œβ”€β”€ Create remediation tickets
   └── Track in vulnerability management system

4. REMEDIATION
   β”œβ”€β”€ Update dependencies
   β”œβ”€β”€ Apply patches
   β”œβ”€β”€ Implement workarounds
   └── Verify fixes

5. VALIDATION
   β”œβ”€β”€ Re-scan to confirm fix
   β”œβ”€β”€ Test for regressions
   └── Close vulnerability ticket

6. REPORTING
   β”œβ”€β”€ Update security dashboard
   β”œβ”€β”€ Notify stakeholders
   └── Document lessons learned

Security Patterns

Defense in Depth

Layer 1: Network Security
β”œβ”€β”€ Firewall rules
β”œβ”€β”€ Network segmentation
β”œβ”€β”€ DDoS protection
└── WAF (Web Application Firewall)

Layer 2: Application Security
β”œβ”€β”€ Input validation
β”œβ”€β”€ Output encoding
β”œβ”€β”€ Authentication & authorization
└── Session management

Layer 3: Data Security
β”œβ”€β”€ Encryption at rest
β”œβ”€β”€ Encryption in transit
β”œβ”€β”€ Data masking
└── Access controls

Layer 4: Infrastructure Security
β”œβ”€β”€ OS hardening
β”œβ”€β”€ Patch management
β”œβ”€β”€ Security configuration
└── Vulnerability scanning

Layer 5: Monitoring & Response
β”œβ”€β”€ Security logging
β”œβ”€β”€ SIEM
β”œβ”€β”€ Incident response
└── Threat intelligence

Zero Trust Architecture

1. VERIFY EXPLICITLY
   β”œβ”€β”€ Authenticate every request
   β”œβ”€β”€ Authorize based on all data points
   └── Use multi-factor authentication

2. LEAST PRIVILEGE ACCESS
   β”œβ”€β”€ Just-in-time access
   β”œβ”€β”€ Risk-based adaptive policies
   └── Data protection

3. ASSUME BREACH
   β”œβ”€β”€ Minimize blast radius
   β”œβ”€β”€ Segment access
   β”œβ”€β”€ End-to-end encryption
   └── Analytics for visibility

Security by Technology Stack

React/TypeScript

Security Concerns:
- XSS vulnerabilities
- Dependency vulnerabilities
- API security
- Authentication token storage

Tools & Practices:

# Dependency scanning
npm audit
snyk test

# SAST scanning
eslint --plugin security
semgrep --config=p/react

# Content Security Policy
# Add to HTML or headers
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'

Secure Coding:

// βœ… GOOD: Sanitize user input
import DOMPurify from 'dompurify';

const SafeComponent: React.FC<{html: string}> = ({html}) => {
  const sanitized = DOMPurify.sanitize(html);
  return <div dangerouslySetInnerHTML={{__html: sanitized}} />;
};

// ❌ BAD: Direct use of dangerouslySetInnerHTML
const UnsafeComponent = ({html}) => (
  <div dangerouslySetInnerHTML={{__html: html}} />
);

// βœ… GOOD: Secure token storage
// Store JWT in httpOnly cookie, not localStorage
// Use secure, sameSite=strict cookies

// ❌ BAD: Storing tokens in localStorage
localStorage.setItem('token', jwt);  // Vulnerable to XSS

Python/FastAPI

Security Concerns:
- SQL injection
- Command injection
- Insecure deserialization
- Dependency vulnerabilities

Tools & Practices:

# Dependency scanning
safety check
pip-audit
snyk test --file=requirements.txt

# SAST scanning
bandit -r .
semgrep --config=p/python

# Secret scanning
detect-secrets scan

Secure Coding:

# βœ… GOOD: Use parameterized queries
from sqlalchemy import text

def get_user(user_id: int):
    query = text("SELECT * FROM users WHERE id = :id")
    result = db.execute(query, {"id": user_id})
    return result.first()

# ❌ BAD: String concatenation (SQL injection)
def get_user_unsafe(user_id: str):
    query = f"SELECT * FROM users WHERE id = {user_id}"
    return db.execute(query)

# βœ… GOOD: Input validation
from pydantic import BaseModel, validator

class UserCreate(BaseModel):
    email: str
    password: str

    @validator('password')
    def validate_password(cls, v):
        if len(v) < 8:
            raise ValueError('Password must be at least 8 characters')
        return v

# βœ… GOOD: Rate limiting
from slowapi import Limiter
from slowapi.util import get_remote_address

limiter = Limiter(key_func=get_remote_address)

@app.post("/api/login")
@limiter.limit("5/minute")
async def login(credentials: LoginRequest):
    return await authenticate(credentials)

Java/Spring Boot

Security Concerns:
- Deserialization vulnerabilities
- XXE (XML External Entity)
- LDAP injection
- Dependency vulnerabilities

Tools & Practices:

# Dependency scanning
mvn dependency-check:check
snyk test

# SAST scanning
spotbugs -effort:max -low
semgrep --config=p/java

# Container scanning
trivy image myapp:latest

Secure Coding:

// βœ… GOOD: Use prepared statements
public User getUserById(int userId) {
    String sql = "SELECT * FROM users WHERE id = ?";
    return jdbcTemplate.queryForObject(sql, new Object[]{userId}, 
                                      new UserRowMapper());
}

// ❌ BAD: String concatenation
public User getUserByIdUnsafe(int userId) {
    String sql = "SELECT * FROM users WHERE id = " + userId;
    return jdbcTemplate.queryForObject(sql, new UserRowMapper());
}

// βœ… GOOD: Spring Security configuration
@Configuration
@EnableWebSecurity
public class SecurityConfig {
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
            .and()
            .authorizeRequests()
                .antMatchers("/api/public/**").permitAll()
                .anyRequest().authenticated()
            .and()
            .oauth2ResourceServer().jwt();
        return http.build();
    }
}

// βœ… GOOD: Secure password hashing
@Service
public class PasswordService {
    private final PasswordEncoder encoder = new BCryptPasswordEncoder(12);

    public String hashPassword(String plainPassword) {
        return encoder.encode(plainPassword);
    }
}

Kubernetes/Docker

Security Concerns:
- Container breakout
- Privilege escalation
- Insecure configurations
- Supply chain attacks

Tools & Practices:

# Container scanning
trivy image nginx:latest
docker scan nginx:latest
grype nginx:latest

# K8s security scanning
kubesec scan pod.yaml
kube-bench
kube-hunter

# Policy enforcement
kubectl apply -f pod-security-policy.yaml
gatekeeper install

Secure Configurations:

# βœ… GOOD: Secure Pod configuration
apiVersion: v1
kind: Pod
metadata:
  name: secure-pod
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
    fsGroup: 2000
    seccompProfile:
      type: RuntimeDefault
  containers:
  - name: app
    image: myapp:latest
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      runAsNonRoot: true
      capabilities:
        drop:
          - ALL
    resources:
      limits:
        cpu: "1"
        memory: "512Mi"
      requests:
        cpu: "0.5"
        memory: "256Mi"
    livenessProbe:
      httpGet:
        path: /health
        port: 8080
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080

# βœ… GOOD: Network Policy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: api-network-policy
spec:
  podSelector:
    matchLabels:
      app: api
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: frontend
    ports:
    - protocol: TCP
      port: 8080
  egress:
  - to:
    - podSelector:
        matchLabels:
          app: database
    ports:
    - protocol: TCP
      port: 5432

Security Tools Integration

GitHub Actions Security Pipeline

name: Security Pipeline

on: [push, pull_request]

jobs:
  secret-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: TruffleHog Secret Scan
        uses: trufflesecurity/trufflehog@main
        with:
          path: ./
          base: ${{ github.event.repository.default_branch }}
          head: HEAD

  sast:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Semgrep
        uses: returntocorp/semgrep-action@v1
        with:
          config: >-
            p/security-audit
            p/secrets
            p/owasp-top-ten
      - name: Run CodeQL
        uses: github/codeql-action/analyze@v2

  dependency-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Snyk
        uses: snyk/actions/node@master
        env:
          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
        with:
          args: --severity-threshold=high

  container-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build image
        run: docker build -t myapp:${{ github.sha }} .
      - name: Run Trivy
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: myapp:${{ github.sha }}
          format: 'sarif'
          output: 'trivy-results.sarif'
      - name: Upload results
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: 'trivy-results.sarif'

  iac-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Checkov
        uses: bridgecrewio/checkov-action@master
        with:
          directory: infrastructure/
          framework: terraform
          output_format: sarif
          output_file_path: checkov-results.sarif

GitLab CI Security Pipeline

include:
  - template: Security/SAST.gitlab-ci.yml
  - template: Security/Secret-Detection.gitlab-ci.yml
  - template: Security/Dependency-Scanning.gitlab-ci.yml
  - template: Security/Container-Scanning.gitlab-ci.yml
  - template: Security/DAST.gitlab-ci.yml

variables:
  SECURE_LOG_LEVEL: "debug"

stages:
  - test
  - security
  - deploy

security-scan:
  stage: security
  image: securego/gosec:latest
  script:
    - gosec -fmt json -out gosec-report.json ./...
  artifacts:
    reports:
      sast: gosec-report.json

custom-container-scan:
  stage: security
  image: aquasec/trivy:latest
  script:
    - trivy image --exit-code 1 --severity CRITICAL $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

Compliance Frameworks

SOC 2 Type II

Key Controls:

CC6.1: Logical and Physical Access Controls
β”œβ”€β”€ Multi-factor authentication
β”œβ”€β”€ Password policies
β”œβ”€β”€ Access reviews (quarterly)
└── Privileged access management

CC6.2: System Monitoring
β”œβ”€β”€ Security logging enabled
β”œβ”€β”€ Log retention (1 year)
β”œβ”€β”€ SIEM implementation
└── Anomaly detection

CC7.1: Threat Detection
β”œβ”€β”€ Vulnerability scanning (weekly)
β”œβ”€β”€ Penetration testing (annual)
β”œβ”€β”€ Security awareness training
└── Incident response plan

CC7.2: Infrastructure Security
β”œβ”€β”€ Network segmentation
β”œβ”€β”€ Encryption at rest and in transit
β”œβ”€β”€ Patch management
└── Configuration management

PCI-DSS

Requirements:

Requirement 1: Firewall Configuration
β”œβ”€β”€ Network diagram documentation
β”œβ”€β”€ Firewall rule reviews (6 months)
└── DMZ implementation

Requirement 2: System Security
β”œβ”€β”€ Change default passwords
β”œβ”€β”€ Disable unnecessary services
└── Security configuration standards

Requirement 3: Protect Cardholder Data
β”œβ”€β”€ Data encryption
β”œβ”€β”€ Minimize data retention
└── Secure key management

Requirement 6: Secure Development
β”œβ”€β”€ Security training for developers
β”œβ”€β”€ SAST/DAST scanning
β”œβ”€β”€ Code review process
└── Vulnerability management

Requirement 10: Logging and Monitoring
β”œβ”€β”€ Audit trails
β”œβ”€β”€ Log review
β”œβ”€β”€ Time synchronization
└── Log protection

Requirement 11: Security Testing
β”œβ”€β”€ Quarterly vulnerability scans
β”œβ”€β”€ Annual penetration testing
β”œβ”€β”€ IDS/IPS deployment
└── File integrity monitoring

Security Metrics & KPIs

Key Metrics to Track

1. VULNERABILITY METRICS
   β”œβ”€β”€ Mean Time to Detect (MTTD): < 24 hours
   β”œβ”€β”€ Mean Time to Remediate (MTTR): < 30 days (critical), < 90 days (high)
   β”œβ”€β”€ Vulnerability density: # of vulnerabilities per 1000 lines of code
   └── False positive rate: < 10%

2. SECURITY TESTING COVERAGE
   β”œβ”€β”€ Code coverage by SAST: > 80%
   β”œβ”€β”€ API endpoints covered by DAST: > 90%
   β”œβ”€β”€ Dependencies scanned: 100%
   └── Containers scanned: 100%

3. PIPELINE SECURITY
   β”œβ”€β”€ Security gate failures: Track trend
   β”œβ”€β”€ Time added by security scans: < 10% of total build time
   β”œβ”€β”€ Security exceptions granted: < 5% of findings
   └── Pipeline security incidents: 0

4. INCIDENT RESPONSE
   β”œβ”€β”€ Security incidents: Track count and trend
   β”œβ”€β”€ Incident response time: < 1 hour
   β”œβ”€β”€ Incident resolution time: Based on severity
   └── Post-incident reviews completed: 100%

5. COMPLIANCE
   β”œβ”€β”€ Policy compliance rate: > 95%
   β”œβ”€β”€ Audit findings: Track and trend
   β”œβ”€β”€ Training completion: 100% annually
   └── Access reviews completed: 100% quarterly

Security Dashboard

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         SECURITY DASHBOARD                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Vulnerability Status                        β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Critical:  3  ⚠️  (↓ 2 from last week) β”‚ β”‚
β”‚ β”‚ High:     12  ⚠️  (↑ 3 from last week) β”‚ β”‚
β”‚ β”‚ Medium:   45  ℹ️                        β”‚ β”‚
β”‚ β”‚ Low:     128  ℹ️                        β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                             β”‚
β”‚ Mean Time to Remediate                      β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Critical: 5 days  βœ… (Target: < 7)     β”‚ β”‚
β”‚ β”‚ High:    18 days  βœ… (Target: < 30)    β”‚ β”‚
β”‚ β”‚ Medium:  45 days  ⚠️  (Target: < 60)   β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                             β”‚
β”‚ Security Scan Coverage                      β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ SAST:  87% βœ…                           β”‚ β”‚
β”‚ β”‚ SCA:   100% βœ…                          β”‚ β”‚
β”‚ β”‚ DAST:  75% ⚠️                           β”‚ β”‚
β”‚ β”‚ Container: 100% βœ…                      β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Best Practices

1. Shift Security Left

  • Integrate security early in SDLC
  • Provide security training to developers
  • Use IDE security plugins
  • Implement pre-commit hooks

2. Automate Everything

  • Automated security scanning in CI/CD
  • Automated vulnerability management
  • Automated compliance checks
  • Infrastructure as code

3. Defense in Depth

  • Multiple layers of security controls
  • Assume each layer can be breached
  • Redundant security mechanisms
  • Principle of least privilege

4. Continuous Monitoring

  • Real-time security monitoring
  • Automated alerting
  • Log aggregation and analysis
  • Threat intelligence integration

5. Fail Securely

  • Secure defaults
  • Fail closed, not open
  • Error messages don't leak information
  • Graceful degradation

6. Security as Code

  • Policy as code
  • Automated compliance testing
  • Version controlled security configs
  • Immutable infrastructure

7. Regular Testing

  • Automated security testing
  • Penetration testing
  • Red team exercises
  • Chaos engineering for security

8. Incident Response Preparedness

  • Documented incident response plan
  • Regular drills and tabletop exercises
  • Clear escalation procedures
  • Post-incident reviews

9. Supply Chain Security

  • Verify software provenance
  • Sign and verify artifacts
  • SBOM (Software Bill of Materials)
  • Dependency pinning and updates

10. Security Culture

  • Security champions program
  • Regular security training
  • Blameless post-mortems
  • Security metrics visibility

Common Security Vulnerabilities

OWASP Top 10 (2021)

A01:2021 – Broken Access Control

Prevention:
- Implement proper authorization checks
- Deny by default
- Test access controls thoroughly
- Log access control failures

A02:2021 – Cryptographic Failures

Prevention:
- Use strong encryption (AES-256, RSA-2048+)
- Implement TLS 1.3
- Secure key management
- Don't store sensitive data unnecessarily

A03:2021 – Injection

Prevention:
- Use parameterized queries
- Validate and sanitize input
- Use ORM frameworks
- Implement WAF

A04:2021 – Insecure Design

Prevention:
- Threat modeling
- Secure design patterns
- Security requirements in user stories
- Security architecture review

A05:2021 – Security Misconfiguration

Prevention:
- Automated configuration management
- Remove default credentials
- Disable unnecessary features
- Regular security audits

A06:2021 – Vulnerable and Outdated Components

Prevention:
- Dependency scanning
- Regular updates
- Remove unused dependencies
- Monitor CVE databases

A07:2021 – Identification and Authentication Failures

Prevention:
- Multi-factor authentication
- Strong password policies
- Session management
- Rate limiting

A08:2021 – Software and Data Integrity Failures

Prevention:
- Digital signatures
- Verify integrity of updates
- Secure CI/CD pipeline
- Supply chain security

A09:2021 – Security Logging and Monitoring Failures

Prevention:
- Comprehensive logging
- Real-time monitoring
- Automated alerting
- Log protection

A10:2021 – Server-Side Request Forgery (SSRF)

Prevention:
- Input validation
- Network segmentation
- Whitelist allowed destinations
- Disable unused URL schemas

When to Use This Skill

Use the DevSecOps skill when you need to:

  • βœ… Implement security in CI/CD pipelines
  • βœ… Set up vulnerability scanning
  • βœ… Configure container security
  • βœ… Manage secrets securely
  • βœ… Implement compliance controls
  • βœ… Design secure architectures
  • βœ… Respond to security incidents
  • βœ… Perform security code reviews
  • βœ… Set up security monitoring
  • βœ… Automate security testing
  • βœ… Implement zero trust architecture
  • βœ… Secure cloud infrastructure
  • βœ… Configure authentication/authorization
  • βœ… Implement encryption
  • βœ… Conduct threat modeling

Examples

Example 1: Setting Up Security Pipeline

Request: "Set up a complete security scanning pipeline for a Python FastAPI application"

Response:

# .github/workflows/security.yml
name: Security Pipeline

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 0 * * 0'  # Weekly scan

jobs:
  secret-scanning:
    name: Secret Detection
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Gitleaks Scan
        uses: gitleaks/gitleaks-action@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  dependency-scanning:
    name: Dependency Vulnerabilities
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          pip install safety pip-audit
      - name: Safety Check
        run: safety check --json > safety-report.json
        continue-on-error: true
      - name: Pip Audit
        run: pip-audit --format json > pip-audit-report.json
      - name: Snyk Test
        uses: snyk/actions/python@master
        env:
          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
        with:
          args: --severity-threshold=high

  sast-scanning:
    name: Static Code Analysis
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Bandit Security Scan
        run: |
          pip install bandit[toml]
          bandit -r . -f json -o bandit-report.json
      - name: Semgrep Scan
        uses: returntocorp/semgrep-action@v1
        with:
          config: >-
            p/python
            p/owasp-top-ten
            p/security-audit

  container-scanning:
    name: Container Security
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build Docker Image
        run: docker build -t myapp:${{ github.sha }} .
      - name: Trivy Scan
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: myapp:${{ github.sha }}
          format: 'sarif'
          severity: 'CRITICAL,HIGH'
          exit-code: '1'
      - name: Grype Scan
        uses: anchore/scan-action@v3
        with:
          image: myapp:${{ github.sha }}
          fail-build: true
          severity-cutoff: high

  api-security-testing:
    name: DAST - API Security
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Start Application
        run: |
          docker-compose up -d
          sleep 10
      - name: OWASP ZAP API Scan
        uses: zaproxy/[email protected]
        with:
          target: 'http://localhost:8000/openapi.json'
          fail_action: true
      - name: Stop Application
        run: docker-compose down

  security-report:
    name: Generate Security Report
    needs: [secret-scanning, dependency-scanning, sast-scanning, container-scanning]
    runs-on: ubuntu-latest
    steps:
      - name: Collect Results
        run: echo "Security scans completed"
      - name: Post to Slack
        uses: slackapi/slack-github-action@v1
        with:
          payload: |
            {
              "text": "Security scan completed for ${{ github.repository }}"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

Example 2: Kubernetes Security Hardening

Request: "Harden Kubernetes deployment for production"

Response provided in examples folder (see EXAMPLES.md)

Example 3: Implementing Secrets Management

Request: "Set up secure secrets management with HashiCorp Vault"

Response provided in examples folder (see EXAMPLES.md)

Resources

Tools

SAST:
- SonarQube, Checkmarx, Veracode, Semgrep, CodeQL

SCA:
- Snyk, Dependabot, WhiteSource, Black Duck, OWASP Dependency-Check

DAST:
- OWASP ZAP, Burp Suite, Acunetix, Netsparker

Container Security:
- Trivy, Clair, Anchore, Aqua Security, Sysdig

IaC Security:
- Checkov, tfsec, Terrascan, Snyk IaC

Secrets Management:
- HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, CyberArk

Standards & Frameworks

  • OWASP Top 10
  • OWASP ASVS (Application Security Verification Standard)
  • NIST Cybersecurity Framework
  • CIS Benchmarks
  • ISO 27001
  • SOC 2
  • PCI-DSS

Learning Resources


Note: Security is everyone's responsibility. This skill provides guidance, but always consult security professionals for critical systems and stay updated with the latest threats and mitigation strategies.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.