@@ -36,35 +36,58 @@ export readonly FILES=("${SLSA_VERIFIER_BINARY}" "${SLSA_VERIFIER_CHECKSUM_FILE}
36
36
37
37
function debug() {
38
38
TIMESTAMP=$( date -u " +%FT%TZ" ) # 2023-05-10T07:53:59Z
39
- echo " " ${TIMESTAMP} " DEBUG - $1 "
39
+ echo " " ${TIMESTAMP} " DEBUG - [*] $1 "
40
40
}
41
41
42
- function download_slsa_verifier() {
43
- debug " [*] Downloading SLSA Verifier for - Binary: slsa-verifier-${OS_NAME} -${ARCHITECTURE} "
44
- curl --location --silent -O " https://github.com/slsa-framework/slsa-verifier/releases/download/v${SLSA_VERIFIER_VERSION} /slsa-verifier-${OS_NAME} -${ARCHITECTURE} "
45
-
46
- debug " [*] Downloading SLSA Verifier checksums"
47
- curl --location --silent -O " https://raw.githubusercontent.com/slsa-framework/slsa-verifier/f59b55ef2190581d40fc1a5f3b7a51cab2f4a652/${SLSA_VERIFIER_CHECKSUM_FILE} "
42
+ function error() {
43
+ cleanup
44
+ TIMESTAMP=$( date -u " +%FT%TZ" ) # 2023-05-10T07:53:59Z
45
+ echo " " ${TIMESTAMP} " ERROR - [!] $1 "
46
+ echo " " ${TIMESTAMP} " ERROR - [!] exiting"
47
+ exit 1
48
+ }
48
49
49
- debug " [*] Verifying SLSA Verifier binary integrity"
50
+ function download_slsa_verifier() {
51
+ readonly SLSA_URL=" https://github.com/slsa-framework/slsa-verifier/releases/download/v${SLSA_VERIFIER_VERSION} /slsa-verifier-${OS_NAME} -${ARCHITECTURE} "
52
+ # debug "Downloading SLSA Verifier for - Binary: slsa-verifier-${OS_NAME}-${ARCHITECTURE}"
53
+ debug " Downloading SLSA Verifier binary: ${SLSA_URL} "
54
+ curl \
55
+ --location \
56
+ --fail \
57
+ --silent \
58
+ -O " ${SLSA_URL} " || error " Failed to download SLSA Verifier binary"
59
+
60
+ readonly SLSA_CHECKSUM_URL=" https://raw.githubusercontent.com/slsa-framework/slsa-verifier/f59b55ef2190581d40fc1a5f3b7a51cab2f4a652/${SLSA_VERIFIER_CHECKSUM_FILE} "
61
+ debug " Downloading SLSA Verifier checksums"
62
+ curl \
63
+ --location \
64
+ --fail \
65
+ --silent \
66
+ -O " ${SLSA_CHECKSUM_URL} " || error " Failed to download SLSA Verifier binary checksum file"
67
+
68
+ debug " Verifying SLSA Verifier binary integrity"
50
69
CURRENT_HASH=$( sha256sum " ${SLSA_VERIFIER_BINARY} " | awk ' {print $1}' )
51
70
if [[ $( grep " ${CURRENT_HASH} " " ${SLSA_VERIFIER_CHECKSUM_FILE} " ) ]]; then
52
- debug " [*] SLSA Verifier binary integrity confirmed"
71
+ debug " SLSA Verifier binary integrity confirmed"
53
72
chmod +x " ${SLSA_VERIFIER_BINARY} "
54
73
else
55
- debug " [!] Failed integrity check for SLSA Verifier binary: ${SLSA_VERIFIER_BINARY} "
56
- exit 1
74
+ error " Failed integrity check for SLSA Verifier binary: ${SLSA_VERIFIER_BINARY} "
57
75
fi
58
76
}
59
77
60
78
function download_provenance() {
61
- debug " [*] Downloading attestation for - Release: https://github.com/${ORG} /${REPO} /releases/v${RELEASE_VERSION} "
62
-
63
- curl --location --silent -O " https://github.com/${ORG} /${REPO} /releases/download/v${RELEASE_VERSION} /${PROVENANCE_FILE} "
79
+ readonly PROVENANCE_URL=" https://github.com/${ORG} /${REPO} /releases/download/v${RELEASE_VERSION} /${PROVENANCE_FILE} "
80
+ debug " Downloading attestation: ${PROVENANCE_URL} "
81
+
82
+ curl \
83
+ --location \
84
+ --fail \
85
+ --silent \
86
+ -O ${PROVENANCE_URL} || error " Failed to download provenance. Does the release already exist?"
64
87
}
65
88
66
89
function download_release_artifact() {
67
- debug " [*] Downloading ${RELEASE_VERSION} release from PyPi"
90
+ debug " Downloading ${RELEASE_VERSION} release from PyPi"
68
91
python -m pip download \
69
92
--only-binary=:all: \
70
93
--no-deps \
@@ -73,19 +96,19 @@ function download_release_artifact() {
73
96
}
74
97
75
98
function verify_provenance() {
76
- debug " [*] Verifying attestation with slsa-verifier"
99
+ debug " Verifying attestation with slsa-verifier"
77
100
" ${SLSA_VERIFIER_BINARY} " verify-artifact \
78
101
--provenance-path " ${PROVENANCE_FILE} " \
79
102
--source-uri github.com/${ORG} /${REPO} \
80
103
${RELEASE_BINARY}
81
104
}
82
105
83
106
function cleanup() {
84
- debug " [*] Cleaning up previously downloaded files"
85
- rm " ${SLSA_VERIFIER_BINARY} "
86
- rm " ${SLSA_VERIFIER_CHECKSUM_FILE} "
87
- rm " ${PROVENANCE_FILE} "
88
- rm " ${RELEASE_BINARY} "
107
+ debug " Cleaning up previously downloaded files"
108
+ rm -f " ${SLSA_VERIFIER_BINARY} "
109
+ rm -f " ${SLSA_VERIFIER_CHECKSUM_FILE} "
110
+ rm -f " ${PROVENANCE_FILE} "
111
+ rm -f " ${RELEASE_BINARY} "
89
112
echo " ${FILES[@]} " | xargs -n1 echo " Removed file: "
90
113
}
91
114
0 commit comments