Skip to content

Commit f2c3f50

Browse files
fix(security): resolve three deferred Hypatia findings (CodeQL/scorecard/setup) (#34)
- codeql.yml: add `language: rust` to the CodeQL matrix so the Rust source (the primary implementation) gets real SAST, not just the GitHub Actions workflows. The `actions` entry already satisfied the stale "lacks actions" finding; this makes SAST non-nominal. - scorecard-enforcer.yml: de-publish the enforcer. scorecard.yml (the reusable workflow) already publishes results, so the enforcer's publish was redundant and placed a privileged publish step (id-token / security-events) next to a custom run: score-gate. Set publish_results: false, drop the upload-sarif step, and reduce the job to contents: read. The score gate still runs on the locally generated results.sarif. Resolves scorecard_publish_with_run_step. - setup.sh: replace the two `curl … | bash` just installers (CWE-494) with install_just_pinned(): pin just 1.53.0, map platform/arch to the release target, download the tarball over HTTPS, verify SHA256, then extract+install — failing closed on mismatch. Usage comment now documents download-review-run instead of pipe-to-shell. Claude-Session: https://claude.ai/code/session_01Y2MWTAqX2x7goVJzjFB4j5 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b2313ca commit f2c3f50

3 files changed

Lines changed: 93 additions & 19 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
include:
3434
- language: actions
3535
build-mode: none
36+
- language: rust
37+
build-mode: none
3638

3739
steps:
3840
- name: Checkout

.github/workflows/scorecard-enforcer.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
timeout-minutes: 15
2727
permissions:
28-
security-events: write
29-
id-token: write # For OIDC
28+
contents: read
3029
steps:
3130
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3231
with:
@@ -37,12 +36,7 @@ jobs:
3736
with:
3837
results_file: results.sarif
3938
results_format: sarif
40-
publish_results: true
41-
42-
- name: Upload SARIF
43-
uses: github/codeql-action/upload-sarif@c6f931105cb2c34c8f901cc885ba1e2e259cf745 # v4
44-
with:
45-
sarif_file: results.sarif
39+
publish_results: false
4640

4741
- name: Check minimum score
4842
run: |

setup.sh

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
# Detects your shell, platform, and installs prerequisites.
66
# Then hands off to `just setup` for project-specific configuration.
77
#
8-
# Usage:
9-
# curl -fsSL https://raw.githubusercontent.com/hyperpolymath/wokelangiser/main/setup.sh | sh
10-
# # or after cloning:
8+
# Usage (recommended — download, review, then run; don't pipe straight to a shell):
9+
# curl -fsSL https://raw.githubusercontent.com/hyperpolymath/wokelangiser/main/setup.sh -o setup.sh
10+
# less setup.sh # review before running
11+
# sh setup.sh
12+
# # …or after cloning:
1113
# ./setup.sh
14+
# # Convenience one-liner (review the script first — you are trusting the network):
15+
# curl -fsSL https://raw.githubusercontent.com/hyperpolymath/wokelangiser/main/setup.sh | sh
1216
#
1317
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath)
1418

@@ -128,6 +132,86 @@ detect_platform() {
128132
esac
129133
}
130134

135+
# ── Verified install of just (pinned version + SHA256; avoids curl|sh, CWE-494) ──
136+
# Bump JUST_VERSION and the four SHA256 values together from:
137+
# https://github.com/casey/just/releases (each release publishes SHA256SUMS)
138+
install_just_pinned() {
139+
JUST_VERSION="1.53.0"
140+
141+
# Map platform/arch -> just release target triple + that tarball's SHA256.
142+
just_target=""
143+
just_sha256=""
144+
case "$OS:$ARCH" in
145+
linux:x86_64|linux:amd64)
146+
just_target="x86_64-unknown-linux-musl"
147+
just_sha256="7fedeb22c7e14d9ef1551e8b793700866d80f409f9884b0e80ebb65c11d4874d" ;;
148+
linux:aarch64|linux:arm64)
149+
just_target="aarch64-unknown-linux-musl"
150+
just_sha256="f29d8e72380bc144465f632c7d59da311205eef2923d57511708b05b82f2e64f" ;;
151+
macos:x86_64|macos:amd64)
152+
just_target="x86_64-apple-darwin"
153+
just_sha256="bc345a26d40ae4697cb6b2f2ca04cdf1fbdc8c50eba1b40684c8bf3f98555d72" ;;
154+
macos:arm64|macos:aarch64)
155+
just_target="aarch64-apple-darwin"
156+
just_sha256="27f1361f2e4fb5d733837f1a9f80f85c237e5a36c75ee14961e59141713aa4ed" ;;
157+
*)
158+
fail "No pinned 'just' build for $OS/$ARCH — install manually: https://just.systems/"
159+
return 1 ;;
160+
esac
161+
162+
# Need a checksum tool (Linux: sha256sum, macOS: shasum -a 256).
163+
if ! command -v sha256sum >/dev/null 2>&1 && ! command -v shasum >/dev/null 2>&1; then
164+
fail "Need sha256sum or shasum to verify the download — install one, or get just manually: https://just.systems/"
165+
return 1
166+
fi
167+
168+
just_tarball="just-${JUST_VERSION}-${just_target}.tar.gz"
169+
just_url="https://github.com/casey/just/releases/download/${JUST_VERSION}/${just_tarball}"
170+
171+
info "Installing just ${JUST_VERSION} (${just_target}): download, verify SHA256, then install"
172+
173+
tmpdir=$(mktemp -d 2>/dev/null) || { fail "Could not create temp dir"; return 1; }
174+
175+
# 1) Download over HTTPS to a file (no pipe-to-shell).
176+
if ! curl -fsSL "$just_url" -o "${tmpdir}/${just_tarball}"; then
177+
fail "Download failed: $just_url"
178+
rm -rf "$tmpdir"; return 1
179+
fi
180+
181+
# 2) Verify integrity BEFORE touching the contents (this is the CWE-494 fix).
182+
if command -v sha256sum >/dev/null 2>&1; then
183+
actual_sha=$(sha256sum "${tmpdir}/${just_tarball}" | awk '{print $1}')
184+
else
185+
actual_sha=$(shasum -a 256 "${tmpdir}/${just_tarball}" | awk '{print $1}')
186+
fi
187+
if [ "$actual_sha" != "$just_sha256" ]; then
188+
fail "Checksum mismatch for ${just_tarball} — refusing to install"
189+
fail " expected: $just_sha256"
190+
fail " actual: $actual_sha"
191+
rm -rf "$tmpdir"; return 1
192+
fi
193+
ok "Checksum verified (SHA256)"
194+
195+
# 3) Extract only the verified binary and install it.
196+
if ! tar -xzf "${tmpdir}/${just_tarball}" -C "$tmpdir" just; then
197+
fail "Could not extract just from ${just_tarball}"
198+
rm -rf "$tmpdir"; return 1
199+
fi
200+
201+
if [ -w /usr/local/bin ]; then
202+
cp "${tmpdir}/just" /usr/local/bin/just && chmod 0755 /usr/local/bin/just
203+
else
204+
sudo cp "${tmpdir}/just" /usr/local/bin/just && sudo chmod 0755 /usr/local/bin/just
205+
fi
206+
rc=$?
207+
208+
rm -rf "$tmpdir"
209+
if [ "$rc" -ne 0 ]; then
210+
fail "Could not install just to /usr/local/bin"
211+
return 1
212+
fi
213+
}
214+
131215
# ── Install just ──
132216
install_just() {
133217
if command -v just >/dev/null 2>&1; then
@@ -139,10 +223,7 @@ install_just() {
139223

140224
case "$PKG_MGR" in
141225
dnf) sudo dnf install -y just ;;
142-
apt) sudo apt-get install -y just 2>/dev/null || {
143-
# just not in older apt repos — use installer
144-
curl -fsSL https://just.systems/install.sh | bash -s -- --to /usr/local/bin
145-
} ;;
226+
apt) sudo apt-get install -y just 2>/dev/null || install_just_pinned ;;
146227
pacman) sudo pacman -S --noconfirm just ;;
147228
apk) sudo apk add just ;;
148229
brew) brew install just ;;
@@ -151,10 +232,7 @@ install_just() {
151232
rpm-ostree) sudo rpm-ostree install just ;;
152233
guix) guix install just ;;
153234
nix) nix-env -iA nixpkgs.just ;;
154-
*)
155-
info "Using just installer script..."
156-
curl -fsSL https://just.systems/install.sh | bash -s -- --to /usr/local/bin
157-
;;
235+
*) install_just_pinned ;;
158236
esac
159237

160238
if command -v just >/dev/null 2>&1; then

0 commit comments

Comments
 (0)