Skip to content

Commit d826374

Browse files
committed
test-infra(vm): remove embedded SSH key, pin host identity and installer
The Windows-VM bootstrap embedded a personal SSH public key and the drivers connected with StrictHostKeyChecking=no. Key material and host identity are now strictly operator-supplied and live outside the repository (~/.claude/cbm-vm/, never committed): - windows-bootstrap.ps1 takes the operator's public key as a mandatory -SshPublicKeyPath argument (validated single Ed25519 line) and prints the VM host-key fingerprint to pin. Generating your own key is documented in the script and README: ssh-keygen -t ed25519 -N "" -C <label> -f ~/.claude/cbm-vm/id_ed25519 - win.sh and provision-windows.sh verify the pinned CBM_VM_HOST_KEY_SHA256 fingerprint before every connection (StrictHostKeyChecking=yes against a keyscanned known_hosts, Ed25519 only, IdentitiesOnly), validate branch names before remote interpolation, and fail remote pipelines loudly (set -e -o pipefail). - The MSYS2 installer download is pinned to a versioned release URL with SHA-256 verification instead of an unpinned latest. - win.sh gains a sync subcommand mirroring the uncommitted worktree onto the VM; its manifest logic is guarded by tests/test_vm_worktree_manifest.sh, wired into scripts/test.sh. guards now runs the maintained PowerShell driver against a clean product build; smoke-install drives vm-smoke.sh. - run.sh drops the stale duplicate windows-vm/mac-vm legs (the former carried its own unpinned ssh path) in favor of the vm/ drivers. The previously committed public key has been rotated off the VM and is no longer authorized anywhere. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 08b7ff5 commit d826374

9 files changed

Lines changed: 392 additions & 115 deletions

File tree

‎scripts/test.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ print_env "test.sh"
6161
echo "=== Step 0a: Windows launcher bundle contract ==="
6262
bash "$ROOT/tests/test_windows_bundle_contract.sh"
6363

64-
echo "=== Step 0b: tree-sitter runtime Makefile dependencies ==="
64+
echo "=== Step 0b: Windows VM worktree sync contract ==="
65+
bash "$ROOT/tests/test_vm_worktree_manifest.sh"
66+
67+
echo "=== Step 0c: tree-sitter runtime Makefile dependencies ==="
6568
bash "$ROOT/tests/test_makefile_ts_runtime_dependencies.sh"
6669

67-
echo "=== Step 0c: security fuzz harness self-test ==="
70+
echo "=== Step 0d: security fuzz harness self-test ==="
6871
bash "$ROOT/tests/test_security_fuzz_harness.sh"
6972

7073
# Verify compiler supports target arch

‎test-infrastructure/run.sh‎

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
#!/usr/bin/env bash
2-
# Local CI — test all platforms before pushing.
2+
# Containerized local-CI legs. Before pushing, pair these with native macOS
3+
# tests and the real-Windows VM gate documented below.
34
#
45
# Coverage:
56
# Linux arm64: test (ASan+LeakSan) + build (-O2) [native, fast]
67
# Linux amd64: test + build [QEMU, slower]
78
# Linux portable: Alpine musl static build + smoke [portable binary]
8-
# Windows: cross-compile with mingw-w64 [compile-check; Wine
9-
# CANNOT reproduce real Windows ACL/token/owner semantics —
10-
# use the windows-vm leg for those]
9+
# Windows: cross-compile with mingw-w64 [compile-check; use
10+
# vm/win.sh for mandatory real-Windows verification]
1111
# macOS: run natively (not in Docker)
12-
# windows-vm: OPT-IN real Windows (UTM) — kernel-real ACL/token/owner
13-
# semantics incl. the runner default-owner policy (vm/README.md)
14-
# mac-vm: OPT-IN GitHub-runner macOS environment (Tart) — the env
15-
# class where runner-only failures reproduce (vm/README.md)
1612
#
1713
# Speed first: test containers run unconstrained by default. Before pushing
1814
# anything that touches timing, scheduling, or subprocess code, run ONE pass
@@ -24,8 +20,8 @@
2420
# this script resides in.
2521
#
2622
# Usage:
27-
# ./test-infrastructure/run.sh # arm64 test+build + portable + Windows
28-
# ./test-infrastructure/run.sh all # above + amd64
23+
# ./test-infrastructure/run.sh # arm64 + portable + Windows cross-compile
24+
# ./test-infrastructure/run.sh all # above + amd64 + Windows Wine smoke
2925
# ./test-infrastructure/run.sh portable # Alpine portable build + smoke only
3026
# ./test-infrastructure/run.sh windows # Windows cross-compile only
3127
# ./test-infrastructure/run.sh test # Linux arm64 test only (no perf)
@@ -55,6 +51,11 @@ set -euo pipefail
5551
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5652
COMPOSE="docker compose -f $ROOT/test-infrastructure/docker-compose.yml"
5753

54+
print_real_windows_gate() {
55+
echo "=== Container/cross-compile legs passed ==="
56+
echo "=== Real-Windows gate remains: vm/win.sh sync, test, guards, smoke-install ==="
57+
}
58+
5859
if ! docker info >/dev/null 2>&1; then
5960
echo "ERROR: no Docker daemon reachable." >&2
6061
echo " Start one first — on macOS: colima start --vm-type vz --vz-rosetta --cpu 12 --memory 16" >&2
@@ -78,7 +79,7 @@ case "${1:-full}" in
7879
$COMPOSE run --rm smoke-portable
7980
echo "=== Windows: cross-compile ==="
8081
$COMPOSE run --rm build-windows
81-
echo "=== All passed ==="
82+
print_real_windows_gate
8283
;;
8384
test)
8485
echo "=== Linux arm64: test (ASan + LeakSanitizer, no perf) ==="
@@ -134,7 +135,7 @@ case "${1:-full}" in
134135
$COMPOSE run --rm smoke-amd64
135136
echo "=== Windows: cross-compile + smoke (Wine) ==="
136137
$COMPOSE run --rm smoke-windows
137-
echo "=== All platforms passed ==="
138+
print_real_windows_gate
138139
;;
139140
lint)
140141
echo "=== Linters (clang-format-20 + cppcheck 2.20.0) ==="
@@ -148,50 +149,8 @@ case "${1:-full}" in
148149
echo "=== Debug shell (Alpine) ==="
149150
$COMPOSE run --rm --entrypoint bash test-portable
150151
;;
151-
windows-vm)
152-
# OPT-IN: real Windows semantics (ACL/token/owner) — see vm/README.md.
153-
[ -f "$ROOT/test-infrastructure/vm/config.env" ] && . "$ROOT/test-infrastructure/vm/config.env"
154-
if [ -z "${CBM_WIN_VM_SSH:-}" ]; then
155-
echo "windows-vm leg not configured (opt-in)." >&2
156-
echo " Setup: test-infrastructure/vm/README.md — UTM + CrystalFetch," >&2
157-
echo " run vm/windows-bootstrap.ps1 in the VM, then set CBM_WIN_VM_SSH" >&2
158-
echo " in test-infrastructure/vm/config.env" >&2
159-
exit 2
160-
fi
161-
echo "=== Windows VM: sync + build + test (real ACL/token semantics) ==="
162-
SUITES="${2:-}"
163-
tar -C "$ROOT" --exclude build --exclude .git -cf - . | ssh "$CBM_WIN_VM_SSH" \
164-
"C:/msys64/usr/bin/bash.exe -lc 'rm -rf /c/cbm/src && mkdir -p /c/cbm/src && cd /c/cbm/src && tar -xf - && scripts/test.sh CC=clang CXX=clang++ ${SUITES:+TEST_SUITES=\"$SUITES\"}'"
165-
;;
166-
mac-vm)
167-
# OPT-IN: GitHub-runner-equivalent macOS environment — see vm/README.md.
168-
if ! command -v tart >/dev/null 2>&1 || ! tart list 2>/dev/null | grep -q cbm-mac-runner; then
169-
echo "mac-vm leg not configured (opt-in)." >&2
170-
echo " Setup: brew trust cirruslabs/cli && brew install tart &&" >&2
171-
echo " tart clone ghcr.io/cirruslabs/macos-runner:sequoia cbm-mac-runner" >&2
172-
exit 2
173-
fi
174-
echo "=== macOS runner VM: sync + test (GitHub-runner environment) ==="
175-
tart run --no-graphics cbm-mac-runner >/dev/null 2>&1 &
176-
TART_PID=$!
177-
trap '{ kill "$TART_PID" 2>/dev/null || true; }' EXIT
178-
VM_IP=""
179-
for _ in $(seq 1 60); do
180-
VM_IP=$(tart ip cbm-mac-runner 2>/dev/null) && [ -n "$VM_IP" ] && break
181-
sleep 2
182-
done
183-
[ -n "$VM_IP" ] || { echo "ERROR: VM did not obtain an IP" >&2; exit 1; }
184-
if ! ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new "admin@$VM_IP" true 2>/dev/null; then
185-
echo "One-time: install your key in the VM (password: admin):" >&2
186-
echo " ssh-copy-id admin@$VM_IP" >&2
187-
exit 2
188-
fi
189-
tar -C "$ROOT" --exclude build --exclude .git -cf - . | \
190-
ssh -o BatchMode=yes "admin@$VM_IP" \
191-
'rm -rf ~/cbm-src && mkdir -p ~/cbm-src && cd ~/cbm-src && tar -xf - && scripts/test.sh CC=cc CXX=c++'
192-
;;
193152
*)
194-
echo "Usage: $0 {full|test|build|smoke|portable|portable-test|windows|amd64|all|lint|shell|shell-alpine|windows-vm|mac-vm}"
153+
echo "Usage: $0 {full|test|perf|build|smoke|portable|portable-test|windows|smoke-windows|soak-windows|amd64|all|lint|shell|shell-alpine}"
195154
exit 1
196155
;;
197156
esac

‎test-infrastructure/vm/README.md‎

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# VM test legs — real-Windows and runner-macOS
1+
# Real-Windows local-CI leg
22

3-
Two failure classes cannot be reproduced by the container legs and need real
4-
virtual machines. Both stacks are free. The Windows VM is a first-class part
5-
of the mandatory local-CI gate (see the repo's local-first workflow): it is
6-
driven entirely over ssh by reproducible scripts in this directory.
3+
Windows kernel semantics cannot be reproduced by the container/Wine legs. The
4+
UTM VM is a first-class part of the mandatory local-CI gate and is driven over
5+
local ssh by the reproducible scripts in this directory. The canonical macOS
6+
leg remains the native host; Linux runs through Colima.
77

88
## Windows VM — real ACL/token/owner semantics (script-driven)
99

@@ -21,10 +21,14 @@ seconds-fast local loop with full stderr/debugger visibility.
2121
| `win.sh` | on the host | daily driver: build / test / guards / install-E2E / shell |
2222

2323
Host-local config (never committed): `~/.claude/cbm-vm/config` with
24-
`CBM_VM_HOST=<ip>` and `CBM_VM_USER=<user>`; ssh keypair at
24+
`CBM_VM_HOST=<ip>`, `CBM_VM_USER=<user>`, and the
25+
`CBM_VM_HOST_KEY_SHA256=<SHA256:...>` fingerprint printed by the bootstrap.
26+
`CBM_VM_BRANCH=<branch>` is optional; both drivers otherwise use the current
27+
local Git branch, falling back to `main` only for a detached worktree.
28+
The drivers verify that fingerprint before every connection. The ssh keypair is at
2529
`~/.claude/cbm-vm/id_ed25519` (generate: `ssh-keygen -t ed25519 -N "" -C
26-
claude-cbm-vm -f ~/.claude/cbm-vm/id_ed25519`, public half goes into
27-
`windows-bootstrap.ps1`).
30+
claude-cbm-vm -f ~/.claude/cbm-vm/id_ed25519`; include the public half beside
31+
`windows-bootstrap.ps1` on the setup ISO as documented in that script).
2832

2933
### One-time VM creation (~30 min interactive, do it once, snapshot it)
3034

@@ -58,14 +62,19 @@ claude-cbm-vm -f ~/.claude/cbm-vm/id_ed25519`, public half goes into
5862
### Daily loop
5963

6064
```
61-
vm/win.sh update # sync VM repo to the pushed branch + rebuild
65+
vm/win.sh update # sync VM repo to the pushed current branch + rebuild
66+
vm/win.sh sync # mirror the uncommitted worktree and rebuild before local gates
6267
vm/win.sh test cli daemon_ipc # run suites natively, seconds
6368
vm/win.sh guards # the Windows guard scripts
6469
vm/win.sh smoke-install # managed-install E2E, stderr VISIBLE
6570
vm/win.sh sh "cd /c/cbm && gdb ..." # anything, interactively
6671
vm/win.sh push-file src/cli/cli.c /c/cbm/src/cli/cli.c # WIP iteration
6772
```
6873

74+
`sync` requires the VM to already have the exact pushed base commit (`update`
75+
does that); it then mirrors the host's uncommitted tracked and untracked changes,
76+
cleans stale build outputs, and rebuilds.
77+
6978
### Toolchains & honest limits
7079

7180
- **CLANGARM64 (native, default)**: fast on all cores; OS-semantics bugs
@@ -91,20 +100,6 @@ vm/win.sh push-file src/cli/cli.c /c/cbm/src/cli/cli.c # WIP iteration
91100
- Environment shape (runner temp paths, runneradmin profile) is
92101
approximated, not identical — CI on the final SHA remains the proof.
93102

94-
## macOS runner VM (`run.sh mac-vm`) — the GitHub-runner macOS environment
95-
96-
A local Mac is not the GitHub macOS runner (different temp ancestry, ACLs,
97-
policies): failures like the index-supervisor worker exits reproduce only
98-
there. Cirrus Labs publishes runner-equivalent images.
99-
100-
1. `brew trust cirruslabs/cli && brew install tart` (free OSS).
101-
2. `tart clone ghcr.io/cirruslabs/macos-runner:sequoia cbm-mac-runner`
102-
(tens of GB, one time).
103-
104-
The leg boots the VM headless (`tart run --no-graphics cbm-mac-runner`),
105-
syncs the worktree over ssh (admin/admin inside the runner image), and
106-
executes `scripts/test.sh`.
107-
108103
## Honesty rules
109104

110105
- These legs never silently skip: absent tooling prints setup guidance and

‎test-infrastructure/vm/provision-windows.sh‎

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
# 1. UTM VM with Windows 11 ARM64 installed, CLONED as a backup before
99
# drivers, SPICE guest tools installed (network), and
1010
# windows-bootstrap.ps1 run inside the VM (OpenSSH + authorized key).
11-
# 2. Host config in ~/.claude/cbm-vm/config (KEY=VALUE):
12-
# CBM_VM_HOST=192.168.64.4
13-
# CBM_VM_USER=test
14-
# Key at ~/.claude/cbm-vm/id_ed25519 (see README.md to generate).
11+
# 2. Host config in ~/.claude/cbm-vm/config (KEY=VALUE), values printed by
12+
# windows-bootstrap.ps1 at the end of its run:
13+
# CBM_VM_HOST=<vm ip>
14+
# CBM_VM_USER=<vm user>
15+
# CBM_VM_HOST_KEY_SHA256=<SHA256:... host-key fingerprint>
16+
# Key at ~/.claude/cbm-vm/id_ed25519 (see README.md to generate your own;
17+
# never commit keys or this config).
1518
#
1619
# Usage:
1720
# test-infrastructure/vm/provision-windows.sh # full provision
@@ -20,20 +23,37 @@ set -euo pipefail
2023

2124
CONFIG="${HOME}/.claude/cbm-vm/config"
2225
KEY="${HOME}/.claude/cbm-vm/id_ed25519"
26+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
27+
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
28+
# The fixed host-local config is intentionally outside this repository.
29+
# shellcheck source=/dev/null
2330
[ -f "$CONFIG" ] && . "$CONFIG"
2431
HOST="${CBM_VM_HOST:?set CBM_VM_HOST in ~/.claude/cbm-vm/config}"
2532
USER_="${CBM_VM_USER:-test}"
26-
BRANCH="${CBM_VM_BRANCH:-feat/shared-coordination-daemon}"
33+
HOST_KEY="${CBM_VM_HOST_KEY_SHA256:?set CBM_VM_HOST_KEY_SHA256 in ~/.claude/cbm-vm/config}"
34+
LOCAL_BRANCH="$(git -C "$ROOT" branch --show-current)"
35+
BRANCH="${CBM_VM_BRANCH:-${LOCAL_BRANCH:-main}}"
2736
REPO_URL="${CBM_VM_REPO:-https://github.com/DeusData/codebase-memory-mcp.git}"
28-
MSYS2_SFX_URL="https://repo.msys2.org/distrib/msys2-x86_64-latest.sfx.exe"
37+
MSYS2_SFX_URL="https://github.com/msys2/msys2-installer/releases/download/2026-06-11/msys2-base-x86_64-20260611.sfx.exe"
38+
MSYS2_SFX_SHA256="c105946e64e08f099ac0e4647461ce762b95333ad211777666476a9a41451d65"
2939

30-
SSH=(ssh -i "$KEY" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
31-
-o ConnectTimeout=10 -o BatchMode=yes "${USER_}@${HOST}")
40+
# shellcheck source=test-infrastructure/vm/ssh-common.sh
41+
source "$SCRIPT_DIR/ssh-common.sh"
42+
cbm_vm_require_safe_branch "$BRANCH"
43+
cbm_vm_prepare_known_hosts "$HOST" "$HOST_KEY"
44+
trap cbm_vm_cleanup_known_hosts EXIT
45+
SSH_OPTIONS=(-i "$KEY" -o IdentitiesOnly=yes -o HostKeyAlgorithms=ssh-ed25519 \
46+
-o StrictHostKeyChecking=yes -o UserKnownHostsFile="$CBM_VM_KNOWN_HOSTS" \
47+
-o ConnectTimeout=10 -o BatchMode=yes)
48+
SSH=(ssh "${SSH_OPTIONS[@]}" "${USER_}@${HOST}")
49+
# Expand inside the remote MSYS2 shell, not on the macOS host.
50+
# shellcheck disable=SC2016
51+
JOBS='$(nproc)'
3252

3353
# Run a command inside the given msys2 environment (clangarm64|clang64|msys).
3454
vm() { # vm <env> <command...>
3555
local env="$1"; shift
36-
"${SSH[@]}" "C:\\msys64\\msys2_shell.cmd -defterm -no-start -${env} -c \"$*\""
56+
"${SSH[@]}" "C:\\msys64\\msys2_shell.cmd -defterm -no-start -${env} -c \"set -e -o pipefail; $*\""
3757
}
3858
vm_cmd() { "${SSH[@]}" "$@"; } # plain cmd.exe
3959

@@ -49,13 +69,15 @@ vm_cmd "echo VM_OK & ver" | grep -q VM_OK || {
4969
if [ "${1:-}" != "--update" ]; then
5070
step "1/6 msys2 base (skip if present)"
5171
if ! vm_cmd "if exist C:\\msys64\\usr\\bin\\bash.exe echo MSYS2_PRESENT" | grep -q MSYS2_PRESENT; then
52-
vm_cmd "powershell -Command \"[Net.ServicePointManager]::SecurityProtocol='Tls12'; Invoke-WebRequest -Uri ${MSYS2_SFX_URL} -OutFile C:\\msys2.sfx.exe\""
72+
vm_cmd "powershell -NoProfile -Command \"\$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol='Tls12'; Invoke-WebRequest -Uri '${MSYS2_SFX_URL}' -OutFile C:\\msys2.sfx.exe; \$actual=(Get-FileHash -LiteralPath C:\\msys2.sfx.exe -Algorithm SHA256).Hash.ToLowerInvariant(); if (\$actual -ne '${MSYS2_SFX_SHA256}') { Remove-Item -LiteralPath C:\\msys2.sfx.exe -Force; throw 'MSYS2 installer SHA-256 mismatch' }\""
5373
vm_cmd "C:\\msys2.sfx.exe -y -oC:\\" >/dev/null
74+
vm_cmd "del C:\\msys2.sfx.exe"
5475
vm "msys" "pacman-key --init && pacman-key --populate msys2"
5576
fi
5677

57-
step "2/6 pacman update (repeat-safe)"
58-
vm "msys" "rm -f /var/lib/pacman/db.lck; pacman -Syu --noconfirm --noprogressbar" || true
78+
step "2/6 pacman full update (official two-pass sequence)"
79+
vm "msys" "pacman --noconfirm --noprogressbar -Syuu"
80+
vm "msys" "pacman --noconfirm --noprogressbar -Syuu"
5981

6082
step "3/6 toolchains: CLANGARM64 (native, fast) + CLANG64 (x86_64 = CI arch, ASan)"
6183
vm "msys" "pacman -S --noconfirm --noprogressbar --needed \
@@ -68,13 +90,13 @@ fi
6890

6991
step "4/6 repo clone/update -> /c/cbm @ ${BRANCH}"
7092
if vm "clangarm64" "test -d /c/cbm/.git && echo REPO_PRESENT" | grep -q REPO_PRESENT; then
71-
vm "clangarm64" "cd /c/cbm && git fetch origin ${BRANCH} && git reset --hard FETCH_HEAD && git log --oneline -1"
93+
vm "clangarm64" "cd /c/cbm && git fetch origin ${BRANCH} && git reset --hard FETCH_HEAD && git clean -fdx && git log --oneline -1"
7294
else
7395
vm "clangarm64" "git clone --branch ${BRANCH} --single-branch --depth 200 ${REPO_URL} /c/cbm && cd /c/cbm && git log --oneline -1"
7496
fi
7597

7698
step "5/6 build: native ARM64 binary + launcher + test-runner (no ASan on arm64)"
77-
vm "clangarm64" "cd /c/cbm && make -j\\\$(nproc) -f Makefile.cbm CC=clang CXX=clang++ SANITIZE= cbm build/c/test-runner > /tmp/provision-build.log 2>&1 && echo BUILD_OK || (echo BUILD_FAIL; tail -15 /tmp/provision-build.log; exit 1)"
99+
vm "clangarm64" "cd /c/cbm && make -j${JOBS} -f Makefile.cbm CC=clang CXX=clang++ SANITIZE= cbm build/c/test-runner > /tmp/provision-build.log 2>&1 && echo BUILD_OK || (echo BUILD_FAIL; tail -15 /tmp/provision-build.log; exit 1)"
78100

79101
step "6/6 smoke: binary + test-runner start"
80102
vm "clangarm64" "cd /c/cbm && ./build/c/codebase-memory-mcp.exe --version && ./build/c/test-runner --list-suites | head -3"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env bash
2+
# Shared pinned-host verification for the local Windows VM drivers.
3+
4+
cbm_vm_require_safe_branch() {
5+
local branch="${1-}"
6+
if [[ ! "$branch" =~ ^[A-Za-z0-9][A-Za-z0-9._/-]*$ ]] ||
7+
! git check-ref-format --branch "$branch" >/dev/null 2>&1; then
8+
echo "FATAL: CBM_VM_BRANCH is not a safe Git branch name: $branch" >&2
9+
return 1
10+
fi
11+
}
12+
13+
cbm_vm_prepare_known_hosts() {
14+
local host="$1"
15+
local expected="$2"
16+
local actual
17+
18+
if [[ ! "$expected" =~ ^SHA256:[A-Za-z0-9+/]{43}$ ]]; then
19+
echo "FATAL: CBM_VM_HOST_KEY_SHA256 is missing or malformed." >&2
20+
echo " Copy the SHA256:... Ed25519 fingerprint printed by windows-bootstrap.ps1." >&2
21+
return 1
22+
fi
23+
24+
CBM_VM_KNOWN_HOSTS="$(mktemp "${TMPDIR:-/tmp}/cbm-vm-known-hosts.XXXXXX")"
25+
chmod 600 "$CBM_VM_KNOWN_HOSTS"
26+
if ! ssh-keyscan -T 10 -t ed25519 "$host" >"$CBM_VM_KNOWN_HOSTS" 2>/dev/null; then
27+
echo "FATAL: could not read the Windows VM Ed25519 host key at $host." >&2
28+
cbm_vm_cleanup_known_hosts
29+
return 1
30+
fi
31+
actual="$(ssh-keygen -lf "$CBM_VM_KNOWN_HOSTS" -E sha256 2>/dev/null | awk '{print $2}')"
32+
if [ "$actual" != "$expected" ]; then
33+
echo "FATAL: Windows VM SSH host-key mismatch." >&2
34+
echo " expected: $expected" >&2
35+
echo " observed: ${actual:-unreadable}" >&2
36+
echo " Stop: verify the fingerprint from the VM console; do not accept it blindly." >&2
37+
cbm_vm_cleanup_known_hosts
38+
return 1
39+
fi
40+
}
41+
42+
cbm_vm_cleanup_known_hosts() {
43+
if [ -n "${CBM_VM_KNOWN_HOSTS:-}" ]; then
44+
rm -f -- "$CBM_VM_KNOWN_HOSTS"
45+
CBM_VM_KNOWN_HOSTS=""
46+
fi
47+
}
48+
49+
cbm_vm_write_untracked_manifest() {
50+
local root="$1"
51+
local manifest="$2"
52+
local symlinks
53+
local entry
54+
local mode
55+
local relative
56+
local link
57+
local nested
58+
59+
symlinks="$(mktemp "${TMPDIR:-/tmp}/cbm-vm-symlinks.XXXXXX")"
60+
: >"$manifest"
61+
while IFS= read -r -d '' entry; do
62+
mode="${entry%% *}"
63+
relative="${entry#*$'\t'}"
64+
if [ "$mode" = "120000" ]; then
65+
printf '%s\0' "$relative" >>"$symlinks"
66+
fi
67+
done < <(git -C "$root" ls-files --stage -z)
68+
69+
while IFS= read -r -d '' relative; do
70+
nested=false
71+
while IFS= read -r -d '' link; do
72+
case "$relative" in
73+
"$link"/*) nested=true; break ;;
74+
esac
75+
done <"$symlinks"
76+
if ! $nested && [ -L "$root/$relative" ]; then
77+
echo "FATAL: untracked symlink cannot be mirrored to Windows: $relative" >&2
78+
echo " Stage the symlink so the binary Git patch carries its platform semantics." >&2
79+
rm -f -- "$symlinks"
80+
return 1
81+
fi
82+
if ! $nested && [ -e "$root/$relative" ]; then
83+
printf '%s\0' "$relative" >>"$manifest"
84+
fi
85+
done < <(git -C "$root" ls-files --others --exclude-standard -z)
86+
rm -f -- "$symlinks"
87+
}

‎test-infrastructure/vm/vm-smoke.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# Run inside the VM's CLANGARM64 shell from the repo root:
1111
# bash test-infrastructure/vm/vm-smoke.sh
12-
# Or from the host: test-infrastructure/vm/win.sh smoke
12+
# Or from the host: test-infrastructure/vm/win.sh smoke-install
1313
set -euo pipefail
1414

1515
cd "$(dirname "$0")/../.."

0 commit comments

Comments
 (0)