Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
SlackIncomingWebhook icon
Switch icon
Create icon
Fail icon
Log icon

Block Container Promotion on grype Severity Findings

Scan a container image with grype, grade matches by severity, block promotion with a GitHub issue and Slack alert, or pass with a recorded warning.

Categories
Infrastructure

How it works

  1. on_promotion_request (io.kestra.plugin.core.trigger.Webhook, keyed) accepts the image reference from your CI. nightly_rescan (io.kestra.plugin.core.trigger.Schedule) ships disabled: true as a fallback net once an operator switches it on.
  2. scan_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared filesystem so the scan and the grader work from the same report file.
  3. run_grype_scan (io.kestra.plugin.scripts.shell.Commands on the io.kestra.plugin.scripts.runner.docker.Docker runner, image anchore/grype:latest) writes a bundled fixture report with a heredoc, then runs grype "${IMAGE_REF}" -o json > grype-report.json || true. The exit code is absorbed on purpose, so a scary scan never fails the task and the graded verdict alone drives the gate. When the image daemon is unreachable the fixture is copied in, keeping the flow deterministic offline.
  4. grade_report (io.kestra.plugin.scripts.python.Script on python:3.12-slim) counts matches by severity, collects the matches at or above the fail_severity floor, and emits PASS, WARN, or BLOCK with the counts and summaries through the outputs protocol. WARN is reserved for runs whose only findings sit below the floor in the medium class.
  5. notify_scan_result (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts the scan summary to the release channel on every run, so the promotion record exists even when nothing blocks.
  6. route_verdict (io.kestra.plugin.core.flow.Switch) maps the verdict with explicit cases. BLOCK opens a labeled GitHub issue through io.kestra.plugin.github.issues.Create, alerts Slack, and fails the execution with io.kestra.plugin.core.execution.Fail. WARN posts a non-blocking warning, PASS records the clean scan, and the defaults case logs an unknown verdict loudly.
  7. The errors block alerts Slack whenever the scan or the grader itself breaks, because a dead scanner looks exactly like a clean image.

What you get

  • A promotion gate that stops a known-bad image before the registry write, not after production traffic hits it.
  • A severity floor you can tighten per environment, critical only for staging, high for production.
  • Escalation where engineers already work, a labeled GitHub issue on BLOCK plus Slack on every outcome.
  • Gateable outputs, verdict, total_matches, worst_severity, cve_ids, and blocking_summary for any parent pipeline.
  • A dated execution history that doubles as the promotion evidence for that exact image reference.

Who it's for

  • Release engineers who need a vulnerability gate between build and production registry.
  • Platform teams standardizing one scan policy across many images and pipelines.
  • Security engineers who want blocking findings tracked as issues instead of buried in CI logs.

Why orchestrate this with Kestra

grype is a strong scanner, but a scanner a pipeline can skip catches nothing. Kestra supplies the loop around it, a keyed webhook from CI, a hermetic container so the tool version lives in the flow file, a map-shaped verdict router that separates block, warn, and pass outcomes, Slack and GitHub routing from one file, and an execution record per image reference. A build step running grype gives you none of that, it only protects the images of pipelines that remember to fail on the exit code.

Prerequisites

  • A worker with Docker access, the scan runs in the grype container and the grader in python:3.12-slim.
  • Registry credentials on the worker when the image is private, grype reads the same Docker auth as the daemon.
  • A GitHub token that can open issues in github_repository (classic PAT scope repo, or fine-grained Issues: write).
  • A Slack incoming webhook for the scan summary, block alerts, and failure alerts.

Secrets

  • GRYPE_WEBHOOK_KEY: key segment guarding the webhook URL, anyone holding it can trigger a promotion scan.
  • GITHUB_TOKEN: token used to open the blocking issue.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.

Quick start

  1. Add the secrets above to your Kestra namespace.
  2. Run the flow once with the default inputs and confirm the bundled fixture routes to BLOCK with verdict and blocking_summary in the outputs.
  3. Raise fail_severity to critical or point image_ref at a clean digest, then re-run and watch the Switch route to WARN or PASS.
  4. Point github_repository at a repository where issues are welcome, then trigger from CI at /api/v1/{tenant}/executions/webhook/{namespace}/grype-cve-promote-gate/{GRYPE_WEBHOOK_KEY}.

How to extend

  • Scan a whole release set by wrapping this flow in a parent that calls it with a Subflow per image and aggregates the verdicts.
  • Add an allowlist input that filters ignored advisory ids in grade_report the same way accepted exceptions work in policy engines.
  • Publish the raw grype-report.json to object storage with io.kestra.plugin.aws.s3.Upload so every promotion keeps its exact scan artifact.
  • Replace the GitHub issue with a Jira or ServiceNow task when that is where your remediation work already lives.
  • Feed worst_severity into a downstream approval flow so medium findings still require a human sign-off.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.