(path: &Path, expected_digest: &str)
| 3756 | } |
| 3757 | |
| 3758 | fn verify_descriptor_digest(path: &Path, expected_digest: &str) -> Result<(), String> { |
| 3759 | let expected = expected_digest |
| 3760 | .strip_prefix("sha256:") |
| 3761 | .ok_or_else(|| format!("unsupported layer digest '{expected_digest}'"))?; |
| 3762 | let actual = compute_file_sha256_hex(path)?; |
| 3763 | if actual == expected { |
| 3764 | Ok(()) |
| 3765 | } else { |
| 3766 | Err(format!( |
| 3767 | "digest mismatch for {}: expected sha256:{expected}, got sha256:{actual}", |
| 3768 | path.display() |
| 3769 | )) |
| 3770 | } |
| 3771 | } |
| 3772 | |
| 3773 | fn compute_file_sha256_hex(path: &Path) -> Result<String, String> { |
| 3774 | let mut file = fs::File::open(path).map_err(|err| format!("open {}: {err}", path.display()))?; |
no test coverage detected