test(git): hermetic fixtures for issue-create harnesses (#1282-#1287)
ci/woodpecker/pr/ci Pipeline was canceled

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.
This commit is contained in:
fargo
2026-08-17 15:19:04 -05:00
parent 19ad93999f
commit d789a43cae
2 changed files with 42 additions and 7 deletions
@@ -77,12 +77,30 @@ exit 0
SH SH
chmod +x "$BIN_DIR/tea" 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" cd "$REPO_DIR"
PATH="$BIN_DIR:$PATH" \ 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" \ MOSAIC_TEST_RECEIVED="$RECEIVED_FILE" \
"$SCRIPT_DIR/issue-create.sh" -t "Body safety test" -b "$BODY" "$SCRIPT_DIR/issue-create.sh" -t "Body safety test" -b "$BODY"
) >/dev/null ) >/dev/null
mkdir -p "$WORK_DIR/home"
# 1. No command substitution executed anywhere in the pipeline. # 1. No command substitution executed anywhere in the pipeline.
if [[ -e "$SENTINEL" ]]; then if [[ -e "$SENTINEL" ]]; then
@@ -47,14 +47,31 @@ SH
chmod +x "$BIN_DIR/tea" "$BIN_DIR/curl" chmod +x "$BIN_DIR/tea" "$BIN_DIR/curl"
run_wrapper() { 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" cd "$REPO_DIR"
PATH="$BIN_DIR:$PATH" \ 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_CREDENTIALS_FILE="$CREDENTIALS_FILE" \
MOSAIC_TEST_LOG="$LOG_FILE" \ MOSAIC_TEST_LOG="$LOG_FILE" "${env_pairs[@]}" \
"$@" "$@"
) )
} }
mkdir -p "$WORK_DIR/home"
: > "$LOG_FILE" : > "$LOG_FILE"
printf 'Interactive title\nInteractive body\nlabel-a,label-b\nM1\n' | run_wrapper "$SCRIPT_DIR/issue-create.sh" -i >/dev/null printf 'Interactive title\nInteractive body\nlabel-a,label-b\nM1\n' | run_wrapper "$SCRIPT_DIR/issue-create.sh" -i >/dev/null