Plug-in Library: a package with an unreadable repo URL downloads nothing

When a package names a `repo` that isn't a GitHub repository URL
(`https://github.com/<owner>/<repo>`, a trailing `/` or `.git` allowed, or
a folder in one, `.../tree/<ref>/<path>`), Install, Update and Preview now
refuse its release URLs with an error naming the package. Before, such a
`repo` skipped the repository check and any GitHub release asset was
downloaded. A package without a `repo` keeps any repository's release
asset.

The example catalog's schema now holds `repo` and release `url` to the
same forms, and `scripts/validate.sh` checks that every release is an
asset of the package's `repo` before it downloads anything.
This commit is contained in:
dotCooCoo committed 2026-11-05 23:40:33 -08:00
1 parent 75fed052e3
commit 5dfcadd09b
6 files changed
+117 -29

No files matched your search

+20 -2
View File
@@ -42,7 +42,25 @@ dups=$(jq -r '.packages[].id' "$catalog" | sort | uniq -d)
[ -z "$dups" ] || fail "duplicate package ids: $dups"
echo "ok"
echo "== 3. downloads"
echo "== 3. release URLs"
# When a package has a `repo`, every release must be an asset of that repository, as Install and
# Preview require (the loader step installs from file:// copies, which skip this check).
bad=$(jq -r '
# Only the scheme, host, owner and name compare without case; the `.git` suffix is lower case.
def repo_of:
(capture("^(?<h>[^/]+//[^/]+)/(?<o>[A-Za-z0-9._-]+)/(?<n>[A-Za-z0-9._-]+?)(\\.git)?/?$")
// capture("^(?<h>[^/]+//[^/]+)/(?<o>[A-Za-z0-9._-]+)/(?<n>[A-Za-z0-9._-]+)/tree/[^?#]+$")
| select(.h | ascii_downcase == "https://github.com") | "\(.o)/\(.n)" | ascii_downcase) // "?";
.packages[] | . as $pkg | ((.repo // "") | gsub("^\\s+|\\s+$"; "")) as $repo
| select($repo != "") | ($repo | repo_of) as $want
| .versions[] | select(.url | startswith("file://") | not)
| ((.url | ascii_downcase | capture("^https://github\\.com/(?<o>[^/]+)/(?<n>[^/]+)/releases/download/") | "\(.o)/\(.n)") // "?") as $got
| select($want == "?" or $got != $want)
| "\($pkg.id) \(.version): \(.url) is not a release asset of \($repo)"' "$catalog")
[ -z "$bad" ] || fail "release URLs outside the package's repo:"$'\n'"$bad"
echo "ok"
echo "== 4. downloads"
# The checked files are what the loader step installs: a copy of the catalog names them by file://.
local_catalog=$(jq '.' "$catalog")
while IFS=$'\t' read -r p r id version url sha size; do
@@ -58,7 +76,7 @@ done < <(jq -r '.packages | to_entries[] | .key as $p | .value as $pkg | $pkg.ve
| [$p, .key, $pkg.id, .value.version, .value.url, .value.sha256, (.value.size // "")] | @tsv' "$catalog")
echo "ok"
echo "== 4. load with EffectCraft"
echo "== 5. load with EffectCraft"
if [ -z "${EFFECTCRAFT_CLI:-}" ]; then
echo "skipped (set EFFECTCRAFT_CLI to an effectcraft-cli build)"
exit 0