Skip to content

cloud-infra: add trivy-scan skill and wire it into verification gates#1

Merged
makigjuro merged 2 commits into
mainfrom
marjangjuroski/add-trivy-scan-skill
Apr 19, 2026
Merged

cloud-infra: add trivy-scan skill and wire it into verification gates#1
makigjuro merged 2 commits into
mainfrom
marjangjuroski/add-trivy-scan-skill

Conversation

@makigjuro
Copy link
Copy Markdown
Owner

Summary

  • Adds a dedicated /trivy-scan skill under cloud-infra that runs trivy config against Terraform modules and Helm charts.
  • Wires the scan into the existing verification flow: /infra-lint invokes it as a final step, and /complete-infra runs it as a parallel track in Phase 1 alongside format/validate/helm-lint.
  • Updates the infra-reviewer agent to correlate .trivyignore suppressions with the current diff instead of re-running the scanner.

Why

Working through SparkReach F01 Azure infra (issue surfaced in my sparkreach repo), terraform validate and helm lint didn't catch:

  • Public network access on Postgres Flexible Server and Key Vault (AZU-0022, AZU-0013)
  • Missing Postgres audit logging (AZU-0019, AZU-0024)
  • Unclassified Key Vault secrets (AZU-0015)

The infra-reviewer agent is great for judgement calls but doesn't carry Aqua Security's curated IaC rule library. trivy config does, and takes seconds. The gap felt like a missing verification gate in cloud-infra.

Changes

New skill: plugins/cloud-infra/skills/trivy-scan/

  • SKILL.md — user-invocable; arguments --strict, --warn-only, --severity; documents the .trivyignore convention (every suppression must have a justifying comment).
  • scripts/scan-trivy.sh — reusable script, consumed from other skills via bash {plugin-skills-path}/trivy-scan/scripts/scan-trivy.sh.
    • Preflights trivy binary, prints brew / curl install hints if missing (never auto-installs).
    • Auto-picks .trivyignore at $TF_PARENT/.trivyignore or $(dirname $CHARTS_PATH)/.trivyignore.
    • Default severity fail set: CRITICAL,HIGH,MEDIUM. TRIVY_STRICT=1 adds LOW. TRIVY_WARN_ONLY=1 makes it non-blocking.

Wired into existing skills

  • infra-lint — new "Security Scan" section that invokes /trivy-scan, new quality-gate row.
  • complete-infra — Phase 1 gains Track D (security scan) running in parallel with fmt/validate/helm-lint; quality-gate output updated.

Agent update

  • infra-reviewer — new "Scanner Correlation (trivy)" section. The agent no longer re-runs trivy; it sanity-checks the .trivyignore justifications against the current diff and flags:
    • Suppressions missing a comment
    • Justifications obsolete given the current diff (e.g. comment says "deferred until VNet" but the diff adds VNet)
    • Rules targeting deprecated resource types (e.g. AZU-0026 is Single-Server only, misfires on Flexible Server)

Docs / versioning

  • cloud-infra plugin 0.1.00.2.0, added trivy and security-scanning keywords.
  • cloud-infra/README.md skills table updated.
  • Top-level README.md skill count badge and headline 2930.

Test plan

  • Smoke-tested scan-trivy.sh against a real Terraform tree (SparkReach deploy/terraform/): correctly picks up .trivyignore, suppresses justified items, exits 0 on clean.
  • Verified script fails non-zero when a seeded unsuppressed finding is present.
  • Invoke /trivy-scan directly from a consumer project after plugin update.
  • Invoke /infra-lint and confirm the new trivy gate appears in the output.
  • Invoke /complete-infra and confirm Track D runs in parallel with the other lint tracks.

Notes

  • trivy is intentionally not auto-installed. The script prints the install command and exits non-zero — consistent with how lint-helm.sh handles a missing helm binary.
  • Trivy has some rules that target deprecated Azure resources (e.g. PostgreSQL Single Server). The reviewer agent specifically calls this out so users don't bloat their .trivyignore with obsolete rules.

Generated with Claude Code

makigjuro and others added 2 commits April 18, 2026 22:02
Adds a dedicated trivy-based security scanner as a first-class skill in
cloud-infra and makes it a mandatory gate in the existing verification
workflow.

New skill: /trivy-scan
- Runs `trivy config` against the Terraform tree and Helm charts
- Honours a `.trivyignore` in the Terraform root, with a convention that
  every suppression must carry a justifying comment
- Preflights the trivy binary and prints an install hint (brew / curl)
  if missing — never auto-installs
- Severity gating: fails on CRITICAL/HIGH/MEDIUM by default; --strict
  includes LOW; --warn-only never exits non-zero
- Reusable `scripts/scan-trivy.sh` consumed by other skills via
  `bash {plugin-skills-path}/trivy-scan/scripts/scan-trivy.sh`

Wired into existing skills
- /infra-lint: invokes /trivy-scan as the final step, adds a new quality
  gate row in the output
- /complete-infra: adds Track D (security scan) to Phase 1's parallel
  lint, adds a quality gate row

Agent updates
- infra-reviewer: new "Scanner Correlation (trivy)" section. The agent
  no longer re-runs the scanner; instead it sanity-checks the
  .trivyignore justifications against the current diff (catches
  obsolete suppressions, missing reasons, rules targeting deprecated
  resources).

Docs / versioning
- cloud-infra version 0.1.0 -> 0.2.0
- cloud-infra README skills table updated
- Top-level README: skill count badge + headline 29 -> 30
- Added `trivy` and `security-scanning` keywords to plugin.json

Motivation
Discovered during issue #15 (SparkReach F01 Azure infra): `terraform
validate` and `helm lint` don't see AZU-0013/0022 (public KV/Postgres),
AZU-0019/0024 (missing Postgres audit logging), or AZU-0015
(unclassified KV secrets). The infra-reviewer agent is good for
judgement calls but doesn't apply Aqua's curated rule library.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@makigjuro makigjuro merged commit 9f69777 into main Apr 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant