Skip to content

test: guard the host X display socket during test runs - #237

Merged
ElbertePlinio merged 7 commits into
mainfrom
test/234-host-display-guard
Oct 3, 2026
Merged

ElbertePlinio merged 7 commits into
mainfrom
test/234-host-display-guard

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Tests and QA started X servers that replaced the host display socket /tmp/.X11-unix/X0, which broke every new X11 app on the host. This adds a static check that rejects the unsafe Xvfb forms, a vitest guard that fails a local run when the host DISPLAY socket changes, and an AGENTS.md rule. Product code is unchanged. The guard does nothing when DISPLAY is unset, as in CI.

Closes #234

Requirement Verified by Scenario Result Evidence
Security check rejects bare -displayfd and xvfb-run -d Automated test, manual check Unit samples: bare array, spawn("Xvfb", [...]), shell Xvfb -displayfd, xvfb-run -d, --auto-display, -ad, -d after an -s value. Allowed: explicit :N, template :${...}, xvfb-run -a, -d after the command or after -n 99. A bad file planted in test/ fails the scan; removing it passes Pass ~/.cache/kickoff-234/qa/scan-bad.log, scan-clean.log
Guard fails a run when the host socket changes Manual check with a dummy display :64998 Socket replaced: exit 1. Socket removed: exit 1. Untouched: exit 0. Absent and still absent: exit 0. DISPLAY=:64998.0: exit 0. Vitest only logs teardown errors, so the guard also sets the exit code Pass ~/.cache/kickoff-234/qa/guard-*.log
Guard is a no-op without a local DISPLAY Automated test Unset, empty, localhost:0, wayland-1, malformed values Pass test/host-display-guard.test.ts
AGENTS.md rule Manual check States the explicit-display rule, the container bind-mount rule, and the guard Pass AGENTS.md diff
viewer-cursor.test.ts cleanup Handed to PR #225, which owns that file allocateDisplay and SIGTERM Handed off #225 (comment)
Repo checks typecheck, oxlint, build, full suite, PickCheck 0.4.0, CI Final head 0059f88. Full suite with the CI PICKFORGE_REQUIRE_* flags, default /tmp, and the guard armed on the real DISPLAY=:0: 2418 passed, 0 failed, host socket inode unchanged. One earlier run hit an unrelated allocation flake under load, filed as #240. CI fully green at a5b94bd, including gitleaks after #241 fixed #236 Pass ~/.cache/kickoff-234/test-final2.log, pickcheck.json

QA pass, evidence in ~/.cache/kickoff-234/qa/. Incident replay in a private namespace with a path-only X0 listener and a live lock: a test that starts a real bare Xvfb -displayfd 3 makes vitest exit 1 with the guard message, and X0 really was replaced; the explicit :1234 form exits 0. The scan flags the bare form of viewer-cursor.test.ts as it ran on 2026-10-03 (line 269) and passes its explicit and current forms. A real Pickforge desktop session (session create, desktop exec zenity, windows, key, screenshot, session destroy) ran on :91 and left the host X0 inode unchanged. Review: Astra and Fable at xhigh, three repair rounds, final rechecks report nothing blocking.

Add a static check that rejects bare Xvfb -displayfd and xvfb-run -d, and a vitest global setup that fails the run when the host DISPLAY socket changes. Refs #234.
Watch /tmp/.X11-unix during the run so a socket that is created and
removed, or moved away and back, fails the run. Read DISPLAY numbers
with leading zeros as Xlib does. Warn and stay inactive when setup
cannot read the socket, and fail the run when teardown cannot.

Bound the security scan to one command or argument list. Check
-displayfd for an exact display token, follow xvfb-run across lines
and shell continuations, and parse grouped short options.
Replace the ad hoc boundary and token logic in the display scan with
one quote-aware lexer for both rules. Terminators and the closing
array bracket count only outside quotes, comments are dropped, and a
bare shell word absorbs adjacent quoted parts.

A display now counts only as the first argument or after a token that
is not an option. Unquoted array items such as spreads count as
xvfb-run options, so only a quoted string ends the option list.
Lex command by command on the logical line when the X server name is
not on the same command, so wrapper and variable forms keep earlier
display arguments. Use array context only inside an unclosed bracket,
and treat // and block comments as comments only in JS context.
@ElbertePlinio
ElbertePlinio merged commit 02e6591 into main Oct 3, 2026
5 checks passed
@ElbertePlinio
ElbertePlinio deleted the test/234-host-display-guard branch October 3, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant