← All Exercises
Verify a SHA-256 Manifest
intermediatebash
Background
Release pipelines verify downloaded artifacts against a published digest list. A clear per-file report makes tampering or truncation obvious.
Problem
Write a script that verifies every checksum in a SHA256SUMS file relative to a base directory, reporting each entry and a summary, with a failing exit status if any check fails.
Input
A readable manifest produced by sha256sum (digest, two spaces, relative path) and an optional base directory defaulting to the current directory.
Output
One OK, FAILED, or MISSING line per manifest entry, then verified=<n> failed=<n>; exit status is 0 only when the failed count is zero.
Sample tests
Sample 1
Input: manifest with the correct digest for reports/summary.txt and a digest for reports/missing.txt
Expected: OK reports/summary.txt MISSING reports/missing.txt verified=1 failed=1 and exit status 1
Sample 2
Input: manifest whose only digest does not match the artifact content
Expected: FAILED artifact.zip verified=0 failed=1 and exit status 1
Your solution
Learning objective
Parse sha256sum output, classify missing versus mismatched files, and drive CI failure through an exit status.