1 #!/usr/bin/env bash2 # Fail closed on any tracked or untracked path that is not part of the public3 # projection. Private paths are the operator-owned surface; the allowlist is4 # everything else. A new bundle, deploy file, or config is refused until it is5 # either made public deliberately or added to the private policy.6 set -euo pipefail7 8 root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)9 mode=${1:-check}10 case $mode in11 check|--list) ;;12 *)13 printf 'usage: %s [check|--list]\n' "$0" >&214 exit 215 ;;16 esac17 18 private() {19 case $1 in20 .f0rge/publish.yaml|\21 .f0rge/issues/*|.f0rge/prs/*|.f0rge/merges/*|.f0rge/tasks/*|\22 .f0rge/ci/runs/*|.f0rge/releases/out/*|vendor/*|\23 .stignore)24 return 025 ;;26 esac27 return 128 }29 30 allowed() {31 case $1 in32 .cargo/*|Cargo.toml|Cargo.lock|rust-toolchain.toml|.gitignore|.dockerignore|\33 README.md|LICENSE|NOTICE|install.sh|deploy.toml|\34 crates/*|spec/*|goldens/*|\35 .f0rge/ci/*|.f0rge/wiki/*|.f0rge/keys/*|.f0rge/labels.md|\36 .f0rge/milestones.md|.f0rge/releases/*.md|\37 docker/Dockerfile|docker/Containerfile|docker/Containerfile.release|\38 docker/README.md|docker/compose.yaml|docker/control.lock|docker/release.lock|\39 docker/entrypoint.sh|docker/manifests/*|\40 docker/config/deploy.toml|docker/config/gate.toml|docker/config/release.toml|\41 ops/*|scripts/*|docs/*|security/*|functions/*|\42 deploy/cloudflare-*|hu13.json|wrangler.toml|SOURCE|\43 plugins/.gitkeep|plugins/mock/*|plugins/echo/*|plugins/toy/*|plugins/fixtures/*)44 return 045 ;;46 esac47 return 148 }49 50 cd "$root"51 # Include untracked files so a newly added operator bundle fails immediately,52 # before it can be committed. Ignored build output is not part of the tree.53 while IFS= read -r -d '' path; do54 path=${path#./}55 private "$path" && continue56 if ! allowed "$path"; then57 printf 'public-tree: not allowed: %s\n' "$path" >&258 exit 159 fi60 [ "$mode" = "--list" ] && printf '%s\n' "$path"61 done < <(git ls-files -z --cached --others --exclude-standard | sort -zu)62 63 [ "$mode" = "--list" ] || printf 'public-tree: ok\n'