Run Cottage's checks with the servers' image allowlist (#21)

The platform check now starts the node with a managed image allowlist and
sets it from this catalog, as the control plane does for the servers. A
recipe whose image the servers would refuse now fails here, before merge,
and a refused template prints the platform's reasons.

Pins the platform at the commit that adds the managed allowlist.
This commit is contained in:
michael authored and GitHub committed 2026-11-22 13:03:49 -05:00
1 parent b1d3b7e189
commit 64e36819fd
5 files changed
+27 -4

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
"""Print the image allowlist the platform's nodes get from this catalog, as the JSON body of
PUT /v1/image-allowlist: every repository the recipes use, without tag or digest."""
import glob, json, yaml
names = set()
for path in glob.glob("apps/*/template.yml"):
for svc in ((yaml.safe_load(open(path)) or {}).get("services") or {}).values():
ref = str((svc or {}).get("image", "")).split("@")[0]
if ref.rfind(":") > ref.rfind("/"):
ref = ref[: ref.rfind(":")]
if ref:
names.add(ref)
print(json.dumps({"images": sorted(names)}))
+5 -1
View File
@@ -14,7 +14,11 @@ api() { curl -fsS -H "Authorization: Bearer $HARBOR_TOKEN" "$@"; }
json() { python3 -c "import sys,json; d=json.load(sys.stdin); print($1)"; }
slug=$(basename "$dir")
api -X POST -H 'Content-Type: application/yaml' --data-binary @"$dir/template.yml" "$HARBOR_URL/v1/templates" >/dev/null
# on a refusal (an image not on the allowlist, say) show the platform's reasons
if ! out=$(curl -sS --fail-with-body -H "Authorization: Bearer $HARBOR_TOKEN" -X POST -H 'Content-Type: application/yaml' \
--data-binary @"$dir/template.yml" "$HARBOR_URL/v1/templates"); then
echo "$slug: the platform refused template.yml: $out"; exit 1
fi
version=$(api "$HARBOR_URL/v1/templates?slug=$slug" | json "sorted(d['data'], key=lambda t: t['created_at'])[-1]['version']")
health=$(api "$HARBOR_URL/v1/templates/$slug?version=$version" | json "d.get('health_path','/')")
ref="smoke-$slug-$$"
+1 -1
View File
@@ -1 +1 @@
e6c8b85797a9068c211702afa30a9b8bba082f66
1c42cea53cd56434bdee4c4efea7fb9a3a8ac4b4
+6 -1
View File
@@ -83,6 +83,11 @@ jobs:
# the runner's sudo ignores -E, so pass the settings explicitly
H="HARBOR_DATA_DIR=$HARBOR_DATA_DIR HARBOR_RUNTIME=$HARBOR_RUNTIME HARBOR_BASE_DOMAIN=$HARBOR_BASE_DOMAIN HARBOR_CAPACITY_CPU_MILLIS=$HARBOR_CAPACITY_CPU_MILLIS HARBOR_CAPACITY_MEMORY_MB=$HARBOR_CAPACITY_MEMORY_MB HARBOR_CAPACITY_STORAGE_MB=$HARBOR_CAPACITY_STORAGE_MB"
export HARBOR_TOKEN=$(sudo env $H /tmp/harbord token create ci | grep -o 'hbr_[A-Za-z0-9_-]*')
sudo env $H /tmp/harbord serve & sleep 2
# As on the servers, the node only runs images on its allowlist, and the control plane
# sets that list from the catalog. A name the node won't take fails here, not in production.
sudo env $H HARBOR_IMAGE_ALLOWLIST_MANAGED=true /tmp/harbord serve & sleep 2
export HARBOR_URL=http://127.0.0.1:7700
python3 .github/platform-allowlist.py > "$RUNNER_TEMP/allowlist.json"
curl -sS --fail-with-body -X PUT -H "Authorization: Bearer $HARBOR_TOKEN" -H 'Content-Type: application/json' \
--data-binary @"$RUNNER_TEMP/allowlist.json" "$HARBOR_URL/v1/image-allowlist"
for app in apps/*/; do sh .github/platform-check.sh "$app"; done
+2 -1
View File
@@ -67,7 +67,8 @@ by the right user, the default memory and CPU limits, no-new-privileges, and the
needs Docker with Compose v2, `python3` and `curl`.
Every pull request runs the same test on the recipes it changes, plus Cottage's own checks of
every recipe. Make sure both pass; we can't merge a recipe until they do. Pull requests from forks
every recipe. Those run the platform as the servers do, with an image allowlist built from this
catalog, so the servers will accept every image a merged recipe uses. Make sure both pass; we can't merge a recipe until they do. Pull requests from forks
get the Compose test, and we run Cottage's checks before merging.
[docs/licensing.md](docs/licensing.md) lists which apps we can host under their licences, and on