| 1 | #!/usr/bin/env bash |
| 2 | # The manual Desktop exception removes Windows Authenticode only. It must never |
| 3 | # also buy an unapproved tag, a different candidate, or a skipped candidate |
| 4 | # validation, so every rule is asserted against the one owning script. |
| 5 | set -euo pipefail |
| 6 | |
| 7 | repo_root="$(git rev-parse --show-toplevel)" |
| 8 | owner="$repo_root/scripts/manual-desktop-exception.sh" |
| 9 | |
| 10 | accepts() { |
| 11 | if ! bash "$owner" validate "$@" 2>/dev/null; then |
| 12 | echo "manual Desktop exception rejected an approved input: $*" >&2 |
| 13 | exit 1 |
| 14 | fi |
| 15 | } |
| 16 | |
| 17 | rejects() { |
| 18 | if bash "$owner" validate "$@" 2>/dev/null; then |
| 19 | echo "manual Desktop exception accepted a forbidden input: $*" >&2 |
| 20 | exit 1 |
| 21 | fi |
| 22 | } |
| 23 | |
| 24 | # Only listed tags carry the exception. |
| 25 | rejects |
| 26 | rejects "" |
| 27 | rejects desktop-v1.39.0 "" false |
| 28 | rejects v1.38.9 "" false |
| 29 | rejects desktop-v1.38.10 "" false |
| 30 | |
| 31 | # Every published row stays bound to its own immutable candidate, and further |
| 32 | # runs against it are recoveries rather than fresh releases. |
| 33 | while read -r tag sha; do |
| 34 | accepts "$tag" "$sha" true |
| 35 | accepts "$tag" |
| 36 | rejects "$tag" "$sha" false |
| 37 | rejects "$tag" 0000000000000000000000000000000000000000 true |
| 38 | done <<'ROWS' |
| 39 | desktop-v1.38.8 7278072720a2dc7a31cce0eec18c1eacc149c0e0 |
| 40 | desktop-v1.38.9 dc915ab97bfdeb5d0e414916c0f58708dca80051 |
| 41 | ROWS |
| 42 | |
| 43 | # A row approved before its candidate exists carries no SHA. It must keep the |
| 44 | # normal candidate and push-CI validation, which release-stable.yml runs only |
| 45 | # when allow_recovery is false; trading that away would make the signing |
| 46 | # exception a release bypass. Exercise that path with an injected row so it |
| 47 | # stays covered once every real row has been published and pinned. |
| 48 | # shellcheck source=/dev/null |
| 49 | . "$owner" |
| 50 | manual_desktop_exception_sha() { |
| 51 | case "$1" in |
| 52 | desktop-v9.9.9) printf '' ;; |
| 53 | *) return 1 ;; |
| 54 | esac |
| 55 | } |
| 56 | manual_desktop_exception_validate desktop-v9.9.9 any-candidate-sha false || |
| 57 | { echo "unpinned row rejected under allow_recovery=false" >&2; exit 1; } |
| 58 | manual_desktop_exception_validate desktop-v9.9.9 || |
| 59 | { echo "unpinned row rejected without optional arguments" >&2; exit 1; } |
| 60 | if manual_desktop_exception_validate desktop-v9.9.9 any-candidate-sha true 2>/dev/null; then |
| 61 | echo "unpinned row accepted allow_recovery=true, which skips candidate validation" >&2 |
| 62 | exit 1 |
| 63 | fi |
| 64 | if manual_desktop_exception_validate desktop-v1.38.8 "" false 2>/dev/null; then |
| 65 | echo "injected allowlist did not replace the real rows" >&2 |
| 66 | exit 1 |
| 67 | fi |
| 68 | |
| 69 | echo "manual Desktop exception contract ok" |
| 70 |