|
1 | 1 | # CI security scans (report-only) |
2 | 2 |
|
3 | | -Helm Watch PR/push CI includes three **report-only** security jobs (Linear [ARM-5](https://linear.app/armanfeyzi/issue/ARM-5)). They run on every workflow but do **not** fail the build yet. Follow-up [ARM-6](https://linear.app/armanfeyzi/issue/ARM-6) turns on hard gates for secrets and critical image CVEs. |
| 3 | +Pull request and push workflows include optional security jobs that **report findings without failing CI**. This lets maintainers review noise levels before enabling enforcement gates. |
4 | 4 |
|
5 | 5 | Workflow: [`.github/workflows/ci.yml`](../.github/workflows/ci.yml) |
6 | 6 |
|
7 | 7 | ## Jobs overview |
8 | 8 |
|
9 | 9 | | Job | Tools | What it checks | |
10 | 10 | |-----|-------|----------------| |
11 | | -| `security-static` | gitleaks | Git secrets | |
12 | | -| `semgrep` | Semgrep (`semgrep/semgrep` image) | Go/Kubernetes SAST rules | |
13 | | -| `container-security` | Trivy | CVEs and misconfig in the `helm-watch:ci` image | |
14 | | -| `test-and-build` | gosec (existing) | Go-specific high-confidence SAST | |
| 11 | +| `security-static` | gitleaks | Secrets in git history | |
| 12 | +| `semgrep` | Semgrep (`semgrep/semgrep` image) | Go and security-audit SAST rules | |
| 13 | +| `container-security` | Trivy | CVEs in the `helm-watch:ci` image | |
| 14 | +| `test-and-build` | gosec (existing) | Go high-confidence SAST (enforced) | |
15 | 15 |
|
16 | | -`container-security` depends on `test-and-build` and reuses the saved Docker image tarball. |
| 16 | +`container-security` depends on `test-and-build` and scans the Docker image artifact produced in that job. |
17 | 17 |
|
18 | 18 | ## gitleaks (secrets) |
19 | 19 |
|
20 | | -- **Why:** Catches API keys, tokens, and passwords committed to git — before they reach a public OSS repo or GHCR. |
21 | | -- **How:** Scans full git history (`fetch-depth: 0`). Uses the default gitleaks ruleset. |
22 | | -- **Report-only:** `continue-on-error: true` — findings appear in the job log; CI stays green. |
23 | | -- **Later (ARM-6):** Remove `continue-on-error` so any leak fails the workflow. |
| 20 | +- **Purpose:** Detect API keys, tokens, and passwords in commits before they are published. |
| 21 | +- **Configuration:** Full git history (`fetch-depth: 0`), default gitleaks ruleset. |
| 22 | +- **Current behavior:** `continue-on-error: true` — findings are logged; the job does not fail CI. |
| 23 | +- **Planned enforcement:** Fail the workflow when any secret is detected. |
24 | 24 |
|
25 | 25 | ## Semgrep (SAST) |
26 | 26 |
|
27 | | -- **Why:** Broader static analysis than gosec alone (logic bugs, unsafe patterns, security anti-patterns in Go and YAML-adjacent rules). |
28 | | -- **How:** Dedicated job using the official [`semgrep/semgrep`](https://hub.docker.com/r/semgrep/semgrep) container and `semgrep scan --config p/golang --config p/security-audit`. The legacy `semgrep/semgrep-action@v1` wrapper is deprecated and its `returntocorp/semgrep-agent` image is no longer pullable. |
29 | | -- **Report-only:** `continue-on-error: true` (findings may still exit non-zero). |
30 | | -- **Later (ARM-10):** Enable Semgrep `--error` / fail on ERROR severity after tuning false positives. |
| 27 | +- **Purpose:** Complement gosec with broader static rules for Go and common security anti-patterns. |
| 28 | +- **Configuration:** Job runs in the [`semgrep/semgrep`](https://hub.docker.com/r/semgrep/semgrep) container with `semgrep scan --config p/golang --config p/security-audit`. |
| 29 | +- **Current behavior:** `continue-on-error: true`. |
| 30 | +- **Planned enforcement:** Fail on ERROR-severity findings after false positives are triaged. |
31 | 31 |
|
32 | 32 | ## Trivy (container image) |
33 | 33 |
|
34 | | -- **Why:** The runtime image can include vulnerable OS packages or dependencies not visible in `go test`. |
35 | | -- **How:** After `docker build`, the image is saved as an artifact, loaded in `container-security`, and scanned with `aquasecurity/trivy-action`. Table output goes to the log; SARIF is uploaded as `trivy-image-sarif` for optional review in GitHub / external tools. |
36 | | -- **Report-only:** `exit-code: "0"` — never fails the job regardless of severity. |
37 | | -- **Later (ARM-6):** Fail on CRITICAL and HIGH; use `.trivyignore` only for documented exceptions. |
| 34 | +- **Purpose:** Scan the runtime image for OS and dependency CVEs not covered by unit tests. |
| 35 | +- **Configuration:** [`aquasecurity/trivy-action`](https://github.com/aquasecurity/trivy-action) (pinned to a release SHA). Table output in logs; SARIF uploaded as `trivy-image-sarif`. |
| 36 | +- **Current behavior:** `exit-code: "0"` — results are informational only. |
| 37 | +- **Planned enforcement:** Fail on CRITICAL and HIGH severities, with `.trivyignore` for documented exceptions only. |
38 | 38 |
|
39 | | -## What stays unchanged |
| 39 | +## Unchanged checks |
40 | 40 |
|
41 | | -- **gosec** remains in `test-and-build` and already fails on high-severity Go issues. |
42 | | -- **golangci-lint**, tests, Helm lint, and image build behavior are unchanged. |
| 41 | +- **gosec** in `test-and-build` continues to fail on high-severity Go issues. |
| 42 | +- Tests, golangci-lint, Helm lint, and image build steps are unchanged. |
43 | 43 |
|
44 | | -## Reading results in GitHub Actions |
| 44 | +## Viewing results in GitHub Actions |
45 | 45 |
|
46 | | -1. Open the CI run for your PR or push. |
47 | | -2. Open **Security — secrets & SAST** or **Security — container image**. |
48 | | -3. Expand the failing-looking steps — with report-only mode the job is still green; read the log for `leak`, `finding`, or Trivy `TOTAL`. |
| 46 | +1. Open the CI run for the branch or pull request. |
| 47 | +2. Inspect **Security — secrets**, **Security — SAST**, or **Security — container image**. |
| 48 | +3. Review step logs for gitleaks leaks, Semgrep rule IDs, or Trivy severity counts (jobs may show warnings while report-only mode is enabled). |
49 | 49 |
|
50 | | -## Rollout plan (from practice lab) |
| 50 | +## Enforcement roadmap |
51 | 51 |
|
52 | | -| Week | Change | |
53 | | -|------|--------| |
54 | | -| 1 (now) | Report-only: gitleaks, Semgrep, Trivy image | |
55 | | -| 2 | Fail on gitleaks + Trivy CRITICAL/HIGH; add govulncheck (ARM-7) | |
56 | | -| 3 | Semgrep error gate (ARM-10) | |
57 | | - |
58 | | -Training notes: see Notion page under **Practice · Lab CI/CD (GitHub Actions)** (helm-watch Week 1 implementation). |
| 52 | +| Phase | Change | |
| 53 | +|-------|--------| |
| 54 | +| Current | Report-only gitleaks, Semgrep, and Trivy image scans | |
| 55 | +| Next | Fail CI on secret leaks and Trivy CRITICAL/HIGH | |
| 56 | +| Later | Dependency scanning (govulncheck); Semgrep ERROR gate | |
0 commit comments