Skip to content

DevSecOps and Workflows

DRomothewriter edited this page Nov 26, 2026 · 1 revision

DevSecOps and Workflows

Pipeline de validación IaC, cumplimiento de seguridad, detección semanal de drift y aplicación controlada a producción mediante firmas Cosign y aprobación manual.


Flujo del Pipeline

flowchart LR
    FEAT["PR (feature/*, fix/*, chore/*)"] --> CIDEV["ci-dev.yml (State Guard, fmt/validate, TruffleHog, TFLint, Trivy)"]
    CIDEV --> DEV["Branch dev (protect-dev)"]
    DEV -->|"PR dev -> main"| SECMAIN["security-main.yml (terraform test, Node tests, SonarCloud, Snyk IaC, Checkov, Trivy, Syft/Grype, Plan Read-Only)"]
    SECMAIN --> MAIN["Branch main (protect-main)"]
    MAIN -->|"GitHub Release vX.Y.Z"| REL["release.yml (Bundle, SBOM, Trivy/Checkov, Cosign Keyless, SLSA)"]
    REL -->|"Manual Approval (environment: production)"| APPLY["AWS OIDC -> terraform apply tfplan"]
    CRON["Cron Lunes 09:00 UTC"] --> DRIFT["drift.yml (terraform plan -detailed-exitcode)"]
Loading

Catálogo de Workflows (.github/workflows/)

Workflow Disparador Gates y Herramientas ¿Bloquea merge/apply?
ci-dev.yml pull_request → dev Bloquea main → dev y archivos *.tfstate/terraform.tfvars trackeados, terraform fmt -check, terraform validate, TruffleHog (--only-verified), TFLint (aws v0.35.0), Trivy Config (HIGH,CRITICAL, .trivyignore) Sí — los 3 checks son requeridos por protect-dev
security-main.yml pull_request → main, push → main, workflow_dispatch Exige head_ref == dev, prohibido ejecutar terraform apply, terraform test (12 tests) + node --test tests/security.workflows.test.js, SonarCloud, Snyk IaC (high), Checkov (--soft-fail + SARIF/JUnit) + Trivy Config, Syft SBOM + Grype (high, only-fixed), Terraform Plan Preview (Read-Only) vía OIDC Sí — los 6 checks obligatorios son requeridos por protect-main
release.yml release: [published], workflow_dispatch (apply_to_production default false) Valida SemVer vX.Y.Z + ancestro de origin/main, empaqueta orbit-iac-<tag>.tar.gz, Syft SBOM, Trivy + Checkov, firma/verifica Cosign Keyless, SLSA Provenance + SBOM Attestation, re-verifica firma y ejecuta terraform apply con aprobación manual Sí — aborta si falla verificación Cosign o gates; exige aprobación manual en production
drift.yml schedule (0 9 * * 1 UTC) y workflow_dispatch Autentica vía AWS OIDC y corre terraform plan -detailed-exitcode -no-color, sube reporte 30 días Falla explícitamente si exit code == 2 (drift detectado)

Note

CodeRabbit (.coderabbit.yaml): Revisa automáticamente PRs hacia dev y main en español (assertive, request_changes_workflow: true) con reglas para **/*.tf, docker/**, docker/nginx/** y .github/workflows/**.


Gobernanza y Excepciones Documentadas

  • Rulesets (.github/rulesets/): protect-dev, protect-main y protect-release-tags se aplican vía scripts/apply-github-policies.sh, que además configura el entorno production con aprobador manual restringido a main y tags v*.
  • Dependabot (.github/dependabot.yml): PRs semanales (lunes 08:00 America/Mexico_City) hacia dev para terraform y github-actions.
  • Excepciones justificadas en .trivyignore y .snyk:
    • AWS-0132: S3 usa SSE-S3 (AES256) gratuito en lugar de KMS CMK.
    • AWS-0011: CloudFront sin AWS WAF en v1 por costo.
    • AWS-0031: ECR MUTABLE para actualizar :latest de forma controlada.
    • AWS-0087, AWS-0093, SNYK-CC-TF-96, SNYK-CC-TF-98: Lectura pública controlada en el bucket de media (s3:GetObject).
    • AWS-0104: Egress abierto en EC2 para ECR, apt, Let's Encrypt, SMTP y MongoDB Atlas.

Secretos y Variables Requeridos

Tipo Nombre Uso
Secret AWS_ROLE_ARN Rol IAM OIDC para plan read-only, drift y terraform apply
Secret SONAR_TOKEN Escaneo SonarCloud (security-main.yml)
Secret SNYK_TOKEN Escaneo Snyk IaC (tolerante a dependabot[bot] si no existe)
Variable AWS_REGION Región AWS (default us-east-2)
Variable SONAR_ORGANIZATION Organización SonarCloud (default dromothewriter)
Variable SONAR_PROJECT_KEY Proyecto SonarCloud (default DRomothewriter_Orbit-IaC)

Clone this wiki locally