From 4622cce68e700bb2e830526bf0f941999c254b64 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 12:36:03 +1100 Subject: [PATCH 1/7] publish-channels: every catalog declares its channel, and none is promoted without it A catalog's signature binds it to a channel only when the catalog declares one. empty-catalog wrote no channel, and os-promote accepted a catalog that declared none on stable, rc and testing, so the same signed bytes could be served on any of them. empty-catalog now takes --channel and writes it. os-promote refuses a catalog that declares no channel, as it already refused one declaring another. A release set bound for more than one channel stages one signed catalog for each as releases/TAG/catalog.CHANNEL.signed.json, which os-promote reads first; publish-r2 uploads those beside catalog.signed.json. channel-status prints the declared channel and compares stable with rc by what they offer, since their bytes now always differ. prepare-distribution-release.py still reads an undeclared delivery as Testing: the development deliveries published today predate the field. Tests pin that it refuses a delivery signed for any other channel. Signed-off-by: Ryan Murray --- macOS/scripts/prepare-distribution-release.py | 2 + macOS/scripts/publish-channels | 77 ++++++++-- macOS/scripts/publish-m1-release | 8 + .../tests/test_distribution_release.py | 24 +++ .../tests/test_make_unsigned_catalog.py | 7 + .../apple-installer-channel-publish-test.sh | 141 ++++++++++++++---- 6 files changed, 215 insertions(+), 44 deletions(-) diff --git a/macOS/scripts/prepare-distribution-release.py b/macOS/scripts/prepare-distribution-release.py index 7806a374..4b51572c 100644 --- a/macOS/scripts/prepare-distribution-release.py +++ b/macOS/scripts/prepare-distribution-release.py @@ -69,6 +69,8 @@ def prepare(source, output, sealed=False, signing_team=None): for model in catalog["models"] ): raise ValueError(f"native-only catalog includes an execution archive: {profile}") + # Published development deliveries predate the channel field, so an + # undeclared one is still read as Testing, as the app reads it. if catalog.get("channel") not in (None, "testing"): raise ValueError("the bundled default must be a testing delivery") schema_versions.add(catalog["schemaVersion"]) diff --git a/macOS/scripts/publish-channels b/macOS/scripts/publish-channels index d7567e82..1570f969 100755 --- a/macOS/scripts/publish-channels +++ b/macOS/scripts/publish-channels @@ -58,7 +58,7 @@ channels_usage() { cat <<'USAGE' Usage: publish-channels envelope --catalog FILE --signature FILE --output FILE - publish-channels empty-catalog --output FILE [--sequence N] + publish-channels empty-catalog --channel stable|rc|testing|edge --output FILE [--sequence N] publish-channels os-promote --tag TAG --to stable|rc|testing|edge [--minimum-sequence N] [--no-prune] publish-channels app-publish --zip FILE --version X.Y.Z [--to stable|rc|testing|edge] publish-channels channel-status [--channel stable|rc|testing|edge|all] @@ -71,6 +71,14 @@ os-promote it like any other release. Its sequence defaults to the current Unix time, as real catalogs use; a later one would block every real release until that time passes, so it is refused. +Every catalog declares the one channel it is signed for, an empty one +included, and os-promote publishes it to that channel only. A catalog that +declares no channel is never promoted: the signature would not say which +channel it belongs to, so the same bytes could be served on any of them. +A release set that goes to more than one channel stages one signed catalog +for each as releases/TAG/catalog.CHANNEL.signed.json; os-promote reads that +first and releases/TAG/catalog.signed.json otherwise. + Credentials come from AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or the Keychain items omarchy-r2-access-key-id and omarchy-r2-secret-access-key. USAGE @@ -119,23 +127,27 @@ bucket_key() { } # A channel with no Mac release yet still serves a signed catalog, so the app -# can tell "nothing here yet" from a channel it cannot reach or verify. +# can tell "nothing here yet" from a channel it cannot reach or verify. It +# declares its channel like any other catalog, so one channel's empty catalog +# cannot be served on another. write_empty_catalog() { - local sequence=$1 output=$2 now + local channel=$1 sequence=$2 output=$3 now + validate_channel "$channel" now=$(date +%s) [[ -n $sequence ]] || sequence=$now [[ $sequence =~ ^[1-9][0-9]*$ ]] || die "the sequence must be a positive integer: $sequence" (( sequence <= now )) || die "the sequence $sequence is later than now ($now); real catalogs could not follow it" [[ ! -e $output ]] || die "refusing to overwrite $output" - python3 - "$sequence" "$output" <<'PY' + python3 - "$channel" "$sequence" "$output" <<'PY' import datetime import json import sys -sequence, output = int(sys.argv[1]), sys.argv[2] +channel, sequence, output = sys.argv[1], int(sys.argv[2]), sys.argv[3] catalog = { "schemaVersion": 5, + "channel": channel, "sequence": sequence, "issuedAt": datetime.datetime.now(datetime.timezone.utc) .replace(microsecond=0) @@ -147,6 +159,7 @@ with open(output, "x", encoding="utf-8") as stream: stream.write("\n") PY echo "empty_catalog=$output" + echo "catalog_channel=$channel" echo "catalog_sequence=$sequence" } @@ -334,18 +347,35 @@ os_promote() { local work work=$(make_scratch) - echo "Reading releases/$tag/catalog.signed.json" - fetch_public "releases/$tag/catalog.signed.json" "$work/candidate.json" || - die "releases/$tag/catalog.signed.json is not published" + # A set offered on more than one channel stages one signed catalog per + # channel, catalog..signed.json; a set for a single channel may + # stage just catalog.signed.json. Either must declare the channel it goes to. + local candidate_key="releases/$tag/catalog.$channel.signed.json" + if ! fetch_public "$candidate_key" "$work/candidate.json"; then + candidate_key="releases/$tag/catalog.signed.json" + fetch_public "$candidate_key" "$work/candidate.json" || + die "neither releases/$tag/catalog.$channel.signed.json nor $candidate_key is published" + fi + echo "Reading $candidate_key" decode_envelope "$work/candidate.json" "$work/catalog" "$work/signature" verify_catalog "$work/catalog" "$work/signature" local declared_channel declared_channel=$(python3 - "$work/catalog" <<'PYCHANNEL' import json, sys -print(json.load(open(sys.argv[1])).get("channel", "")) +catalog = json.load(open(sys.argv[1])) +if not isinstance(catalog, dict): + raise SystemExit("catalog is not an object") +declared = catalog.get("channel") +if declared is not None and not (isinstance(declared, str) and declared): + raise SystemExit("catalog channel is not a name") +print(declared or "") PYCHANNEL -) - [[ -z $declared_channel || $declared_channel == "$channel" ]] || +) || die "catalog does not declare a readable channel" + # The signature must name the channel: an undeclared catalog would verify on + # every channel, so it is not promoted to any. + [[ -n $declared_channel ]] || + die "catalog declares no channel; $channel requires a catalog signed with \"channel\": \"$channel\"" + [[ $declared_channel == "$channel" ]] || die "catalog is bound to $declared_channel; $channel requires its own signed channel catalog" local sequence @@ -664,6 +694,10 @@ channel_status() { if fetch_public "channels/$directory/catalog.signed.json" "$work/$channel.json"; then decode_envelope "$work/$channel.json" "$work/$channel.catalog" "$work/$channel.sig" if verify_catalog "$work/$channel.catalog" "$work/$channel.sig" >/dev/null 2>&1; then + echo " catalog_channel=$(python3 -c ' +import json, sys +print(json.load(open(sys.argv[1])).get("channel") or "undeclared") +' "$work/$channel.catalog")" echo " catalog_sequence=$(catalog_field "$work/$channel.catalog" sequence)" echo " catalog_schema=$(catalog_field "$work/$channel.catalog" schemaVersion)" echo " catalog_sha256=$(file_digest "$work/$channel.catalog")" @@ -683,8 +717,18 @@ channel_status() { done if [[ $requested == "all" ]]; then - if [[ -f $work/stable.json && -f $work/rc.json ]] && - [[ $(file_digest "$work/stable.json") == "$(file_digest "$work/rc.json")" ]]; then + # Each channel's catalog is signed for that channel alone, so the two + # agree when they offer the same release at the same sequence, not when + # the bytes match. + if [[ -f $work/stable.catalog && -f $work/rc.catalog ]] && + python3 -c ' +import json, sys +first, second = (json.load(open(path)) for path in sys.argv[1:3]) +for catalog in (first, second): + catalog.pop("channel", None) + catalog.pop("issuedAt", None) +raise SystemExit(0 if first == second else 1) +' "$work/stable.catalog" "$work/rc.catalog"; then echo "stable_equals_rc=yes" else echo "stable_equals_rc=no" @@ -876,16 +920,17 @@ channels_main() { echo "envelope=$output" ;; empty-catalog) - local sequence="" output="" + local channel="" sequence="" output="" while (( $# > 0 )); do case $1 in + --channel) channel=${2:-}; shift 2 ;; --sequence) sequence=${2:-}; shift 2 ;; --output) output=${2:-}; shift 2 ;; *) channels_usage ;; esac done - [[ -n $output ]] || channels_usage - write_empty_catalog "$sequence" "$output" + [[ -n $channel && -n $output ]] || channels_usage + write_empty_catalog "$channel" "$sequence" "$output" ;; os-promote) os_promote "$@" ;; app-publish) app_publish "$@" ;; diff --git a/macOS/scripts/publish-m1-release b/macOS/scripts/publish-m1-release index bfacf52b..482bbe46 100755 --- a/macOS/scripts/publish-m1-release +++ b/macOS/scripts/publish-m1-release @@ -437,6 +437,14 @@ publish_r2_release() { require_file "$catalog_dir/$catalog_asset" catalog_assets="$catalog_assets $catalog_asset" done + # A set bound for more than one channel also carries one signed catalog + # per channel, which publish-channels os-promote reads for that channel. + for catalog_asset in catalog.stable.signed.json catalog.rc.signed.json \ + catalog.testing.signed.json catalog.edge.signed.json; do + [[ -e $catalog_dir/$catalog_asset ]] || continue + require_file "$catalog_dir/$catalog_asset" + catalog_assets="$catalog_assets $catalog_asset" + done catalog_assets=${catalog_assets# } fi r2_credentials diff --git a/macOS/scripts/tests/test_distribution_release.py b/macOS/scripts/tests/test_distribution_release.py index b35abf38..21e1ac5b 100644 --- a/macOS/scripts/tests/test_distribution_release.py +++ b/macOS/scripts/tests/test_distribution_release.py @@ -78,6 +78,30 @@ def test_complete_native_only_set(self): set(module.PROFILES)) self.assertEqual(json.loads((output / "catalog.json").read_text())["schemaVersion"], 5) + def declare(self, channel): + for profile in module.PROFILES: + directory = self.profiles / profile + catalog = json.loads((directory / "catalog.json").read_text()) + catalog["channel"] = channel + (directory / "catalog.json").write_text(json.dumps(catalog)) + self.sign(directory) + + def test_a_delivery_declaring_testing_is_the_bundled_default(self): + self.declare("testing") + output = self.root / "output" + with patch.object(module, "ROOT", self.root): + module.prepare(self.profiles, output, sealed=True) + self.assertEqual(json.loads((output / "catalog.json").read_text())["channel"], "testing") + + def test_a_delivery_signed_for_another_channel_emits_no_release(self): + for channel in ("stable", "rc", "edge", "", 5): + with self.subTest(channel=channel): + self.declare(channel) + output = self.root / f"output-{channel}" + with patch.object(module, "ROOT", self.root), self.assertRaises(ValueError): + module.prepare(self.profiles, output, sealed=True) + self.assertFalse(output.exists()) + def test_default_accepts_nine_profiles_and_opt_in_requires_omarchy(self): import shutil shutil.rmtree(self.profiles / module.OMARCHY_PROFILE) diff --git a/macOS/scripts/tests/test_make_unsigned_catalog.py b/macOS/scripts/tests/test_make_unsigned_catalog.py index 2aec6578..ec670c0f 100644 --- a/macOS/scripts/tests/test_make_unsigned_catalog.py +++ b/macOS/scripts/tests/test_make_unsigned_catalog.py @@ -132,6 +132,13 @@ def test_emits_schema_five_without_an_expiry(self) -> None: self.assertEqual(catalog["sequence"], 1788480000) self.assertEqual(len(catalog["models"]), len(self.inputs["device_identifiers"])) + def test_every_catalog_declares_the_testing_channel(self) -> None: + # The signature covers the channel only when the catalog declares it. + result = self.generate() + self.assertEqual(result.returncode, 0, result.stderr) + catalog = json.loads((self.directory / "catalog.json").read_text()) + self.assertEqual(catalog["channel"], "testing") + def test_schema_five_binds_only_native_delivery_assets(self) -> None: document = self.with_neo() document["schema_version"] = 5 diff --git a/macOS/test/shell.d/apple-installer-channel-publish-test.sh b/macOS/test/shell.d/apple-installer-channel-publish-test.sh index c91cd189..1661097e 100755 --- a/macOS/test/shell.d/apple-installer-channel-publish-test.sh +++ b/macOS/test/shell.d/apple-installer-channel-publish-test.sh @@ -234,22 +234,34 @@ with open(output, "w", encoding="utf-8") as stream: PY } +# publish_candidate TAG SEQUENCE URL SIZE [CHANNELS] [FILE] +# Stages one signed catalog per channel, each declaring its channel, as +# catalog..signed.json: a set bound for stable and rc by default. +# FILE stages a single channel's catalog under that name instead, and the +# channel "undeclared" stages catalog.signed.json with no channel at all, as +# catalogs from before the channel field were. publish_candidate() { - local tag=$1 sequence=$2 payload_url=$3 payload_size=$4 declared_channel=${5:-} - local catalog="$WORK/$tag.catalog" signature="$WORK/$tag.sig" - write_catalog "$catalog" "$sequence" "$payload_url" "$payload_size" - if [[ -n $declared_channel ]]; then - python3 - "$catalog" "$declared_channel" <<'PYCHANNEL' + local tag=$1 sequence=$2 payload_url=$3 payload_size=$4 channels=${5:-stable rc} file=${6:-} + local channel catalog signature name + mkdir -p "$STREAM_DIR/releases/$tag" + for channel in $channels; do + catalog="$WORK/$tag.$channel.catalog" signature="$WORK/$tag.$channel.sig" + write_catalog "$catalog" "$sequence" "$payload_url" "$payload_size" + name=${file:-catalog.$channel.signed.json} + if [[ $channel == "undeclared" ]]; then + name=${file:-catalog.signed.json} + else + python3 - "$catalog" "$channel" <<'PYCHANNEL' import json, sys from pathlib import Path p = Path(sys.argv[1]); value = json.loads(p.read_text()); value['channel'] = sys.argv[2] p.write_text(json.dumps(value)) PYCHANNEL - fi - sign_catalog "$catalog" "$signature" - mkdir -p "$STREAM_DIR/releases/$tag" - "$PUBLISHER" envelope --catalog "$catalog" --signature "$signature" \ - --output "$STREAM_DIR/releases/$tag/catalog.signed.json" >/dev/null + fi + sign_catalog "$catalog" "$signature" + "$PUBLISHER" envelope --catalog "$catalog" --signature "$signature" \ + --output "$STREAM_DIR/releases/$tag/$name" >/dev/null + done } stage_payload() { @@ -279,7 +291,7 @@ MX_ROOT_DIGEST=$(root_digest) # --- the envelope carries the catalog and its signature together ------------ stage_payload "os-v4.0.2-mac.1.20260902" 128 publish_candidate "os-v4.0.2-mac.1.20260902" 100 "$BASE/releases/os-v4.0.2-mac.1.20260902/payload.zip" 128 -[[ -f $STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.signed.json ]] || +[[ -f $STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.stable.signed.json ]] || fail "envelope is written" python3 -c ' import base64, json, sys @@ -287,7 +299,7 @@ d = json.load(open(sys.argv[1])) assert set(d) == {"schema_version", "catalog", "signature"}, d.keys() assert d["schema_version"] == 1 json.loads(base64.b64decode(d["catalog"])) -' "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.signed.json" || +' "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.stable.signed.json" || fail "envelope decodes to a catalog and a signature" pass "an envelope holds the catalog and its signature in one object" @@ -764,7 +776,7 @@ rm -f "$BUCKET_LOCKED" # Restore the fixture state the later prune cases expect: stable back on …20260902. rm -rf "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260701" "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260908" publish_candidate "os-v4.0.2-mac.1.20260902" 100 "$BASE/releases/os-v4.0.2-mac.1.20260902/payload.zip" 128 -cp "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.signed.json" "$STREAM_DIR/channels/stable/catalog.signed.json" +cp "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260902/catalog.stable.signed.json" "$STREAM_DIR/channels/stable/catalog.signed.json" pass "a bucket lock is reported after promotion, never as a failed release" # --- prune keeps what a channel can reach and the newest spare set ---------- @@ -811,7 +823,7 @@ pass "prune deletes only unreferenced immutable sets and never a channel object" # --- Testing is development; Edge requires a separate qualified Alpha --------- stage_payload "os-v4.0.2-mac.1.20260910" 128 -publish_candidate "os-v4.0.2-mac.1.20260910" 900 "$BASE/releases/os-v4.0.2-mac.1.20260910/payload.zip" 128 testing +publish_candidate "os-v4.0.2-mac.1.20260910" 900 "$BASE/releases/os-v4.0.2-mac.1.20260910/payload.zip" 128 testing catalog.signed.json AURORA_PUBLISH_ASSUME_YES=os-v4.0.2-mac.1.20260910 "$PUBLISHER" os-promote --tag os-v4.0.2-mac.1.20260910 --to testing \ >"$WORK/testing.log" 2>&1 || fail "testing promotion succeeds" "$(cat "$WORK/testing.log")" [[ -f $STREAM_DIR/channels/testing/catalog.signed.json ]] || fail "the testing catalog is published" @@ -836,46 +848,119 @@ grep -q "catalog_sequence=900" "$WORK/testing-status.log" || fail "status reads grep -q "catalog=absent" "$WORK/edge-status.log" || fail "Edge does not alias testing" pass "testing stays development and cannot be promoted or relabelled as Edge" +# --- a catalog that declares no channel is promoted nowhere ------------------- +# Its signature would verify on every channel alike, so nothing binds it to +# the one it is served on. +stage_payload "os-v4.0.2-mac.1.20260914" 128 +publish_candidate "os-v4.0.2-mac.1.20260914" 950 "$BASE/releases/os-v4.0.2-mac.1.20260914/payload.zip" 128 undeclared +before_calls=$(grep -c '^aws ' "$CALLS" || true) +before=$(find "$STREAM_DIR/channels" -type f | sort | xargs shasum | shasum | cut -d" " -f1) +for target in stable rc testing; do + if AURORA_PUBLISH_ASSUME_YES=os-v4.0.2-mac.1.20260914 "$PUBLISHER" os-promote \ + --tag os-v4.0.2-mac.1.20260914 --to "$target" >"$WORK/undeclared-$target.log" 2>&1; then + fail "an undeclared catalog is not promoted to $target" + fi + grep -q "catalog declares no channel" "$WORK/undeclared-$target.log" || + fail "the $target refusal names the missing channel" "$(cat "$WORK/undeclared-$target.log")" +done +[[ $(grep -c '^aws ' "$CALLS" || true) == "$before_calls" ]] || fail "an undeclared catalog reaches no publication" +after=$(find "$STREAM_DIR/channels" -type f | sort | xargs shasum | shasum | cut -d" " -f1) +[[ $before == "$after" ]] || fail "an undeclared catalog changes no channel" +rm -rf "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260914" +pass "a catalog that declares no channel is refused on stable, rc and testing" + +# --- a set bound for two channels stages one signed catalog for each ---------- +# The stable and rc catalogs of …20260907 are different signed bytes; neither +# channel was ever handed the other's. +for target in stable rc; do + python3 -c ' +import base64, json, sys +catalog = json.loads(base64.b64decode(json.load(open(sys.argv[1]))["catalog"])) +assert catalog["channel"] == sys.argv[2], catalog.get("channel") +' "$STREAM_DIR/channels/$target/catalog.signed.json" "$target" || + fail "the $target channel serves a catalog declaring $target" +done +"$PUBLISHER" channel-status --channel stable >"$WORK/declared-status.log" 2>&1 || fail "stable status succeeds" +grep -q "catalog_channel=stable" "$WORK/declared-status.log" || + fail "status reports the declared channel" "$(cat "$WORK/declared-status.log")" +pass "every promoted channel serves a catalog declaring that channel" + # --- a channel with no Mac release serves a signed empty catalog -------------- -"$PUBLISHER" empty-catalog --sequence 1000 --output "$WORK/empty.catalog" >"$WORK/empty.log" 2>&1 || +"$PUBLISHER" empty-catalog --channel stable --sequence 1000 --output "$WORK/empty.catalog" >"$WORK/empty.log" 2>&1 || fail "empty-catalog succeeds" "$(cat "$WORK/empty.log")" python3 -c ' import json, sys catalog = json.load(open(sys.argv[1])) -assert set(catalog) == {"schemaVersion", "sequence", "issuedAt", "models"}, catalog +assert set(catalog) == {"schemaVersion", "channel", "sequence", "issuedAt", "models"}, catalog assert catalog["schemaVersion"] == 5 and catalog["sequence"] == 1000 and catalog["models"] == [] -' "$WORK/empty.catalog" || fail "the empty catalog is a schema-5 catalog without models" -"$PUBLISHER" empty-catalog --sequence 1000 --output "$WORK/empty.catalog" >/dev/null 2>&1 && +assert catalog["channel"] == "stable", catalog +' "$WORK/empty.catalog" || fail "the empty catalog is a schema-5 catalog without models that declares its channel" +grep -q "^catalog_channel=stable$" "$WORK/empty.log" || fail "empty-catalog reports its channel" +"$PUBLISHER" empty-catalog --sequence 1000 --output "$WORK/nochannel.catalog" >/dev/null 2>&1 && + fail "empty-catalog refuses to write a catalog without a channel" +[[ ! -e $WORK/nochannel.catalog ]] || fail "no undeclared empty catalog is written" +"$PUBLISHER" empty-catalog --channel nightly --sequence 1000 --output "$WORK/nightly.catalog" >/dev/null 2>&1 && + fail "empty-catalog refuses an unknown channel" +for declared in rc testing edge; do + "$PUBLISHER" empty-catalog --channel "$declared" --sequence 1000 --output "$WORK/empty.$declared.catalog" >/dev/null || + fail "empty-catalog writes the $declared channel's empty catalog" + [[ $(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["channel"])' "$WORK/empty.$declared.catalog") == "$declared" ]] || + fail "the $declared empty catalog declares $declared" +done +"$PUBLISHER" empty-catalog --channel stable --sequence 1000 --output "$WORK/empty.catalog" >/dev/null 2>&1 && fail "empty-catalog never overwrites" -"$PUBLISHER" empty-catalog --sequence 0 --output "$WORK/zero.catalog" >/dev/null 2>&1 && +"$PUBLISHER" empty-catalog --channel stable --sequence 0 --output "$WORK/zero.catalog" >/dev/null 2>&1 && fail "empty-catalog refuses a zero sequence" -"$PUBLISHER" empty-catalog --sequence $(( $(date +%s) + 86400 )) --output "$WORK/future.catalog" >/dev/null 2>&1 && +"$PUBLISHER" empty-catalog --channel stable --sequence $(( $(date +%s) + 86400 )) --output "$WORK/future.catalog" >/dev/null 2>&1 && fail "empty-catalog refuses a sequence later than now" before=$(date +%s) -"$PUBLISHER" empty-catalog --output "$WORK/now.catalog" >/dev/null || fail "empty-catalog defaults its sequence" +"$PUBLISHER" empty-catalog --channel stable --output "$WORK/now.catalog" >/dev/null || fail "empty-catalog defaults its sequence" python3 -c 'import json, sys; s = json.load(open(sys.argv[1]))["sequence"]; assert int(sys.argv[2]) <= s <= int(sys.argv[2]) + 60, s' \ "$WORK/now.catalog" "$before" || fail "the default sequence is the current Unix time" sign_catalog "$WORK/empty.catalog" "$WORK/empty.sig" +sign_catalog "$WORK/empty.rc.catalog" "$WORK/empty.rc.sig" mkdir -p "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty" "$PUBLISHER" envelope --catalog "$WORK/empty.catalog" --signature "$WORK/empty.sig" \ - --output "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.signed.json" >/dev/null || + --output "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.stable.signed.json" >/dev/null || fail "the empty catalog wraps into an envelope" +# The stable channel's empty catalog alone, staged as the set's only catalog, +# is not rc's: rc needs the empty catalog signed for rc. +cp "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.stable.signed.json" \ + "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.signed.json" +if AURORA_PUBLISH_ASSUME_YES=os-v4.0.2-mac.1.20260911-empty "$PUBLISHER" os-promote \ + --tag os-v4.0.2-mac.1.20260911-empty --to rc >"$WORK/empty-wrong.log" 2>&1; then + fail "the stable channel's empty catalog is not promoted to rc" +fi +grep -q "catalog is bound to stable" "$WORK/empty-wrong.log" || + fail "the refusal names the empty catalog's channel" "$(cat "$WORK/empty-wrong.log")" +rm "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.signed.json" +"$PUBLISHER" envelope --catalog "$WORK/empty.rc.catalog" --signature "$WORK/empty.rc.sig" \ + --output "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.rc.signed.json" >/dev/null || + fail "the rc empty catalog wraps into an envelope" # Stable prunes after promotion; the empty set must survive it, or rc could # no longer be promoted from the same tag. AURORA_PUBLISH_ASSUME_YES=os-v4.0.2-mac.1.20260911-empty "$PUBLISHER" os-promote \ --tag os-v4.0.2-mac.1.20260911-empty --to stable >"$WORK/empty-stable.log" 2>&1 || fail "the empty catalog promotes to stable" "$(cat "$WORK/empty-stable.log")" -[[ -f $STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.signed.json ]] || +[[ -f $STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.rc.signed.json ]] || fail "the stable prune keeps the set stable now serves" "$(cat "$WORK/empty-stable.log")" AURORA_PUBLISH_ASSUME_YES=os-v4.0.2-mac.1.20260911-empty "$PUBLISHER" os-promote \ --tag os-v4.0.2-mac.1.20260911-empty --to rc >"$WORK/empty-rc.log" 2>&1 || fail "the empty catalog then promotes to rc" "$(cat "$WORK/empty-rc.log")" -cmp -s "$STREAM_DIR/channels/stable/catalog.signed.json" "$STREAM_DIR/channels/rc/catalog.signed.json" || - fail "stable and rc serve the same empty catalog" -pass "a signed empty catalog promotes to stable and rc and survives the stable prune" +cmp -s "$STREAM_DIR/channels/stable/catalog.signed.json" \ + "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.stable.signed.json" || + fail "stable serves the empty catalog signed for stable" +cmp -s "$STREAM_DIR/channels/rc/catalog.signed.json" \ + "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260911-empty/catalog.rc.signed.json" || + fail "rc serves the empty catalog signed for rc" +"$PUBLISHER" channel-status --channel all >"$WORK/empty-status.log" 2>&1 || + fail "channel-status reads the empty channels" "$(cat "$WORK/empty-status.log")" +grep -q "stable_equals_rc=yes" "$WORK/empty-status.log" || + fail "stable and rc offer the same empty release" "$(cat "$WORK/empty-status.log")" +pass "each channel's own signed empty catalog promotes to it and survives the stable prune" # --- replacing an empty catalog keeps it as the rollback set ----------------- -"$PUBLISHER" empty-catalog --sequence 1100 --output "$WORK/empty2.catalog" >/dev/null +"$PUBLISHER" empty-catalog --channel rc --sequence 1100 --output "$WORK/empty2.catalog" >/dev/null sign_catalog "$WORK/empty2.catalog" "$WORK/empty2.sig" mkdir -p "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260912-empty" "$PUBLISHER" envelope --catalog "$WORK/empty2.catalog" --signature "$WORK/empty2.sig" \ @@ -890,7 +975,7 @@ pass "an empty catalog it replaces stays recorded for rollback" # An old app still reads its bundled legacy development endpoint. Pruning # must retain payloads reachable only through that compatibility alias. stage_payload "os-v4.0.2-mac.1.20260913" 128 -publish_candidate "os-v4.0.2-mac.1.20260913" 1200 "$BASE/releases/os-v4.0.2-mac.1.20260913/payload.zip" 128 +publish_candidate "os-v4.0.2-mac.1.20260913" 1200 "$BASE/releases/os-v4.0.2-mac.1.20260913/payload.zip" 128 undeclared mkdir -p "$STREAM_DIR/channels/edge" cp "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260913/catalog.signed.json" "$STREAM_DIR/channels/edge/catalog.signed.json" AURORA_PUBLISH_ASSUME_YES=prune "$PUBLISHER" prune --confirm >"$WORK/legacy-prune.log" 2>&1 || fail "legacy-aware prune succeeds" From ffad3f556a389e9fc78488eafb7c15e4cb71cec8 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 12:36:03 +1100 Subject: [PATCH 2/7] catalog: require every channel's catalog to declare that channel The app accepted a signed catalog with no channel field on Stable and RC without any check, and an empty undeclared one on Edge. Such a catalog verifies on every channel alike, so one channel's catalog, or an old one, could be served on another. Stable, RC and Edge now accept only a catalog whose signed channel is that channel, an empty catalog included. Testing keeps one exception, because the development deliveries published today carry no channel: an undeclared catalog is read as Testing only when it lists models and every one is of that delivery lineage. An undeclared empty catalog is no longer accepted there. Signed-off-by: Ryan Murray --- macOS/Release/README.md | 2 + .../ReleaseCatalogChannelPolicy.swift | 20 ++- .../InstallerAssetPreparerTests.swift | 2 +- .../ReleaseChannelAvailabilityTests.swift | 141 ++++++++++++++++-- 4 files changed, 147 insertions(+), 18 deletions(-) diff --git a/macOS/Release/README.md b/macOS/Release/README.md index cf7be797..dd33575d 100644 --- a/macOS/Release/README.md +++ b/macOS/Release/README.md @@ -27,3 +27,5 @@ Every catalog must use schema 5 and select the built-in `native-v1` engine. Olde The descriptor remains schema 3 and names four distinct channel endpoints, with Testing as the bundled default. The bundled default is the sealed, offline fallback, never Edge. In the standard build a new installation opens on Edge instead when the selected profile's verified Edge catalog admits this Mac and lists it as family-qualified: `edgeQualification.devices` maps the Mac's device identifier to `{"evidenceDigest": "sha256:<64 hex>"}`, the digest of a detached evidence record naming the Mac and the machine row its chip family passed. One qualified machine qualifies its family; the app checks only that the map is well formed, and which models a row covers is the signed publisher's policy. A catalog without `devices` but with `neoEvidence` qualifies only `apple,j700` (a temporary fallback for alpha.1/alpha.2 catalogs, to be removed in a follow-up PR once `fedora-kde` Edge is re-published with `devices`), and a malformed `devices` qualifies no Mac. A listed Mac that isn't family-qualified, or a catalog with no release for it, opens on Nightly; Edge can still be chosen where it is listed. An Edge catalog that cannot be fetched or verified keeps Edge chosen rather than falling back, so preparing retries it, and Check Channels Again decides that default again from the same read the menu shows. Each profile is decided once per launch, and a Release channel menu choice wins. Reset and Update Boot Loader act on an existing installation and read the channel recorded when this app installed it (by the space it occupies), or Testing when none was recorded, never the Edge default; their masthead names that channel, Edge included. Because `InstallationChannelRecordStore` is stored per-user in Application Support, running Reset or Update Boot Loader from a different macOS account finds no record and falls back to Testing (shown in the masthead). Installations made before the record existed read Testing: the lane in the installation's own `omarchy/install.conf` is on its EFI partition, which only the privileged helper mounts, and `lane=edge` from installers before alpha.22 meant today's Testing. Developer and private builds keep the bundled default. Edge's ID is `edge`; its new URL is `channels/edge-alpha/catalog.signed.json`. The older `channels/edge` URL is a legacy Testing alias for already released installers and never carries the new Edge track. A legacy three-channel descriptor is read as a development descriptor: its old default Edge resolves to Testing, while new Edge is unavailable. A sealed catalog is usable only for its own default channel. Edge cannot reuse a sealed Testing catalog. Missing Edge endpoints, signed empty Edge catalogs and unqualified legacy development catalogs are displayed as unavailable without substituting Testing. A nonempty Edge catalog must carry signed `channel: edge` and a valid `edgeQualification` bound to the actual payload, Linux/Mesa source revisions and Git tree IDs. + +Every channel's catalog declares that channel in its signed `channel` field, an empty catalog included: `scripts/publish-channels empty-catalog --channel ` writes it, and `os-promote` refuses a catalog that declares another channel or none. A release set bound for more than one channel stages one signed catalog for each as `releases//catalog..signed.json`. The app accepts a Stable, RC or Edge catalog only when it declares that channel. Testing keeps one exception for the development deliveries published before the field existed: an undeclared catalog is read as Testing only when it lists models and every one is of that delivery lineage (or disabled). That exception goes away once those deliveries are republished with `channel: testing`. diff --git a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift index 332c422d..136f73a9 100644 --- a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift +++ b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift @@ -2,7 +2,13 @@ import Foundation /// Applied only after the catalog signature and rollback floor are verified. - /// Legacy development catalogs belong to Testing; they can never become Edge. + /// The signed `channel` is what binds a catalog to the channel it is served + /// on: every channel's catalog, an empty one included, must declare that + /// channel, or the same signed bytes could be served on any of them. The one + /// exception is Testing, whose published development deliveries predate the + /// field: an undeclared catalog is accepted there only when it lists models + /// and each of them is of that delivery lineage. Those catalogs belong to + /// Testing; they can never become Stable, RC or Edge. enum ReleaseCatalogChannelPolicy { static func validate(payload: Data, channel: ReleaseChannel) throws { guard let object = try JSONSerialization.jsonObject(with: payload) as? [String: Any], @@ -13,15 +19,13 @@ throw InstallerReleaseConfigurationError.invalidCatalogChannel } guard channel == .edge else { - if let declared, declared != channel.rawValue { - throw InstallerReleaseConfigurationError.invalidCatalogChannel - } - if channel == .testing && declared == nil && !models.allSatisfy(isLegacyDevelopment) { - throw InstallerReleaseConfigurationError.invalidCatalogChannel - } + if declared == channel.rawValue { return } + guard channel == .testing, declared == nil, !models.isEmpty, + models.allSatisfy(isLegacyDevelopment) + else { throw InstallerReleaseConfigurationError.invalidCatalogChannel } return } - if models.isEmpty && (declared == nil || declared == "edge") { return } + if models.isEmpty && declared == "edge" { return } guard declared == "edge" else { throw InstallerReleaseConfigurationError.edgeAlphaUnavailable } diff --git a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/InstallerAssetPreparerTests.swift b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/InstallerAssetPreparerTests.swift index 3e395511..d91d33f4 100644 --- a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/InstallerAssetPreparerTests.swift +++ b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/InstallerAssetPreparerTests.swift @@ -578,7 +578,7 @@ } ?? "" return Data( """ - {"schemaVersion":\(schemaVersion),"sequence":30,"issuedAt":"\(issued)","expiresAt":"\(expires)"\(installer),"models":[{"deviceIdentifier":"apple,j314s","status":"enabled","asahiInstallerTag":"v0.9.0","asahiInstallerRevision":"\(String(repeating: "a", count: 40))","asahiInstallerDataRevision":"\(String(repeating: "b", count: 40))","downstreamRevision":"\(String(repeating: "c", count: 40))","metadataDigest":"\(digest(metadata))","payloadDigest":"\(digest(payload))","evidenceRevision":"\(evidenceRevision)"\(delivery)}]} + {"schemaVersion":\(schemaVersion),"channel":"stable","sequence":30,"issuedAt":"\(issued)","expiresAt":"\(expires)"\(installer),"models":[{"deviceIdentifier":"apple,j314s","status":"enabled","asahiInstallerTag":"v0.9.0","asahiInstallerRevision":"\(String(repeating: "a", count: 40))","asahiInstallerDataRevision":"\(String(repeating: "b", count: 40))","downstreamRevision":"\(String(repeating: "c", count: 40))","metadataDigest":"\(digest(metadata))","payloadDigest":"\(digest(payload))","evidenceRevision":"\(evidenceRevision)"\(delivery)}]} """.utf8 ) } diff --git a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift index 46e88f5a..02a4d5ea 100644 --- a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift +++ b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift @@ -88,12 +88,114 @@ func testSignedEmptyEdgeIsClearlyEmptyWithoutInventingQualification() async throws { let configuration = try configuration() let value = coordinator(serving: [ - configuration.catalogURL(for: .edge): try envelope(emptyCatalog(sequence: 5)) + configuration.catalogURL(for: .edge): try envelope( + emptyCatalog(sequence: 5, channel: .edge)) ]) let state = await availability(value, configuration, .edge) XCTAssertEqual(state, .noRelease) } + func testAnEmptyEdgeCatalogMustDeclareEdge() async throws { + // An empty catalog signed for no channel, or for another one, says + // nothing about Edge: served there it must not read as "no release yet". + let configuration = try configuration() + let others: [ReleaseChannel?] = [nil, .stable, .rc, .testing] + for declared in others { + let value = coordinator(serving: [ + configuration.catalogURL(for: .edge): try envelope( + emptyCatalog(sequence: 5, channel: declared)) + ]) + let state = await availability(value, configuration, .edge) + XCTAssertEqual(state, .notPublished, declared?.rawValue ?? "undeclared") + } + } + + // MARK: Every channel's catalog declares that channel + + func testStableAndRCRefuseACatalogThatDeclaresNoChannel() async throws { + // The signature covers the channel only when the catalog declares it. + // Without it the same signed bytes verify on every channel. + let configuration = try configuration() + var object = try XCTUnwrap( + JSONSerialization.jsonObject(with: modelCatalog(devices: [thisMac])) as? [String: Any]) + object["channel"] = nil + let undeclared = try JSONSerialization.data(withJSONObject: object) + for channel in [ReleaseChannel.stable, .rc] { + for payload in [undeclared, emptyCatalog(sequence: 5, channel: nil)] { + let value = coordinator(serving: [ + configuration.catalogURL(for: channel): try envelope(payload) + ]) + let state = await availability(value, configuration, channel) + XCTAssertEqual(state, .checkFailed(.verification), channel.rawValue) + } + } + } + + func testACatalogSignedForOneChannelIsRefusedOnEveryOther() async throws { + let configuration = try configuration() + for declared in ReleaseChannel.allCases { + for payload in [ + modelCatalog(devices: [thisMac], channel: declared), + emptyCatalog(sequence: 5, channel: declared), + ] { + for channel in [ReleaseChannel.stable, .rc, .testing] { + let value = coordinator(serving: [ + configuration.catalogURL(for: channel): try envelope(payload) + ]) + let state = await availability(value, configuration, channel) + let label = "\(declared.rawValue) on \(channel.rawValue)" + if declared == channel { + XCTAssertNotEqual(state, .checkFailed(.verification), label) + } else { + XCTAssertEqual(state, .checkFailed(.verification), label) + } + } + } + } + } + + func testAnUndeclaredLegacyDeliveryIsTestingOnly() async throws { + // The published development deliveries predate the channel field. They + // stay readable on Testing and nowhere else. + let configuration = try configuration() + let legacy = try legacyDevelopmentCatalog() + let testing = coordinator(serving: [ + configuration.catalogURL(for: .testing): try envelope(legacy) + ]) + let accepted = await availability(testing, configuration, .testing) + XCTAssertEqual(accepted, .available) + for channel in [ReleaseChannel.stable, .rc] { + let value = coordinator(serving: [ + configuration.catalogURL(for: channel): try envelope(legacy) + ]) + let state = await availability(value, configuration, channel) + XCTAssertEqual(state, .checkFailed(.verification), channel.rawValue) + } + let edge = coordinator(serving: [ + configuration.catalogURL(for: .edge): try envelope(legacy) + ]) + let unavailable = await availability(edge, configuration, .edge) + XCTAssertEqual(unavailable, .notPublished) + } + + func testAnUndeclaredEmptyCatalogIsNotALegacyTestingDelivery() async throws { + // The Testing exception is for a delivery that lists its models. An + // empty catalog signed for no channel is not one. + let configuration = try configuration() + let value = coordinator(serving: [ + configuration.catalogURL(for: .testing): try envelope( + emptyCatalog(sequence: 5, channel: nil)) + ]) + let undeclared = await availability(value, configuration, .testing) + XCTAssertEqual(undeclared, .checkFailed(.verification)) + let declared = coordinator(serving: [ + configuration.catalogURL(for: .testing): try envelope( + emptyCatalog(sequence: 5, channel: .testing)) + ]) + let empty = await availability(declared, configuration, .testing) + XCTAssertEqual(empty, .noRelease) + } + func testAQualifiedSignedEdgeAlphaIsSupportedButCannotBeReadAsTesting() async throws { let configuration = try configuration() var object = try XCTUnwrap( @@ -277,7 +379,8 @@ func testEachChannelReportsItsOwnStateFromItsSignedCatalog() async throws { let configuration = try configuration() let coordinator = coordinator(serving: [ - configuration.catalogURL(for: .stable): try envelope(emptyCatalog(sequence: 5)), + configuration.catalogURL(for: .stable): try envelope( + emptyCatalog(sequence: 5, channel: .stable)), configuration.catalogURL(for: .rc): try envelope( modelCatalog(devices: ["apple,j274"], channel: .rc)), configuration.catalogURL(for: .testing): try envelope(modelCatalog(devices: [thisMac])), @@ -294,7 +397,7 @@ func testAnEmptyCatalogWithABadSignatureIsNeverReadAsNoRelease() async throws { let configuration = try configuration() - let payload = emptyCatalog(sequence: 5) + let payload = emptyCatalog(sequence: 5, channel: .stable) let coordinator = coordinator(serving: [ configuration.catalogURL(for: .stable): envelope( payload: payload, signature: Data(repeating: 1, count: 64)) @@ -317,7 +420,8 @@ func testAnEmptyCatalogBelowTheRollbackFloorIsAVerificationFailure() async throws { let configuration = try configuration() let coordinator = coordinator(serving: [ - configuration.catalogURL(for: .stable): try envelope(emptyCatalog(sequence: 5)) + configuration.catalogURL(for: .stable): try envelope( + emptyCatalog(sequence: 5, channel: .stable)) ]) let stable = await coordinator.availability( @@ -332,7 +436,7 @@ // MARK: Preparation on a channel with no Mac release func testPreparingFromAnEmptyCatalogSaysTheChannelHasNoMacRelease() async throws { - let payload = emptyCatalog(sequence: 5) + let payload = emptyCatalog(sequence: 5, channel: .stable) let request = InstallerAssetPreparationRequest( host: host(), catalogPayload: payload, @@ -438,14 +542,33 @@ assetPreparer: InstallerAssetPreparer()) } - /// What `publish-channels empty-catalog` writes. - private func emptyCatalog(sequence: Int) -> Data { - Data( + /// What `publish-channels empty-catalog --channel` writes. Without a + /// channel it is the undeclared form older publishers wrote. + private func emptyCatalog(sequence: Int, channel: ReleaseChannel?) -> Data { + let declared = channel.map { "\"channel\":\"\($0.rawValue)\"," } ?? "" + return Data( """ - {"schemaVersion":5,"sequence":\(sequence),"issuedAt":"2026-09-01T00:00:00Z","models":[]} + {"schemaVersion":5,\(declared)"sequence":\(sequence),"issuedAt":"2026-09-01T00:00:00Z","models":[]} """.utf8) } + /// An undeclared catalog of the published development delivery lineage. + private func legacyDevelopmentCatalog() throws -> Data { + var object = try XCTUnwrap( + JSONSerialization.jsonObject(with: modelCatalog(devices: [thisMac])) as? [String: Any]) + object["channel"] = nil + var models = try XCTUnwrap(object["models"] as? [[String: Any]]) + models[0]["installationProfile"] = "fedora-kde" + models[0]["evidenceRevision"] = "image-build-41" + models[0]["payloadArtifact"] = [ + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/" + + "payload-fedora-kde-41/payload.zip", + "fileName": "payload.zip", "sizeBytes": 1, + ] + object["models"] = models + return try JSONSerialization.data(withJSONObject: object) + } + private func modelCatalog(devices: [String], channel: ReleaseChannel = .testing) -> Data { let models = devices.map { device in """ From 1f1232b346a5a5da861f9b10bd8faf5b6c2a3bcd Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 14:21:59 +1100 Subject: [PATCH 3/7] publish-channels: fall back to catalog.signed.json only on a 404 os-promote read releases//catalog..signed.json and, on any failure to fetch it, promoted releases//catalog.signed.json instead. A 5xx, a reset or a truncated body for the channel's own catalog could therefore promote the other file without a word, when that file also declared the channel. The fetch now goes through fetch_status: only a 404 falls back, and any other result stops the promotion and names the status. Signed-off-by: Ryan Murray --- macOS/scripts/publish-channels | 23 +++++++++---- .../apple-installer-channel-publish-test.sh | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/macOS/scripts/publish-channels b/macOS/scripts/publish-channels index 1570f969..9e77e77c 100755 --- a/macOS/scripts/publish-channels +++ b/macOS/scripts/publish-channels @@ -350,12 +350,23 @@ os_promote() { # A set offered on more than one channel stages one signed catalog per # channel, catalog..signed.json; a set for a single channel may # stage just catalog.signed.json. Either must declare the channel it goes to. - local candidate_key="releases/$tag/catalog.$channel.signed.json" - if ! fetch_public "$candidate_key" "$work/candidate.json"; then - candidate_key="releases/$tag/catalog.signed.json" - fetch_public "$candidate_key" "$work/candidate.json" || - die "neither releases/$tag/catalog.$channel.signed.json nor $candidate_key is published" - fi + # Only a 404 for the channel's own catalog falls back to the single one; any + # other failure stops, so a transient error can't promote the other file. + local candidate_key="releases/$tag/catalog.$channel.signed.json" candidate_status + candidate_status=$(fetch_status "$candidate_key" "$work/candidate.json") + case $candidate_status in + 200) ;; + 404) + candidate_key="releases/$tag/catalog.signed.json" + candidate_status=$(fetch_status "$candidate_key" "$work/candidate.json") + case $candidate_status in + 200) ;; + 404) die "neither releases/$tag/catalog.$channel.signed.json nor $candidate_key is published" ;; + *) die "could not read $candidate_key ($candidate_status)" ;; + esac + ;; + *) die "could not read $candidate_key ($candidate_status); not falling back to releases/$tag/catalog.signed.json" ;; + esac echo "Reading $candidate_key" decode_envelope "$work/candidate.json" "$work/catalog" "$work/signature" verify_catalog "$work/catalog" "$work/signature" diff --git a/macOS/test/shell.d/apple-installer-channel-publish-test.sh b/macOS/test/shell.d/apple-installer-channel-publish-test.sh index 1661097e..b0695472 100755 --- a/macOS/test/shell.d/apple-installer-channel-publish-test.sh +++ b/macOS/test/shell.d/apple-installer-channel-publish-test.sh @@ -869,6 +869,38 @@ after=$(find "$STREAM_DIR/channels" -type f | sort | xargs shasum | shasum | cut rm -rf "$STREAM_DIR/releases/os-v4.0.2-mac.1.20260914" pass "a catalog that declares no channel is refused on stable, rc and testing" +# --- only a 404 for catalog..signed.json falls back ----------------- +# A set staging both files, where the single catalog.signed.json also declares +# the channel: an error reading the channel's own file must stop the promotion, +# not quietly promote the other one. +fallback_tag=os-v4.0.2-mac.1.20260915 +stage_payload "$fallback_tag" 128 +publish_candidate "$fallback_tag" 960 "$BASE/releases/$fallback_tag/payload.zip" 128 testing +publish_candidate "$fallback_tag" 960 "$BASE/releases/$fallback_tag/payload.zip" 128 testing catalog.signed.json +before=$(find "$STREAM_DIR/channels" -type f | sort | xargs shasum | shasum | cut -d" " -f1) +for failure in CURL_UNAVAILABLE CURL_TRUNCATED; do + if env "$failure=releases/$fallback_tag/catalog.testing.signed.json" \ + AURORA_PUBLISH_ASSUME_YES=$fallback_tag "$PUBLISHER" os-promote \ + --tag "$fallback_tag" --to testing --no-prune >"$WORK/fallback-$failure.log" 2>&1; then + fail "a $failure read of the channel's catalog stops the promotion" "$(cat "$WORK/fallback-$failure.log")" + fi + grep -q "could not read releases/$fallback_tag/catalog.testing.signed.json" "$WORK/fallback-$failure.log" || + fail "the $failure refusal names the channel's catalog" "$(cat "$WORK/fallback-$failure.log")" + grep -q "Reading releases/$fallback_tag/catalog.signed.json" "$WORK/fallback-$failure.log" && + fail "a $failure read never falls back to catalog.signed.json" "$(cat "$WORK/fallback-$failure.log")" +done +after=$(find "$STREAM_DIR/channels" -type f | sort | xargs shasum | shasum | cut -d" " -f1) +[[ $before == "$after" ]] || fail "a failed read of the channel's catalog changes no channel" +rm "$STREAM_DIR/releases/$fallback_tag/catalog.testing.signed.json" +AURORA_PUBLISH_ASSUME_YES=$fallback_tag "$PUBLISHER" os-promote \ + --tag "$fallback_tag" --to testing --no-prune >"$WORK/fallback-404.log" 2>&1 || + fail "a 404 for the channel's catalog falls back to catalog.signed.json" "$(cat "$WORK/fallback-404.log")" +grep -q "Reading releases/$fallback_tag/catalog.signed.json" "$WORK/fallback-404.log" || + fail "the 404 fallback reads catalog.signed.json" "$(cat "$WORK/fallback-404.log")" +cmp -s "$STREAM_DIR/channels/testing/catalog.signed.json" "$STREAM_DIR/releases/$fallback_tag/catalog.signed.json" || + fail "testing serves the fallback catalog" +pass "only a 404 for the channel's own catalog falls back to catalog.signed.json" + # --- a set bound for two channels stages one signed catalog for each ---------- # The stable and rc catalogs of …20260907 are different signed bytes; neither # channel was ever handed the other's. From b82866c99f10818cd6aae96536b808f06d9c5329 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 14:22:39 +1100 Subject: [PATCH 4/7] catalog: another channel's catalog on Edge is a verification failure On Stable, RC and Testing a catalog signed for another channel fails verification. On Edge the same catalog was reported as edgeAlphaUnavailable, which the app shows as "Edge isn't available yet", so a mis-served or replayed catalog looked like a quiet empty channel. Edge now throws invalidCatalogChannel when the catalog declares any other channel. Only an undeclared catalog still reads as not published. Signed-off-by: Ryan Murray --- macOS/Release/README.md | 2 +- .../ReleaseCatalogChannelPolicy.swift | 10 ++-- .../ReleaseChannelAvailabilityTests.swift | 50 ++++++++++++++++--- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/macOS/Release/README.md b/macOS/Release/README.md index dd33575d..e593624d 100644 --- a/macOS/Release/README.md +++ b/macOS/Release/README.md @@ -28,4 +28,4 @@ The descriptor remains schema 3 and names four distinct channel endpoints, with A sealed catalog is usable only for its own default channel. Edge cannot reuse a sealed Testing catalog. Missing Edge endpoints, signed empty Edge catalogs and unqualified legacy development catalogs are displayed as unavailable without substituting Testing. A nonempty Edge catalog must carry signed `channel: edge` and a valid `edgeQualification` bound to the actual payload, Linux/Mesa source revisions and Git tree IDs. -Every channel's catalog declares that channel in its signed `channel` field, an empty catalog included: `scripts/publish-channels empty-catalog --channel ` writes it, and `os-promote` refuses a catalog that declares another channel or none. A release set bound for more than one channel stages one signed catalog for each as `releases//catalog..signed.json`. The app accepts a Stable, RC or Edge catalog only when it declares that channel. Testing keeps one exception for the development deliveries published before the field existed: an undeclared catalog is read as Testing only when it lists models and every one is of that delivery lineage (or disabled). That exception goes away once those deliveries are republished with `channel: testing`. +Every channel's catalog declares that channel in its signed `channel` field, an empty catalog included: `scripts/publish-channels empty-catalog --channel ` writes it, and `os-promote` refuses a catalog that declares another channel or none. A release set bound for more than one channel stages one signed catalog for each as `releases//catalog..signed.json`. The app accepts a Stable, RC or Edge catalog only when it declares that channel. A catalog that declares another channel fails verification on every channel, Edge included; on Edge only an undeclared catalog reads as not published. Testing keeps one exception for the development deliveries published before the field existed: an undeclared catalog is read as Testing only when it lists models and every one is of that delivery lineage (or disabled). That exception goes away once those deliveries are republished with `channel: testing`. diff --git a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift index 136f73a9..ad4570f7 100644 --- a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift +++ b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift @@ -25,10 +25,14 @@ else { throw InstallerReleaseConfigurationError.invalidCatalogChannel } return } - if models.isEmpty && declared == "edge" { return } - guard declared == "edge" else { - throw InstallerReleaseConfigurationError.edgeAlphaUnavailable + // A catalog signed for another channel and served on Edge was mis-served + // or replayed: that is a verification failure, as on every other + // channel. Only an undeclared catalog means Edge has no Alpha yet. + guard let declared else { throw InstallerReleaseConfigurationError.edgeAlphaUnavailable } + guard declared == channel.rawValue else { + throw InstallerReleaseConfigurationError.invalidCatalogChannel } + if models.isEmpty { return } guard let envelope = try? JSONDecoder().decode(Envelope.self, from: payload) else { throw InstallerReleaseConfigurationError.invalidEdgeQualification } diff --git a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift index 02a4d5ea..96938307 100644 --- a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift +++ b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift @@ -77,11 +77,11 @@ let configuration = try configuration() let missing = await availability(coordinator(serving: [:]), configuration, .edge) XCTAssertEqual(missing, .notPublished) - let testing = modelCatalog(devices: [thisMac]) - let misplaced = coordinator(serving: [ - configuration.catalogURL(for: .edge): try envelope(testing) + let undeclared = try legacyDevelopmentCatalog() + let legacy = coordinator(serving: [ + configuration.catalogURL(for: .edge): try envelope(undeclared) ]) - let state = await availability(misplaced, configuration, .edge) + let state = await availability(legacy, configuration, .edge) XCTAssertEqual(state, .notPublished) } @@ -96,8 +96,10 @@ } func testAnEmptyEdgeCatalogMustDeclareEdge() async throws { - // An empty catalog signed for no channel, or for another one, says - // nothing about Edge: served there it must not read as "no release yet". + // An empty catalog signed for no channel says nothing about Edge, and + // one signed for another channel was served in the wrong place: neither + // reads as "no release yet". Only the undeclared one is "not published"; + // another channel's is a verification failure, as on every channel. let configuration = try configuration() let others: [ReleaseChannel?] = [nil, .stable, .rc, .testing] for declared in others { @@ -106,7 +108,41 @@ emptyCatalog(sequence: 5, channel: declared)) ]) let state = await availability(value, configuration, .edge) - XCTAssertEqual(state, .notPublished, declared?.rawValue ?? "undeclared") + XCTAssertEqual( + state, declared == nil ? .notPublished : .checkFailed(.verification), + declared?.rawValue ?? "undeclared") + } + } + + func testACatalogSignedForAnotherChannelIsAVerificationFailureOnEdge() async throws { + // Stable, RC or Testing bytes served at the Edge address are a mis-served + // or replayed catalog, not an Edge that isn't published yet. + let configuration = try configuration() + for declared in [ReleaseChannel.stable, .rc, .testing] { + for payload in [ + modelCatalog(devices: [thisMac], channel: declared), + emptyCatalog(sequence: 5, channel: declared), + ] { + XCTAssertThrowsError( + try ReleaseCatalogChannelPolicy.validate(payload: payload, channel: .edge) + ) { + XCTAssertEqual( + $0 as? InstallerReleaseConfigurationError, .invalidCatalogChannel, + declared.rawValue) + } + let value = coordinator(serving: [ + configuration.catalogURL(for: .edge): try envelope(payload) + ]) + let state = await availability(value, configuration, .edge) + XCTAssertEqual(state, .checkFailed(.verification), declared.rawValue) + } + } + for payload in [try legacyDevelopmentCatalog(), emptyCatalog(sequence: 5, channel: nil)] { + XCTAssertThrowsError( + try ReleaseCatalogChannelPolicy.validate(payload: payload, channel: .edge) + ) { + XCTAssertEqual($0 as? InstallerReleaseConfigurationError, .edgeAlphaUnavailable) + } } } From e7a7f0cea0a0e7e8be0585e4d54774a717ed6d2c Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 14:27:59 +1100 Subject: [PATCH 5/7] prepare-distribution-release: apply the app's channel policy to the bundled catalog The bundled catalog replaces the fetch for the default channel, but the release preparation accepted any catalog declaring no channel or Testing. A build could pass it with an undeclared catalog the app then refuses, leaving that build with no working default. The bundled catalog of each profile, and the root one, now pass the rule the app applies: a declared channel must be the descriptor's default channel, and an undeclared catalog is accepted only as Testing and only as a development delivery. The lineage test is ported from ReleaseCatalogChannelPolicy, and a shared vector file pins the Swift and Python implementations to the same cases. Two changes to the app's rule make the port exact and close gaps: - An undeclared catalog must list at least one Mac that is not disabled. A catalog of only disabled models matched the lineage test and read as an empty Testing channel. - The payload source must be the canonical release URL byte for byte, and the file name ASCII letters, digits, '.', '_', '+' and '-'. URL parsing let a port, percent-encoding, doubled slashes and a '..' file name through, which a string check in Python would not mirror. Every published Testing catalog still passes both implementations. Signed-off-by: Ryan Murray --- macOS/Release/README.md | 2 +- .../ReleaseCatalogChannelPolicy.swift | 42 +- .../legacy-testing-catalog-vectors.json | 594 ++++++++++++++++++ .../ReleaseChannelAvailabilityTests.swift | 29 + macOS/scripts/prepare-distribution-release.py | 63 +- .../tests/test_distribution_release.py | 87 ++- 6 files changed, 797 insertions(+), 20 deletions(-) create mode 100644 macOS/Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json diff --git a/macOS/Release/README.md b/macOS/Release/README.md index e593624d..75b09cd4 100644 --- a/macOS/Release/README.md +++ b/macOS/Release/README.md @@ -28,4 +28,4 @@ The descriptor remains schema 3 and names four distinct channel endpoints, with A sealed catalog is usable only for its own default channel. Edge cannot reuse a sealed Testing catalog. Missing Edge endpoints, signed empty Edge catalogs and unqualified legacy development catalogs are displayed as unavailable without substituting Testing. A nonempty Edge catalog must carry signed `channel: edge` and a valid `edgeQualification` bound to the actual payload, Linux/Mesa source revisions and Git tree IDs. -Every channel's catalog declares that channel in its signed `channel` field, an empty catalog included: `scripts/publish-channels empty-catalog --channel ` writes it, and `os-promote` refuses a catalog that declares another channel or none. A release set bound for more than one channel stages one signed catalog for each as `releases//catalog..signed.json`. The app accepts a Stable, RC or Edge catalog only when it declares that channel. A catalog that declares another channel fails verification on every channel, Edge included; on Edge only an undeclared catalog reads as not published. Testing keeps one exception for the development deliveries published before the field existed: an undeclared catalog is read as Testing only when it lists models and every one is of that delivery lineage (or disabled). That exception goes away once those deliveries are republished with `channel: testing`. +Every channel's catalog declares that channel in its signed `channel` field, an empty catalog included: `scripts/publish-channels empty-catalog --channel ` writes it, and `os-promote` refuses a catalog that declares another channel or none. A release set bound for more than one channel stages one signed catalog for each as `releases//catalog..signed.json`. The app accepts a Stable, RC or Edge catalog only when it declares that channel. A catalog that declares another channel fails verification on every channel, Edge included; on Edge only an undeclared catalog reads as not published. Testing keeps one exception for the development deliveries published before the field existed: an undeclared catalog is read as Testing only when it lists at least one Mac that is not disabled and every model is of that delivery lineage (or disabled); a lineage source must be the canonical `https://github.com/aurora-silicon//releases/download//` URL byte for byte. `scripts/prepare-distribution-release.py` applies the same rule to the bundled default catalog, which must otherwise declare the descriptor's default channel; `Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json` pins both implementations to the same cases. That exception goes away once those deliveries are republished with `channel: testing`. diff --git a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift index ad4570f7..83c53652 100644 --- a/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift +++ b/macOS/Sources/AuroraAppleInstaller/ReleaseCatalogChannelPolicy.swift @@ -6,9 +6,10 @@ /// on: every channel's catalog, an empty one included, must declare that /// channel, or the same signed bytes could be served on any of them. The one /// exception is Testing, whose published development deliveries predate the - /// field: an undeclared catalog is accepted there only when it lists models - /// and each of them is of that delivery lineage. Those catalogs belong to - /// Testing; they can never become Stable, RC or Edge. + /// field: an undeclared catalog is accepted there only when it lists a model + /// that isn't disabled and each of them is of that delivery lineage (or + /// disabled). Those catalogs belong to Testing; they can never become Stable, + /// RC or Edge. enum ReleaseCatalogChannelPolicy { static func validate(payload: Data, channel: ReleaseChannel) throws { guard let object = try JSONSerialization.jsonObject(with: payload) as? [String: Any], @@ -20,7 +21,8 @@ } guard channel == .edge else { if declared == channel.rawValue { return } - guard channel == .testing, declared == nil, !models.isEmpty, + guard channel == .testing, declared == nil, + models.contains(where: { $0["status"] as? String != "disabled" }), models.allSatisfy(isLegacyDevelopment) else { throw InstallerReleaseConfigurationError.invalidCatalogChannel } return @@ -92,6 +94,10 @@ && board.allSatisfy { (48...57).contains($0) || (97...122).contains($0) } } + /// The published development delivery lineage. scripts/ + /// prepare-distribution-release.py ports this exactly, and + /// Fixtures/legacy-testing-catalog-vectors.json pins both to the same + /// cases. The source must be the canonical release URL byte for byte. private static func isLegacyDevelopment(_ model: [String: Any]) -> Bool { if model["status"] as? String == "disabled" { return true } guard let profile = model["installationProfile"] as? String, @@ -100,9 +106,7 @@ let artifact = model["payloadArtifact"] as? [String: Any], let fileName = artifact["fileName"] as? String, let source = artifact["sourceURL"] as? String, - let url = URL(string: source), - url.scheme == "https", url.host == "github.com", url.user == nil, - url.password == nil, url.query == nil, url.fragment == nil + isFileName(fileName) else { return false } let run = String(evidence.dropFirst("image-build-".count)) guard !run.isEmpty, run.first != "0", run.utf8.allSatisfy({ (48...57).contains($0) }) @@ -111,16 +115,28 @@ "fedora": "fedora-aurora", "arch": "alarm-aurora", "nixos": "nixos-aurora", "omarchy": "omarchy-aurora", ] - guard AuroraInstallationSelection.allProfileIDs.contains(profile), + guard + AuroraInstallationSelection.allProfileIDs.contains(where: { + $0.utf8.elementsEqual(profile.utf8) + }), let distribution = profile.split(separator: "-").first, let repository = repositories[String(distribution)] else { return false } - let parts = url.pathComponents let tag = "payload-\(profile)-\(run)" - return parts.count == 7 && parts[1] == "aurora-silicon" && parts[2] == repository - && parts[3] == "releases" && parts[4] == "download" - && [tag, tag + "-models58", tag + "-models65"].contains(parts[5]) - && parts[6] == fileName + return [tag, tag + "-models58", tag + "-models65"].contains { release in + source.utf8.elementsEqual( + "https://github.com/aurora-silicon/\(repository)/releases/download/\(release)/\(fileName)" + .utf8) + } + } + + /// ASCII letters and digits, then also `.`, `_`, `+` and `-`. + private static func isFileName(_ value: String) -> Bool { + let isAlphanumeric = { (byte: UInt8) in + (48...57).contains(byte) || (65...90).contains(byte) || (97...122).contains(byte) + } + guard let first = value.utf8.first, isAlphanumeric(first) else { return false } + return value.utf8.allSatisfy { isAlphanumeric($0) || [46, 95, 43, 45].contains($0) } } private struct Envelope: Decodable { diff --git a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json new file mode 100644 index 00000000..ab829466 --- /dev/null +++ b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json @@ -0,0 +1,594 @@ +{ + "comment": "Undeclared catalogs and whether the app reads them as Testing. Pins ReleaseCatalogChannelPolicy (Swift) and scripts/prepare-distribution-release.py (Python) to the same cases.", + "cases": [ + { + "name": "a delivery model", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": true + }, + { + "name": "an arch delivery from a models58 release", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "arch-gnome", + "evidenceRevision": "image-build-44886731192", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/alarm-aurora/releases/download/payload-arch-gnome-44886731192-models58/arch-gnome-build-44886731192.zip", + "fileName": "arch-gnome-build-44886731192.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": true + }, + { + "name": "a nixos delivery from a models65 release", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "nixos-minimal", + "evidenceRevision": "image-build-7", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/nixos-aurora/releases/download/payload-nixos-minimal-7-models65/nixos-minimal-build-7.zip", + "fileName": "nixos-minimal-build-7.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": true + }, + { + "name": "a delivery model beside a disabled one", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + }, + { + "deviceIdentifier": "apple,j274", + "status": "disabled" + } + ], + "acceptedAsTesting": true + }, + { + "name": "no models", + "models": [], + "acceptedAsTesting": false + }, + { + "name": "only disabled models", + "models": [ + { + "deviceIdentifier": "apple,j274", + "status": "disabled" + }, + { + "deviceIdentifier": "apple,j313", + "status": "disabled" + } + ], + "acceptedAsTesting": false + }, + { + "name": "a model without a status is not disabled", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": true + }, + { + "name": "an http source", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "http://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "another host", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://api.github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an explicit port", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com:443/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a user in the source", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://x@github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a query", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip?x=1", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a fragment", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip#x", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a percent-encoded file name", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41%2Ezip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a doubled slash", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download//payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an uppercase host", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://GitHub.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "another organisation", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon-fork/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "another distribution's repository", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/alarm-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a release of another run", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-42/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a release of another profile", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-gnome-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an unknown release suffix", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41-models99/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an extra path component", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/x/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a source naming another file", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/other.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a file name with a slash", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/x/fedora-kde-build-41.zip", + "fileName": "x/fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a dot-dot file name", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/..", + "fileName": "..", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an empty file name", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/", + "fileName": "", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a run with a leading zero", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-041", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-041/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a run that is not decimal", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-4a", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-4a/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "a run of non-ASCII digits", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-\u0664\u0661", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-\u0664\u0661/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an empty run", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "evidence of another kind", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "evidence-s4", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "an unknown profile", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-xfce", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-xfce-41/f.zip", + "fileName": "f.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "evidence that is not a string", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": 41, + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + }, + { + "name": "no payload artifact", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41" + } + ], + "acceptedAsTesting": false + }, + { + "name": "one delivery model and one foreign", + "models": [ + { + "deviceIdentifier": "apple,j314s", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://github.com/aurora-silicon/fedora-aurora/releases/download/payload-fedora-kde-41/fedora-kde-build-41.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + }, + { + "deviceIdentifier": "apple,j274", + "status": "enabled", + "installationProfile": "fedora-kde", + "evidenceRevision": "image-build-41", + "payloadArtifact": { + "sourceURL": "https://downloads.example.com/payload.zip", + "fileName": "fedora-kde-build-41.zip", + "sizeBytes": 1 + } + } + ], + "acceptedAsTesting": false + } + ] +} diff --git a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift index 96938307..6ca3ea0d 100644 --- a/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift +++ b/macOS/Tests/AuroraAppleInstallerTrustCoreTests/ReleaseChannelAvailabilityTests.swift @@ -412,6 +412,35 @@ XCTAssertEqual(accepted, .available) } + func testUndeclaredTestingCatalogsMatchTheReleasePreparationVectors() throws { + // scripts/tests/test_distribution_release.py runs the same vectors + // through prepare-distribution-release.py, so a bundled default that the + // release preparation accepts is one this policy accepts, and back. + let fixtures = try XCTUnwrap(Bundle.module.url(forResource: "Fixtures", withExtension: nil)) + let data = try Data( + contentsOf: fixtures.appendingPathComponent("legacy-testing-catalog-vectors.json")) + let vectors = try XCTUnwrap(JSONSerialization.jsonObject(with: data) as? [String: Any]) + let cases = try XCTUnwrap(vectors["cases"] as? [[String: Any]]) + XCTAssertFalse(cases.isEmpty) + for vector in cases { + let name = try XCTUnwrap(vector["name"] as? String) + let accepted = try XCTUnwrap(vector["acceptedAsTesting"] as? Bool) + let catalog: [String: Any] = [ + "schemaVersion": 5, "sequence": 1, "issuedAt": "2026-09-01T00:00:00Z", + "models": try XCTUnwrap(vector["models"] as? [Any]), + ] + let payload = try JSONSerialization.data(withJSONObject: catalog) + do { + try ReleaseCatalogChannelPolicy.validate(payload: payload, channel: .testing) + XCTAssertTrue(accepted, name) + } catch { + XCTAssertFalse(accepted, name) + XCTAssertEqual( + error as? InstallerReleaseConfigurationError, .invalidCatalogChannel, name) + } + } + } + func testEachChannelReportsItsOwnStateFromItsSignedCatalog() async throws { let configuration = try configuration() let coordinator = coordinator(serving: [ diff --git a/macOS/scripts/prepare-distribution-release.py b/macOS/scripts/prepare-distribution-release.py index 4b51572c..c588c055 100644 --- a/macOS/scripts/prepare-distribution-release.py +++ b/macOS/scripts/prepare-distribution-release.py @@ -14,6 +14,58 @@ PROFILES = tuple(f"{distribution}-{desktop}" for distribution in ("fedora", "arch", "nixos") for desktop in ("kde", "gnome", "minimal")) OMARCHY_PROFILE = "omarchy-hyprland" +# The development delivery lineage the app reads as Testing when a catalog +# declares no channel. This is ReleaseCatalogChannelPolicy.isLegacyDevelopment +# and the undeclared Testing rule in validate(); both are pinned to the same +# cases by Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/ +# legacy-testing-catalog-vectors.json. +LEGACY_REPOSITORIES = {"fedora": "fedora-aurora", "arch": "alarm-aurora", + "nixos": "nixos-aurora", "omarchy": "omarchy-aurora"} +LEGACY_EVIDENCE_PREFIX = "image-build-" + + +def is_legacy_development(model, profiles): + if model.get("status") == "disabled": + return True + profile = model.get("installationProfile") + evidence = model.get("evidenceRevision") + artifact = model.get("payloadArtifact") + if not (isinstance(profile, str) and isinstance(evidence, str) + and evidence.startswith(LEGACY_EVIDENCE_PREFIX) and isinstance(artifact, dict)): + return False + file_name = artifact.get("fileName") + source = artifact.get("sourceURL") + if not (isinstance(file_name, str) and isinstance(source, str) + and re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._+-]*", file_name)): + return False + run = evidence[len(LEGACY_EVIDENCE_PREFIX):] + if not re.fullmatch(r"[1-9][0-9]*", run) or profile not in profiles: + return False + repository = LEGACY_REPOSITORIES.get(profile.split("-")[0]) + if repository is None: + return False + tag = f"payload-{profile}-{run}" + return source in {f"https://github.com/aurora-silicon/{repository}/releases/download/{name}/{file_name}" + for name in (tag, tag + "-models58", tag + "-models65")} + + +def is_legacy_testing_catalog(catalog, profiles): + """An undeclared catalog the app reads as Testing: it lists at least one + Mac that is not disabled, and every model is of the delivery lineage.""" + models = catalog.get("models") if isinstance(catalog, dict) else None + return (isinstance(models, list) and all(isinstance(model, dict) for model in models) + and any(model.get("status") != "disabled" for model in models) + and all(is_legacy_development(model, profiles) for model in models)) + + +def check_bundled_default(catalog, default_channel, profiles, name): + """The bundled catalog replaces the fetch for the default channel, so it + must pass the channel policy the app applies to that channel.""" + if "channel" in catalog: + if not isinstance(catalog["channel"], str) or catalog["channel"] != default_channel: + raise ValueError(f"the bundled default catalog must declare {default_channel}: {name}") + elif default_channel != "testing" or not is_legacy_testing_catalog(catalog, profiles): + raise ValueError(f"an undeclared bundled catalog must be a Testing development delivery: {name}") def prepare(source, output, sealed=False, signing_team=None): @@ -69,10 +121,6 @@ def prepare(source, output, sealed=False, signing_team=None): for model in catalog["models"] ): raise ValueError(f"native-only catalog includes an execution archive: {profile}") - # Published development deliveries predate the channel field, so an - # undeclared one is still read as Testing, as the app reads it. - if catalog.get("channel") not in (None, "testing"): - raise ValueError("the bundled default must be a testing delivery") schema_versions.add(catalog["schemaVersion"]) descriptor = json.loads(data["release.json"]) expected = "sha256:" + hashlib.sha256(trusted).hexdigest() @@ -116,6 +164,13 @@ def release_descriptor(content): return (json.dumps(descriptor, indent=2) + "\n").encode() descriptors = {profile: release_descriptor(data["release.json"]) for profile, data in documents.items()} root_descriptor = release_descriptor((ROOT / "Release/release.json").read_bytes()) + # Published development deliveries predate the channel field; an undeclared + # one is accepted only where the app reads it as Testing. + for profile, data in documents.items(): + check_bundled_default(json.loads(data["catalog.json"]), + json.loads(descriptors[profile]).get("default_channel"), set(profiles), profile) + check_bundled_default(json.loads(documents["fedora-kde"]["catalog.json"]), + json.loads(root_descriptor).get("default_channel"), set(profiles), "release.json") # Nothing is emitted until every requested profile has verified. output.mkdir(parents=True) for profile, data in documents.items(): diff --git a/macOS/scripts/tests/test_distribution_release.py b/macOS/scripts/tests/test_distribution_release.py index 21e1ac5b..5d072659 100644 --- a/macOS/scripts/tests/test_distribution_release.py +++ b/macOS/scripts/tests/test_distribution_release.py @@ -13,6 +13,39 @@ spec.loader.exec_module(module) +VECTORS = (Path(__file__).resolve().parents[2] + / "Tests/AuroraAppleInstallerTrustCoreTests/Fixtures/legacy-testing-catalog-vectors.json") + + +def delivery_model(profile, run="41"): + """A model of the published development delivery lineage.""" + repository = {"fedora": "fedora-aurora", "arch": "alarm-aurora", "nixos": "nixos-aurora", + "omarchy": "omarchy-aurora"}[profile.split("-")[0]] + name = f"{profile}-build-{run}.zip" + return {"status": "enabled", "installationProfile": profile, "evidenceRevision": f"image-build-{run}", + "payloadArtifact": {"sourceURL": f"https://github.com/aurora-silicon/{repository}/releases/download/" + f"payload-{profile}-{run}/{name}", + "fileName": name, "sizeBytes": 1}} + + +class LegacyTestingVectorTests(unittest.TestCase): + def test_undeclared_testing_vectors_match_the_app(self): + # ReleaseChannelAvailabilityTests runs the same vectors through + # ReleaseCatalogChannelPolicy.validate, so both accept the same catalogs. + cases = json.loads(VECTORS.read_text())["cases"] + self.assertTrue(cases) + for case in cases: + with self.subTest(case=case["name"]): + catalog = {"schemaVersion": 5, "sequence": 1, "models": case["models"]} + self.assertEqual(module.is_legacy_testing_catalog(catalog, set(module.PROFILES)), + case["acceptedAsTesting"]) + if case["acceptedAsTesting"]: + module.check_bundled_default(catalog, "testing", set(module.PROFILES), "vector") + else: + with self.assertRaises(ValueError): + module.check_bundled_default(catalog, "testing", set(module.PROFILES), "vector") + + class DistributionReleaseTests(unittest.TestCase): def setUp(self): mode = patch.dict(os.environ, {"AURORA_ENABLE_OMARCHY": "0"}) @@ -38,7 +71,7 @@ def setUp(self): for profile in module.PROFILES + (module.OMARCHY_PROFILE,): directory = self.profiles / profile directory.mkdir(parents=True) - descriptor = {"schema_version": 3, "trust_root_fingerprint": fingerprint, + descriptor = {"schema_version": 3, "default_channel": "testing", "trust_root_fingerprint": fingerprint, "helper_mach_service_name": "invalid.example.installer.helper", "helper_code_signing_requirement": 'identifier "invalid.example.installer.helper"', "channels": {channel: {"catalog_url": "https://delivery.invalid/native/Profiles/" @@ -47,7 +80,7 @@ def setUp(self): (directory / "release.json").write_text(json.dumps(descriptor)) (directory / "trust-root.ed25519.pub").write_bytes(self.public) (directory / "catalog.json").write_text(json.dumps({"schemaVersion": 5, "sequence": 1, - "models": [{"status": "enabled", "installationProfile": profile}]})) + "models": [delivery_model(profile)]})) self.sign(directory) (release / "release.json").write_text(json.dumps(descriptor)) @@ -102,6 +135,56 @@ def test_a_delivery_signed_for_another_channel_emits_no_release(self): module.prepare(self.profiles, output, sealed=True) self.assertFalse(output.exists()) + def rewrite(self, profile, edit): + directory = self.profiles / profile + catalog = json.loads((directory / "catalog.json").read_text()) + edit(catalog) + (directory / "catalog.json").write_text(json.dumps(catalog)) + self.sign(directory) + + def set_default(self, channel): + for path in [self.root / "Release/release.json"] + [self.profiles / p / "release.json" + for p in module.PROFILES]: + descriptor = json.loads(path.read_text()) + descriptor["default_channel"] = channel + path.write_text(json.dumps(descriptor)) + + def assert_refused_undeclared(self, profile, edit): + self.rewrite(profile, edit) + output = self.root / "output" + with patch.object(module, "ROOT", self.root), self.assertRaisesRegex( + ValueError, f"undeclared bundled catalog must be a Testing development delivery: {profile}"): + module.prepare(self.profiles, output, sealed=True) + self.assertFalse(output.exists()) + + def test_an_undeclared_bundled_default_must_be_of_the_delivery_lineage(self): + # The app reads an undeclared catalog as Testing only when every model + # is of the published development delivery lineage. + def foreign(catalog): + catalog["models"][0]["payloadArtifact"]["sourceURL"] = "https://downloads.example.com/payload.zip" + self.assert_refused_undeclared("nixos-gnome", foreign) + + def test_an_undeclared_bundled_default_of_only_disabled_macs_is_refused(self): + def disabled(catalog): + catalog["models"] = [{"deviceIdentifier": "apple,j274", "status": "disabled"}] + self.assert_refused_undeclared("arch-kde", disabled) + + def test_the_bundled_default_must_be_the_default_channel(self): + self.set_default("stable") + output = self.root / "output" + with patch.object(module, "ROOT", self.root), self.assertRaisesRegex( + ValueError, "undeclared bundled catalog"): + module.prepare(self.profiles, output, sealed=True) + self.declare("testing") + with patch.object(module, "ROOT", self.root), self.assertRaisesRegex( + ValueError, "must declare stable"): + module.prepare(self.profiles, output, sealed=True) + self.assertFalse(output.exists()) + self.declare("stable") + with patch.object(module, "ROOT", self.root): + module.prepare(self.profiles, output, sealed=True) + self.assertEqual(json.loads((output / "catalog.json").read_text())["channel"], "stable") + def test_default_accepts_nine_profiles_and_opt_in_requires_omarchy(self): import shutil shutil.rmtree(self.profiles / module.OMARCHY_PROFILE) From a3a640200f1b500876eece19145853895179fbbd Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 14:29:58 +1100 Subject: [PATCH 6/7] publish-m1-release: check each per-channel catalog's channel before upload publish-r2 uploaded catalog..signed.json to the immutable releases// keys without reading it. os-promote refuses a catalog that declares the wrong channel, but by then the key cannot be replaced for that tag. Each per-channel envelope is now decoded and its signed catalog must declare the channel in its file name; otherwise nothing is uploaded. The reader, catalog_declared_channel, is shared with publish-channels os-promote, which sources this script, in place of its inline copy. Signed-off-by: Ryan Murray --- macOS/scripts/publish-channels | 13 +- macOS/scripts/publish-m1-release | 44 +++++- ...apple-installer-r2-catalog-channel-test.sh | 147 ++++++++++++++++++ 3 files changed, 191 insertions(+), 13 deletions(-) create mode 100755 macOS/test/shell.d/apple-installer-r2-catalog-channel-test.sh diff --git a/macOS/scripts/publish-channels b/macOS/scripts/publish-channels index 9e77e77c..da7d2687 100755 --- a/macOS/scripts/publish-channels +++ b/macOS/scripts/publish-channels @@ -371,17 +371,8 @@ os_promote() { decode_envelope "$work/candidate.json" "$work/catalog" "$work/signature" verify_catalog "$work/catalog" "$work/signature" local declared_channel - declared_channel=$(python3 - "$work/catalog" <<'PYCHANNEL' -import json, sys -catalog = json.load(open(sys.argv[1])) -if not isinstance(catalog, dict): - raise SystemExit("catalog is not an object") -declared = catalog.get("channel") -if declared is not None and not (isinstance(declared, str) and declared): - raise SystemExit("catalog channel is not a name") -print(declared or "") -PYCHANNEL -) || die "catalog does not declare a readable channel" + declared_channel=$(catalog_declared_channel "$work/catalog") || + die "catalog does not declare a readable channel" # The signature must name the channel: an undeclared catalog would verify on # every channel, so it is not promoted to any. [[ -n $declared_channel ]] || diff --git a/macOS/scripts/publish-m1-release b/macOS/scripts/publish-m1-release index 482bbe46..20f9d7e6 100755 --- a/macOS/scripts/publish-m1-release +++ b/macOS/scripts/publish-m1-release @@ -38,8 +38,10 @@ PREFIX (default STREAM/releases/TAG, STREAM being INSTALLER_STREAM_PATH, where publish-channels promotes from) using the aws CLI. Credentials come from AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or the macOS Keychain items omarchy-r2-access-key-id / omarchy-r2-secret-access-key. Existing objects -are never replaced: a size mismatch is a hard error. After upload every -asset is downloaded back from --base-url and checked against SHA256SUMS. +are never replaced: a size mismatch is a hard error. A per-channel +catalog.CHANNEL.signed.json in --catalog-dir must declare CHANNEL in its +signed catalog, or nothing is uploaded. After upload every asset is +downloaded back from --base-url and checked against SHA256SUMS. EOF exit 1 } @@ -61,6 +63,35 @@ file_digest() { shasum -a 256 "$1" | cut -d ' ' -f 1 } +# Prints the channel a signed catalog declares, or nothing when it declares +# none; fails when the field is there but is not a channel name. With +# "envelope" the file is a catalog envelope and the catalog it carries, the +# bytes its signature covers, is read. publish-channels sources this too. +catalog_declared_channel() { + local file=$1 form=${2:-catalog} + python3 - "$file" "$form" <<'PY' +import base64 +import json +import sys + +path, form = sys.argv[1:3] +document = json.load(open(path, encoding="utf-8")) +if form == "envelope": + if (not isinstance(document, dict) + or set(document) != {"schema_version", "catalog", "signature"} + or document["schema_version"] != 1 + or not isinstance(document["catalog"], str)): + raise SystemExit("not a catalog envelope") + document = json.loads(base64.b64decode(document["catalog"], validate=True)) +if not isinstance(document, dict): + raise SystemExit("catalog is not an object") +declared = document.get("channel") +if declared is not None and not (isinstance(declared, str) and declared): + raise SystemExit("catalog channel is not a name") +print(declared or "") +PY +} + validate_tag() { # OS release tags carry an os- prefix so they never collide with the Linux # lane's vX.Y.Z-mac.N tags or with the installer's own installer-vX.Y.Z line. @@ -439,10 +470,19 @@ publish_r2_release() { done # A set bound for more than one channel also carries one signed catalog # per channel, which publish-channels os-promote reads for that channel. + # The keys are immutable, so each must declare the channel in its name + # before it is uploaded: a mislabelled one could never be replaced. + local named_channel declared_channel for catalog_asset in catalog.stable.signed.json catalog.rc.signed.json \ catalog.testing.signed.json catalog.edge.signed.json; do [[ -e $catalog_dir/$catalog_asset ]] || continue require_file "$catalog_dir/$catalog_asset" + named_channel=${catalog_asset#catalog.} + named_channel=${named_channel%.signed.json} + declared_channel=$(catalog_declared_channel "$catalog_dir/$catalog_asset" envelope) || + die "$catalog_asset is not a readable catalog envelope" + [[ $declared_channel == "$named_channel" ]] || + die "$catalog_asset declares ${declared_channel:-no channel}; it must be signed with \"channel\": \"$named_channel\"" catalog_assets="$catalog_assets $catalog_asset" done catalog_assets=${catalog_assets# } diff --git a/macOS/test/shell.d/apple-installer-r2-catalog-channel-test.sh b/macOS/test/shell.d/apple-installer-r2-catalog-channel-test.sh new file mode 100755 index 00000000..13be8177 --- /dev/null +++ b/macOS/test/shell.d/apple-installer-r2-catalog-channel-test.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +source "$(dirname -- "${BASH_SOURCE[0]}")/base-test.sh" + +require_command python3 + +PUBLISHER="$ROOT/scripts/publish-m1-release" +[[ -f $PUBLISHER ]] || fail "publish-m1-release exists" + +WORK=$(mktemp -d) +trap 'rm -rf "$WORK"' EXIT + +BUCKET_DIR="$WORK/bucket" +BIN_DIR="$WORK/bin" +CALLS="$WORK/calls.log" +mkdir -p "$BUCKET_DIR" "$BIN_DIR" +: >"$CALLS" + +# The tag is pushed; nothing else reaches git. +cat >"$BIN_DIR/git" <<'SHIM' +#!/bin/bash +printf 'git %s\n' "$*" >>"$CALLS" +[[ $1 == "ls-remote" ]] && exit 0 +exit 64 +SHIM + +# A bucket-backed aws shim: object keys become paths under the bucket. +cat >"$BIN_DIR/aws" <<'SHIM' +#!/bin/bash +printf 'aws %s\n' "$*" >>"$CALLS" +if [[ $1 == "s3api" && $2 == "head-object" ]]; then + key="" + while (( $# > 0 )); do + [[ $1 == "--key" ]] && key=$2 + shift + done + [[ -f $BUCKET_DIR/$key ]] || exit 254 + wc -c <"$BUCKET_DIR/$key" | tr -d ' ' + exit 0 +fi +if [[ $1 == "s3" && $2 == "cp" ]]; then + key=${4#s3://*/} + mkdir -p "$BUCKET_DIR/$(dirname "$key")" + cp "$3" "$BUCKET_DIR/$key" + exit 0 +fi +exit 64 +SHIM + +# The public base serves the bucket's prefix, so read-back verification runs. +cat >"$BIN_DIR/curl" <<'SHIM' +#!/bin/bash +printf 'curl %s\n' "$*" >>"$CALLS" +url="" +for argument in "$@"; do + [[ $argument == http* ]] && url=$argument +done +file=$BUCKET_DIR/$PREFIX/${url#"$BASE_URL"/} +[[ -f $file ]] || exit 22 +cat "$file" +SHIM + +if ! command -v shasum >/dev/null; then + cat >"$BIN_DIR/shasum" <<'SHIM' +#!/bin/bash +file="-" +while (( $# > 0 )); do + case $1 in + -a) shift 2 ;; + *) file=$1; shift ;; + esac +done +sha256sum "$file" +SHIM +fi +chmod +x "$BIN_DIR"/* + +TAG=os-v4.0.2-mac.1.20260920 +BASE_URL=https://downloads.example.test/native/releases/$TAG +PREFIX=native/releases/$TAG +export PATH="$BIN_DIR:$PATH" BUCKET_DIR CALLS BASE_URL PREFIX +export AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test + +RELEASE="$WORK/release" +CATALOGS="$WORK/catalogs" +mkdir -p "$RELEASE" "$CATALOGS" +head -c 128 /dev/zero >"$RELEASE/payload.zip" +(cd "$RELEASE" && shasum -a 256 payload.zip >SHA256SUMS) +printf 'TAG=%s\nBASE_URL=%s\nRELEASE_ASSETS="payload.zip"\n' "$TAG" "$BASE_URL" >"$RELEASE/release-urls.env" + +# envelope FILE [CHANNEL]: a catalog envelope whose catalog declares CHANNEL, +# or no channel when CHANNEL is empty. The signature is not checked here. +envelope() { + python3 - "$1" "${2:-}" <<'PY' +import base64, json, sys +output, channel = sys.argv[1:3] +catalog = {"schemaVersion": 5, "sequence": 1, "issuedAt": "2026-09-20T00:00:00Z", "models": []} +if channel: + catalog["channel"] = channel +json.dump({"schema_version": 1, + "catalog": base64.b64encode(json.dumps(catalog).encode()).decode(), + "signature": base64.b64encode(b"\0" * 64).decode()}, open(output, "w")) +PY +} +printf '{}' >"$CATALOGS/catalog.json" +head -c 64 /dev/zero >"$CATALOGS/catalog.json.sig" +envelope "$CATALOGS/catalog.signed.json" testing + +publish() { + AURORA_PUBLISH_ASSUME_YES=$TAG "$PUBLISHER" publish-r2 --dir "$RELEASE" --tag "$TAG" \ + --bucket test-bucket --endpoint https://example.r2.cloudflarestorage.com \ + --base-url "$BASE_URL" --prefix "$PREFIX" --catalog-dir "$CATALOGS" +} + +# --- a per-channel catalog that declares another channel, or none, is not uploaded +for declared in rc "" testing; do + rm -f "$CATALOGS"/catalog.*.signed.json + envelope "$CATALOGS/catalog.stable.signed.json" "$declared" + envelope "$CATALOGS/catalog.rc.signed.json" rc + if publish >"$WORK/mislabelled.log" 2>&1; then + fail "catalog.stable.signed.json declaring '${declared:-nothing}' is refused" + fi + grep -q "catalog.stable.signed.json declares ${declared:-no channel}; it must be signed with \"channel\": \"stable\"" \ + "$WORK/mislabelled.log" || fail "the refusal names the declared channel" "$(cat "$WORK/mislabelled.log")" + grep -q '^aws s3 cp ' "$CALLS" && fail "nothing is uploaded before every catalog is checked" "$(cat "$CALLS")" + [[ -z $(find "$BUCKET_DIR" -type f) ]] || fail "the bucket is untouched" +done +pass "a per-channel catalog that declares another channel or none uploads nothing" + +printf 'not an envelope' >"$CATALOGS/catalog.stable.signed.json" +if publish >"$WORK/unreadable.log" 2>&1; then + fail "an unreadable per-channel catalog is refused" +fi +grep -q "catalog.stable.signed.json is not a readable catalog envelope" "$WORK/unreadable.log" || + fail "the refusal names the unreadable catalog" "$(cat "$WORK/unreadable.log")" +grep -q '^aws s3 cp ' "$CALLS" && fail "an unreadable catalog uploads nothing" +pass "an unreadable per-channel catalog uploads nothing" + +# --- catalogs that declare their own channels are uploaded and read back ----- +envelope "$CATALOGS/catalog.stable.signed.json" stable +publish >"$WORK/publish.log" 2>&1 || fail "a correctly labelled set publishes" "$(cat "$WORK/publish.log")" +for asset in payload.zip catalog.json catalog.json.sig catalog.signed.json \ + catalog.stable.signed.json catalog.rc.signed.json; do + [[ -f $BUCKET_DIR/$PREFIX/$asset ]] || fail "$asset is uploaded" "$(cat "$WORK/publish.log")" + grep -q "verified $BASE_URL/$asset" "$WORK/publish.log" || fail "$asset is read back" +done +pass "per-channel catalogs that declare their own channel are uploaded and verified" From 11a0ef8f2166a4d45e7518d1f7930927e77d1b27 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 14:30:26 +1100 Subject: [PATCH 7/7] PlainLanguage: show a catalog for the wrong channel as a verification failure invalidCatalogChannel, which now covers undeclared Stable and RC catalogs and another channel's catalog on Edge, fell through to the generic "The release is unavailable" text. It is a verification failure, so it now reads "The release couldn't be verified", as a bad envelope or signature does. Signed-off-by: Ryan Murray --- .../AuroraInstallerUXCore/PlainLanguage.swift | 2 +- .../PlainLanguageTests.swift | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/macOS/Sources/AuroraInstallerUXCore/PlainLanguage.swift b/macOS/Sources/AuroraInstallerUXCore/PlainLanguage.swift index d1cf3c13..faa90208 100644 --- a/macOS/Sources/AuroraInstallerUXCore/PlainLanguage.swift +++ b/macOS/Sources/AuroraInstallerUXCore/PlainLanguage.swift @@ -1209,7 +1209,7 @@ "Check your internet connection and try again, or choose another channel from the Release channel menu." ) case .invalidCatalogEnvelope, .invalidCatalogSignature, - .oversizedDocument: + .invalidCatalogChannel, .oversizedDocument: return FailureDisplay( headline: "The release couldn’t be verified", plainDetail: diff --git a/macOS/Tests/AuroraInstallerUXCoreTests/PlainLanguageTests.swift b/macOS/Tests/AuroraInstallerUXCoreTests/PlainLanguageTests.swift index 5aec40a9..501dea77 100644 --- a/macOS/Tests/AuroraInstallerUXCoreTests/PlainLanguageTests.swift +++ b/macOS/Tests/AuroraInstallerUXCoreTests/PlainLanguageTests.swift @@ -812,6 +812,20 @@ XCTAssertEqual(failure.headline, "The release couldn’t be verified") } + func testACatalogForAnotherChannelIsAVerificationFailure() { + // A catalog that doesn't declare the channel it was served on, or + // declares another one, failed verification like a bad signature. + let failure = PlainLanguage.failure( + for: InstallerReleaseConfigurationError.invalidCatalogChannel + ) + + XCTAssertEqual(failure.headline, "The release couldn’t be verified") + XCTAssertEqual( + failure.plainDetail, + PlainLanguage.failure(for: InstallerReleaseConfigurationError.invalidCatalogSignature) + .plainDetail) + } + func testRetryEligibleFailureIsFlaggedAndExplained() { let failure = PlainLanguage.failure( for: EngineXPCSubmissionError.recoveryAuthorizationFailed,