sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

helper-rule.sh (1186B)


      1 #!/usr/bin/env bash
      2 # The root helper (patina-update) checks image names with a regex; the app checks them in Rust
      3 # (valid_image in src/backend.rs). They must agree, since the app's check is a convenience and the
      4 # helper's is the one that protects the system. This feeds the helper's function the names the
      5 # Rust tests use. Usage: helper-rule.sh <path to patina-update>
      6 set -uo pipefail
      7 PATINA_UPDATE_SOURCE=1 source "$1"
      8 ok=(
      9   ghcr.io/sector-f-labs/sector-f-linux:latest
     10   ghcr.io/sector-f-labs/sector-f-linux
     11   registry.example.org:5000/team/os:2026-11
     12   localhost:5000/os@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
     13 )
     14 bad=(
     15   "" nohost "ghcr.io/" "ghcr.io/Org/Name" "ghcr.io/org/name:" "ghcr.io/org/name:ta g"
     16   "ghcr.io/org/name;rm -rf /" "--help/x" "ghcr.io/org/../name" "ghcr.io/org/name@sha256:abc"
     17   "ostree-unverified-registry:ghcr.io/org/name" $'ghcr.io/org/name\nx'
     18 )
     19 fail=0
     20 for i in "${ok[@]}"; do valid_image "$i" || { echo "helper wrongly refuses: $i"; fail=1; }; done
     21 for i in "${bad[@]}"; do valid_image "$i" && { echo "helper wrongly accepts: $i"; fail=1; }; done
     22 [[ $fail -eq 0 ]] && echo "helper rule agrees with the app's"
     23 exit $fail