From d789a43caebc94c1f46ca8bf5593bd9fe9ab9e22 Mon Sep 17 00:00:00 2001 From: fargo Date: Mon, 17 Aug 2026 15:19:04 -0500 Subject: [PATCH] test(git): hermetic fixtures for issue-create harnesses (#1282-#1287) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-issue-create-body-safety.sh and test-issue-create-interactive-auth.sh inherited the seat's real HOME and global git config. With the #1280 fix activating identity mode BEFORE the tea path, a workstation-global mosaic.gitIdentity resolved inside the fixture repo, and the wrapper's API fallback posted to the LIVE forge with a real per-slot token — six real issues (#1282-#1287, authored mos-dt-0, closed with provenance by fred within the hour). Neutralize the source the resolver actually reads, and prove it by making the resolution fail. A control that does not make the thing fail has not been shown to control it. The earlier attempted neutralization pinned MOSAIC_CREDENTIALS_FILE to a fake — a real guard aimed at an adjacent input: the identity arm reads the per-slot token file directly and never consults credentials.json. Hence env -i with a fake HOME and GIT_CONFIG_GLOBAL=/dev/null (severing the global identity) rather than one more targeted variable, plus a curl tripwire stub in the body-safety harness so ANY provider request is a loud test failure instead of a live write. --- .../git/test-issue-create-body-safety.sh | 24 +++++++++++++++--- .../git/test-issue-create-interactive-auth.sh | 25 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/packages/mosaic/framework/tools/git/test-issue-create-body-safety.sh b/packages/mosaic/framework/tools/git/test-issue-create-body-safety.sh index 1c95c3ca..71afc31c 100755 --- a/packages/mosaic/framework/tools/git/test-issue-create-body-safety.sh +++ b/packages/mosaic/framework/tools/git/test-issue-create-body-safety.sh @@ -77,12 +77,30 @@ exit 0 SH chmod +x "$BIN_DIR/tea" +# TRIPWIRE provider stub: this harness tests argv construction, so ANY curl +# call is a failure of that contract (and, before this stub existed, a LIVE +# write — the #1282–#1287 incident: the seat's real HOME leaked a global +# mosaic.gitIdentity, flipping the wrapper into identity mode whose real +# per-slot token created real issues on the forge). Fail loudly instead. +cat > "$BIN_DIR/curl" <<'SH' +#!/usr/bin/env bash +echo "FAIL: body-safety harness reached a provider request — this test must never curl" >&2 +exit 99 +SH +chmod +x "$BIN_DIR/curl" + +# Hermetic invocation: fake HOME (no credentials, no tea config, no token +# slots) and GIT_CONFIG_GLOBAL severed — `git config --get mosaic.gitIdentity` +# otherwise resolves the WORKSTATION's global identity (mos-dt-0 on the seat +# that wrote this) and reroutes the wrapper into identity mode (#1280 family). ( cd "$REPO_DIR" - PATH="$BIN_DIR:$PATH" \ - MOSAIC_TEST_RECEIVED="$RECEIVED_FILE" \ - "$SCRIPT_DIR/issue-create.sh" -t "Body safety test" -b "$BODY" + env -i HOME="$WORK_DIR/home" PATH="$BIN_DIR:$PATH" \ + GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null \ + MOSAIC_TEST_RECEIVED="$RECEIVED_FILE" \ + "$SCRIPT_DIR/issue-create.sh" -t "Body safety test" -b "$BODY" ) >/dev/null +mkdir -p "$WORK_DIR/home" # 1. No command substitution executed anywhere in the pipeline. if [[ -e "$SENTINEL" ]]; then diff --git a/packages/mosaic/framework/tools/git/test-issue-create-interactive-auth.sh b/packages/mosaic/framework/tools/git/test-issue-create-interactive-auth.sh index 496e2c43..2566388e 100755 --- a/packages/mosaic/framework/tools/git/test-issue-create-interactive-auth.sh +++ b/packages/mosaic/framework/tools/git/test-issue-create-interactive-auth.sh @@ -47,14 +47,31 @@ SH chmod +x "$BIN_DIR/tea" "$BIN_DIR/curl" run_wrapper() { + # Hermetic: fake HOME (fixture credentials only, no token slots, no tea + # config) and GIT_CONFIG_GLOBAL severed — `git config --get + # mosaic.gitIdentity` otherwise resolves the WORKSTATION's global identity + # and reroutes the wrapper into identity mode before the tea paths this + # harness exercises (#1280 family; see test-issue-create-body-safety.sh). + # An `env …` prefix (used for MOSAIC_TEA_STALE_USER) is re-wrapped, not + # doubled: arguments beginning with "env" are shifted past. + local env_pairs=() + if [[ "${1:-}" == "env" ]]; then + shift + while [[ "$#" -gt 0 && "$1" == *=* ]]; do + env_pairs+=("$1") + shift + done + fi ( cd "$REPO_DIR" - PATH="$BIN_DIR:$PATH" \ - MOSAIC_CREDENTIALS_FILE="$CREDENTIALS_FILE" \ - MOSAIC_TEST_LOG="$LOG_FILE" \ - "$@" + env -i HOME="$WORK_DIR/home" PATH="$BIN_DIR:$PATH" \ + GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null \ + MOSAIC_CREDENTIALS_FILE="$CREDENTIALS_FILE" \ + MOSAIC_TEST_LOG="$LOG_FILE" "${env_pairs[@]}" \ + "$@" ) } +mkdir -p "$WORK_DIR/home" : > "$LOG_FILE" printf 'Interactive title\nInteractive body\nlabel-a,label-b\nM1\n' | run_wrapper "$SCRIPT_DIR/issue-create.sh" -i >/dev/null