Skip to content

DevSecOps and Workflows

DRomothewriter edited this page Nov 26, 2026 · 1 revision

DevSecOps and Workflows

Pipeline completo de CI/CD, análisis de seguridad estático/dinámico, integridad de recursos (SRI), supply chain con Cosign y despliegue sin llaves estáticas a S3 + CloudFront.


Flujo del Pipeline

flowchart LR
    FEAT["PR (feature/*, fix/*, chore/*)"] --> CIDEV["ci-dev.yml (ESLint Security, Build, TruffleHog, npm audit, Snyk SCA)"]
    CIDEV --> DEV["Branch dev (protect-dev)"]
    DEV -->|"PR dev -> main"| SECMAIN["security-main.yml (Karma lcov, SonarCloud, CodeQL, Snyk Code, Syft/Grype, OWASP ZAP)"]
    SECMAIN --> MAIN["Branch main (protect-main)"]
    MAIN -->|"GitHub Release vX.Y.Z"| REL["release.yml (Build SRI, Tarball reproducible, SBOM, Grype, Cosign, SLSA)"]
    REL -->|"Manual Approval (environment: production)"| DEPLOY["AWS OIDC -> S3 Sync (--delete) + CloudFront Invalidation (/*)"]
Loading

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

Workflow Disparador Gates y Herramientas ¿Bloquea merge/deploy?
ci-dev.yml pull_request → dev Bloquea main → dev, npm run lint:security, npm run build, TruffleHog (--only-verified), Dependency Review (high), npm audit --omit=dev --audit-level=high, Snyk SCA (high, SARIF) Sí — los 3 checks son requeridos por protect-dev
security-main.yml pull_request → main, push → main, workflow_dispatch Exige head_ref == dev, Node workflow tests (node --test tests/*.test.js) + Karma/Jasmine (ChromeHeadless + lcov), SonarCloud (qualitygate.wait=true), CodeQL (security-extended), Snyk Code (high), Syft SBOM + Grype (high, only-fixed), OWASP ZAP Baseline (-j Ajax Spider sobre 127.0.0.1:4200 + .zap/rules.tsv) Sí — los 7 checks + 1 aprobación + Code Owner (@DRomothewriter) son requeridos por protect-main
release.yml release: [published], workflow_dispatch Valida SemVer vX.Y.Z + ancestro de origin/main, build producción con SRI, tarball reproducible (orbit-frontend-<tag>.tar.gz), Syft SBOM, Grype, firma/verificación Cosign Keyless, SLSA Provenance + SBOM Attestation, deploy OIDC a S3 + CloudFront Sí — aborta en Grype o falla de verificación SHA256/Cosign; exige aprobación manual en production

Note

CodeRabbit (.coderabbit.yaml): Revisa PRs a dev y main en español (assertive, request_changes_workflow: true) verificando XSS, teardown de SocketService (socket.off + clearTimeout), rel="noopener noreferrer" y permisos de workflows.


Seguridad de Build y Gobernanza

  • Subresource Integrity (SRI): angular.json habilita "subresourceIntegrity": true y "outputHashing": "all" en builds de producción.
  • ESLint Security (eslint.config.mjs): Bloquea eval, new Function, javascript: URLs, innerHTML, outerHTML, bypassSecurityTrustHtml, bypassSecurityTrustScript y document.write.
  • Rulesets (.github/rulesets/): protect-dev, protect-main y protect-release-tags se aplican vía scripts/apply-github-policies.sh.
  • Dependabot (.github/dependabot.yml): PRs semanales (lunes 08:00 America/Mexico_City) hacia dev para npm (agrupado) y github-actions.

Secretos y Variables Requeridos

Tipo Nombre Uso
Secret AWS_ROLE_ARN Rol IAM asumido vía OIDC (release.yml)
Secret SONAR_TOKEN Escaneo SonarCloud (security-main.yml)
Secret SNYK_TOKEN Snyk SCA y Snyk Code
Variable / Secret S3_FRONTEND_BUCKET_NAME Bucket S3 privado de destino (aws s3 sync --delete)
Variable / Secret CLOUDFRONT_DISTRIBUTION_ID Distribución CloudFront para invalidación /*
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-Frontend)

Cómo Funciona el Despliegue a Producción

  1. build-sign-attest compila la SPA en modo production (con SRI), empaqueta un tarball reproducible, genera SBOMs, corre Grype y firma con Cosign Keyless adjuntando los artefactos al GitHub Release.
  2. deploy-production espera aprobación manual en environment: production.
  3. Antes de subir archivos, re-valida sha256sum -c SHA256SUMS.txt y cosign verify-blob, autentica a AWS por OIDC, sincroniza s3://$S3_BUCKET/ con --delete e invalida /* en CloudFront.

Clone this wiki locally