|
| 1 | +name: devsecops-pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + security-events: write |
| 12 | + packages: write # útil si luego publicas en GHCR |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: devsecops-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +env: |
| 19 | + # 🔁 Cambia esto para probar cada escenario (apps/10-secrets-leak, 20-sast-bugs, etc.) |
| 20 | + APP_DIR: apps/10-secrets-leak |
| 21 | + # Parámetros de despliegue local |
| 22 | + IMAGE_NAME: demo-app |
| 23 | + IMAGE_TAG: local |
| 24 | + KIND_CLUSTER: kind-devsecops |
| 25 | + SERVICE_RELEASE_NAME: demo |
| 26 | + |
| 27 | +jobs: |
| 28 | + # ────────────────────────────────────────────────────────────────────────────── |
| 29 | + # Secrets + SAST |
| 30 | + # ────────────────────────────────────────────────────────────────────────────── |
| 31 | + secrets: |
| 32 | + name: Secrets scanning (Gitleaks) |
| 33 | + runs-on: self-hosted |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + with: { fetch-depth: 0 } # para análisis que miran historial |
| 37 | + - name: Gitleaks |
| 38 | + uses: gitleaks/gitleaks-action@v2 |
| 39 | + env: |
| 40 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + # Si usas un gitleaks.toml propio, añade inputs/vars según la acción |
| 42 | + |
| 43 | + sast: |
| 44 | + name: SAST (Semgrep) |
| 45 | + runs-on: self-hosted |
| 46 | + needs: [secrets] |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + - name: Semgrep (bloqueante) |
| 50 | + run: | |
| 51 | + docker run --rm -v "$PWD:/src" returntocorp/semgrep:latest \ |
| 52 | + semgrep scan --config p/ci --config .semgrep |
| 53 | + - name: Export SARIF (para pestaña Security) |
| 54 | + run: | |
| 55 | + docker run --rm -v "$PWD:/src" returntocorp/semgrep:latest \ |
| 56 | + semgrep scan --config p/ci --config .semgrep --sarif -o semgrep.sarif || true |
| 57 | + - uses: github/codeql-action/upload-sarif@v3 |
| 58 | + with: { sarif_file: semgrep.sarif } |
0 commit comments