Hari 29: Pipeline Consolidation — Satu Pipeline, 8 Scanner
3 min read

Hari 29: Pipeline Consolidation — Satu Pipeline, 8 Scanner

Dari 2 file workflow jadi 1. Semua 7 scanner (Gitleaks, Trivy, Semgrep, ZAP, Checkov) plus security gate di satu pipeline. 8/8 jobs green.

devsecops
ci/cd
github actions
security gate
pipeline consolidation
Share

Hari ke-29. Phase 2 hampir selesai. Hari ini mau rapikan pipeline yang udah terpisah jadi 2 file workflow — ci.yml dan infra.yml — digabung jadi satu.

Kenapa Konsolidasi?

Selama 14 hari terakhir (Day 16–28), aku nambah scanner satu per satu: Gitleaks (Day 3), Trivy SCA (Day 5), Semgrep SAST (Day 8), ZAP DAST (Day 25), Checkov IaC (Day 22), Trivy IaC (Day 21). Setiap kali nambah scanner yang baru, aku bikin workflow file terpisah karena lebih gampang.

Tapi masalahnya: 2 file workflow artinya 2 tempat untuk di-maintain. infra.yml cuma trigger kalau ada perubahan di terraform/** directory. Kalau ada commit yang ubah kode Go tapi tidak sentuh Terraform, IaC scanner tidak jalan. Tidak ideal.

Solusi: Satu ci.yml, 8 Jobs

Jadi aku gabungkan semuanya ke ci.yml:

# Job Tool Fungsi
1 build-and-test Go 1.26 Build + test + coverage
2 secret-scan Gitleaks Deteksi secret yang bocor
3 sca-scan Trivy FS Scan CVE di go.mod
4 sast-scan Semgrep Static analysis kode
5 dast-scan OWASP ZAP Dynamic scan running app
6 iac-checkov Checkov Scan Terraform misconfig
7 iac-trivy Trivy IaC Scan Terraform CVE
8 security-gate Quality gate final

Job 1–7 berjalan paralel. Job 8 (security-gate) needs semua 7 job di atasnya — kalau semua hijau, dia hijau. Kalau satu merah, dia merah. Single point of truth.

Security Gate Pattern

Ini bagian yang keren. Daripada lihat 7 job satu-satu untuk mastiin semua hijau, security-gate jadi single checkpoint:

security-gate:
  name: Security Gate
  needs: [build-and-test, secret-scan, sca-scan, sast-scan, dast-scan, iac-checkov, iac-trivy]
  runs-on: ubuntu-latest
  steps:
    - run: echo "All 7 security scans passed"

GitHub Branch Protection Rules bisa pakai job ini sebagai required status check.PR tidak bisa merge kalau security-gate merah. Simple, clean, effective.

Yang Dicatat: continue-on-error + needs

DAST scan (ZAP) pakai continue-on-error: true karena ZAP rule 10049 itu false positive untuk API. Faktanya, GitHub Actions menganggap job yang continue-on-error: true selalu success — meskipun step di dalamnya fail.

Itu sesuai dengan yang aku mau: DAST false positive tidak boleh block pipeline. Dan security-gate yang needs: dast-scan tetap hijau karena ZAP job selalu dianggap success.

Before vs After

Before:

.github/workflows/
├── ci.yml       # 5 jobs
└── infra.yml    # 2 jobs (trigger: terraform/** only)

After:

.github/workflows/
└── ci.yml       # 8 jobs (trigger: all pushes)

Hasil: 8/8 jobs green, satu file workflow, satu tempat untuk debug, satu source of truth.

Pelajaran Hari Ini

Satu pipeline = satu source of truth. Daripada maintain 2+ file workflow yang trigger-nya beda-beda, gabungkan semuanya. Lebih gampang debug, lebih gampang audit, lebih gampang maintain. Security gate pattern bikin "apakah pipeline aman?" jadi pertanyaan yes/no, bukan "cek 7 job satu-satu".

Repo

Semua code ada di: https://github.com/stayrelevantid/chalange-devsecops

Kesimpulan

Day 29 selesai. Fase 2 tinggal 1 hari lagi — Day 30 adalah retrospektif lengkap 15 hari Phase 2 (Day 16–30). Sampai jumpa besok.

Enjoyed this article? Share it!

Share

Diskusi & Komentar

Artikel Terkait