Skip to content

CICD-378 · Container base-image policy ​

Encyclopedia · Advanced security and compliance · All snippets

Previous · CICD-377 · Next · CICD-379

1. Where it fits ​

  • Placement CI Docker policy gate.
  • Prerequisites reviewed policies, a short-lived CI identity, and synthetic or approved test inputs.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
grep -E '^FROM ' Dockerfile | awk 'BEGIN{n=0} {if ($2 !~ /@sha256:[a-f0-9]+$/) exit 1; n++} END{if (!n) exit 1}'

3. How it works ​

The filter checks every FROM line for a digest suffix and requires at least one such line. A production rule needs to account for named build stages and validate digest length.

4. Verify the result ​

This strict starter requires digest-pinned external FROM lines. Real multi-stage policy must allow aliases defined earlier and validate the digest length.

Validation syntax-validated (Bash parse). Status definitions.