Skip to content

Commit 778e1b1

Browse files
committed
Inspect line-continued install_package calls too
Scoping checksum extraction to lines starting with install_package missed a call spelled across continued lines: only the first line matched, so a URL on a continuation went uninspected. Latent rather than live — no definition uses continuations today — but it's the same vacuous-pass hole one level down, and the "found no URLs" guard wouldn't have caught it either, since another well-formed call in the same file keeps the count nonzero. Fold continuations before matching. Pure bash rather than sed or awk: the usual line-joining one-liners differ between BSD and GNU, and macOS portability is what this whole section is about.
1 parent 65e0c11 commit 778e1b1

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎bin/ci‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ lint_syntax() {
6161
}
6262

6363
# --- Checksums --------------------------------------------------------------
64+
# Fold backslash-continued lines into one, so an install_package spelled across several
65+
# lines is inspected whole. Matching raw lines would see only the first, and a missing
66+
# checksum on a continuation would pass unnoticed — with another well-formed call in the
67+
# file, even the "found nothing" guard below wouldn't fire.
68+
#
69+
# Pure bash rather than sed/awk: the usual line-joining one-liners differ between BSD and
70+
# GNU, and macOS portability is the entire point of this section.
71+
join_continuations() {
72+
local line acc=""
73+
while IFS= read -r line || [ -n "$line" ]; do
74+
if [ "${line%\\}" != "$line" ]; then
75+
acc="${acc}${line%\\} "
76+
else
77+
printf '%s%s\n' "$acc" "$line"
78+
acc=""
79+
fi
80+
done < "$1"
81+
[ -n "$acc" ] && printf '%s\n' "$acc"
82+
return 0
83+
}
84+
6485
# ruby-build only verifies a download when the URL carries a #checksum. Without
6586
# one it fetches and builds whatever it got, silently. A missing checksum is the
6687
# kind of thing that survives review, so assert it here.
@@ -80,7 +101,7 @@ lint_checksums() {
80101
while IFS= read -r url; do
81102
found=$(( found + 1 ))
82103
[[ $url =~ \#[0-9a-f]{64}$ ]] || { fail "$f: no sha256 on ${url%%\#*}"; ok=false; }
83-
done < <(grep -E '^[[:space:]]*install_package' "$f" \
104+
done < <(join_continuations "$f" | grep -E '^[[:space:]]*install_package' \
84105
| grep -oE "[\"']https?://[^\"']+[\"']" | tr -d "\"'")
85106
# Every definition installs at least Ruby itself from a URL. Finding none means the
86107
# extractor stopped matching, not that the file is clean — don't call that a pass.

0 commit comments

Comments
 (0)