security: enforce HTTPS on curl downloads (SonarCloud S6506)

Add --proto '=https' to curl invocations so redirects cannot downgrade to
plaintext HTTP. Resolves SonarCloud S6506 (shell/docker/githubactions).
This commit is contained in:
Dylan M. Taylor
2026-10-21 17:07:04 -04:00
parent 3dc3b955df
commit 36ea99fdc8
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -83,13 +83,13 @@ BASE="https://huggingface.co/$REPO/resolve/main"
fetch() {
set -- "$1" "$2" "${3:-}"
if [ -n "$TOKEN" ]; then auth="Authorization: Bearer $TOKEN"; else auth="X-No-Auth: 1"; fi
code=$(curl -fsSL ${3:+-C -} -H "$auth" -w '%{http_code}' -o "$2" "$BASE/$1") || true
code=$(curl --proto '=https' -fsSL ${3:+-C -} -H "$auth" -w '%{http_code}' -o "$2" "$BASE/$1") || true
case "$code" in
200|206) return 0 ;;
416)
echo "the partial download of $1 doesn't match the server's; starting over" >&2
rm -f "$2"
code=$(curl -fsSL -H "$auth" -w '%{http_code}' -o "$2" "$BASE/$1") || true
code=$(curl --proto '=https' -fsSL -H "$auth" -w '%{http_code}' -o "$2" "$BASE/$1") || true
[ "$code" = 200 ] && return 0
echo "download of $REPO/$1 failed ($code)" >&2; return 1 ;;
401|403) echo "access denied to $REPO/$1 (has your request for facebook/sam3 been approved?)" >&2; return 1 ;;