Skip to content

Commit 037bfb7

Browse files
committed
Introduce checksum verification of downloads
- Add central checksums dir - shvr_fetch verification - check by default, SHVR_SKIP_VERIFY_SHA256=1 to skip - Replace direct downloads with shvr_fetch - Added CI flow to ensure checksum verification works - README updates
1 parent 47888ff commit 037bfb7

579 files changed

Lines changed: 764 additions & 43 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker-all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
build:
1717
needs: download
1818
runs-on: ubuntu-24.04
19+
1920
continue-on-error: ${{ matrix.can_fail_build }}
2021
steps:
2122
- uses: actions/checkout@v3

.github/workflows/docker-latest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
build:
1717
needs: download
1818
runs-on: ubuntu-24.04
19+
1920
continue-on-error: ${{ matrix.can_fail_build }}
2021
steps:
2122
- uses: actions/checkout@v3

.github/workflows/docker-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-License-Identifier: ISC
33

44
name: Push alganet/shell-versions:test
5+
permissions:
6+
contents: read
57

68
on:
79
pull_request:
@@ -16,6 +18,7 @@ jobs:
1618
build:
1719
needs: download
1820
runs-on: ubuntu-24.04
21+
1922
continue-on-error: ${{ matrix.can_fail_build }}
2023
steps:
2124
- uses: actions/checkout@v3
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Checksum Verification
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
verify-checksums:
12+
runs-on: ubuntu-24.04
13+
timeout-minutes: 15
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: 'Fast verify: successful download (dash)'
18+
run: |
19+
set -ex
20+
# ensure clean state and perform an initial download (should succeed)
21+
rm -f build/dash/0.5.13.tar.gz
22+
sh shvr.sh download dash_0.5.13
23+
24+
- name: 'Corrupt checksum and assert download fails'
25+
run: |
26+
set -ex
27+
# backup checksum file
28+
cp checksums/dash/0.5.13.tar.gz.sha256sums checksums/dash/0.5.13.tar.gz.sha256sums.bak
29+
# corrupt checksum: replace hash with ones; keep filename
30+
printf '1111111111111111111111111111111111111111111111111111111111111111 %s\n' "0.5.13.tar.gz" > checksums/dash/0.5.13.tar.gz.sha256sums
31+
# remove any existing artifact to force re-download
32+
rm -f build/dash/0.5.13.tar.gz
33+
set +e
34+
# attempt download once; if the worker network is flaky this may fail
35+
# for reasons other than checksum mismatch. Capture logs and RC so we
36+
# can differentiate mismatch from other failures.
37+
# run the download and capture the exit code; write logs to file
38+
sh shvr.sh download dash_0.5.13 > download.log 2>&1
39+
rc=$?
40+
# show the log to the step output so it appears in CI
41+
cat download.log
42+
set -e
43+
if [ "$rc" -eq 0 ]; then
44+
echo "Expected checksum verification to fail but it succeeded" >&2
45+
exit 1
46+
fi
47+
# ensure the failure was due to checksum mismatch; depending on the
48+
# runner and sha256sum version we may see one of multiple messages:
49+
# - our own 'sha256sum mismatch for ...' message
50+
# - a 'filename: FAILED' message emitted by 'sha256sum -c'
51+
# If neither is present then this is likely a transient network or
52+
# download tool error; fail the CI with the full log to help debug.
53+
grep -q "sha256sum mismatch" download.log || grep -q ": FAILED" download.log || (cat download.log && exit 1)
54+
55+
- name: 'Restore checksum and verify success'
56+
run: |
57+
set -ex
58+
mv checksums/dash/0.5.13.tar.gz.sha256sums.bak checksums/dash/0.5.13.tar.gz.sha256sums
59+
rm -f build/dash/0.5.13.tar.gz
60+
sh shvr.sh download dash_0.5.13

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ FROM debian:bookworm-slim AS builder
77
RUN apt-get -y update
88

99
# Copy contents
10-
COPY "shvr.sh" "/shvr/shvr.sh"
11-
COPY "variants/" "/shvr/variants"
10+
COPY "build/" "/usr/src/shvr"
11+
COPY "checksums/" "/shvr/checksums"
1212
COPY "common/" "/shvr/common"
1313
COPY "patches/" "/shvr/patches"
14-
COPY "build/" "/usr/src/shvr"
14+
COPY "variants/" "/shvr/variants"
15+
16+
COPY "shvr.sh" "/shvr/shvr.sh"
1517
RUN chmod +x "/shvr/shvr.sh"
1618

1719
# Setup environment

README.md

Lines changed: 17 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bf7a055e0916b7899e7429e36e35d009db445b942b34520a601ea5a8fa634fdd 001
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
affdd1808a6262fbfe291ebffa2133b05e4bb46067a90e3329d5741e10f0587b 002
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
604972eaafe69f44413d429e0a826b0eae209ca74b14eeeccdf0d502bbabb340 003
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fab91e9742ca4e990666441e91821742e6dff78e8e388ba55205cf7b1cd8e8e1 004

0 commit comments

Comments
 (0)