Files
gstack/scripts/ubicloud/setup-free-suite.sh
Garry Tanandcapy-ai[bot] 4c6fa89cdc v1.91.159.0 security: gstack's Bun entry points ignore the audited repo's .env and bunfig.toml (S1) (#3312)
* security: isolate every gstack Bun entry point from the audited checkout's .env and bunfig.toml

Bun auto-loads .env, .env.local and .env.<NODE_ENV> from its cwd and runs a
cwd bunfig.toml preload before the program starts. gstack runs inside the repo
it audits, so a committed .env could steer state roots, the claude binary or
spend caps, and a bunfig preload ran arbitrary code in every bin and hook.

Every bun shebang, shell and skill caller, TypeScript spawn and compiled build
now disables both (--no-env-file --config=/dev/null, bunIsolationArgs(),
--no-compile-autoload-dotenv/bunfig), with a ratchet and hostile-fixture
regressions.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: name the directly executed scripts in the isolation ratchet

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: follow the isolation flags in touchfiles, copy lists, recipe assertions and the harness pin

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: keep browse/src/bun-child-config.ts unchanged so the native cookie qualification still binds

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(windows): the empty bunfig outlives its process so the timeline hook's detached repair child can read it

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* v1.91.159.0 security: gstack's Bun entry points ignore the audited repo's .env and bunfig.toml (S1)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: plan-mode render pattern accepts the isolation flags

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-10-20 00:24:28 +00:00

59 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Bootstrap a fresh ubuntu-noble Ubicloud VM to run the free suite exactly as
# the required CI lane does (.github/workflows/free-tests.yml, free-suite job).
# Runs as user `ubi` (passwordless sudo) from the synced checkout.
set -euo pipefail
BUN_VERSION=1.4.2
NODE_VERSION=22.20.0
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get update -qq
sudo -E apt-get install -y -qq --no-install-recommends \
git curl unzip zip xz-utils ca-certificates build-essential clang python3-venv jq \
xvfb x11-utils poppler-utils fonts-noto-color-emoji zsh >/dev/null
# Ubuntu 24.04 blocks unprivileged user namespaces, which Chromium's sandbox
# needs; GitHub-hosted runners ship with this relaxed.
sudo sysctl -qw kernel.apparmor_restrict_unprivileged_userns=0
if ! command -v node >/dev/null; then
curl -fsSL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
| sudo tar -xJ -C /usr/local --strip-components=1
fi
# The exact release archive, verified by SHA-256 before it is unpacked, as in
# .github/docker/Dockerfile.ci (test/ci-image-cli-pin.test.ts keeps them equal).
if [ ! -x "$HOME/.bun/bin/bun" ]; then
bun_tmp=$(mktemp -d)
curl --retry 5 --retry-delay 5 --retry-connrefused -fsSL \
"https://github.com/oven-sh/bun/releases/download/bun-v$BUN_VERSION/bun-linux-x64.zip" -o "$bun_tmp/bun.zip"
echo "36368faef7527875d5ffa52e53cd48021741f2a83eb6208a8dd64068d422a913 $bun_tmp/bun.zip" | sha256sum -c - >/dev/null
unzip -q "$bun_tmp/bun.zip" -d "$bun_tmp"
install -D -m 0755 "$bun_tmp/bun-linux-x64/bun" "$HOME/.bun/bin/bun"
ln -sf bun "$HOME/.bun/bin/bunx"
rm -rf "$bun_tmp"
fi
grep -q '.bun/bin' "$HOME/.profile" || echo 'export PATH="$HOME/.bun/bin:$PATH"' >>"$HOME/.profile"
export PATH="$HOME/.bun/bin:$PATH"
test "$(bun --version)" = "$BUN_VERSION"
git config --global user.email "free-tests@gstack.test"
git config --global user.name "Free Tests"
git config --global init.defaultBranch main
git config --global --add safe.directory '*'
bun install --frozen-lockfile
bunx playwright install --with-deps chromium
chrome=$(bun --no-env-file --config=/dev/null -e 'import { chromium } from "playwright"; import { realpathSync } from "node:fs"; console.log(realpathSync(chromium.executablePath()))')
sudo install -T -o root -g root -m 4755 "${chrome%/*}/chrome_sandbox" "${chrome%/*}/chrome-sandbox"
{
bun run gen:skill-docs --host all
bun run vendor:xterm
bash browse/scripts/build-node-server.sh
bun run build:gates
bun run build:cso
} >/dev/null