Repository navigation
Description
Problem Description
On 2026-11-09 at 19:18:52 UTC, a helper of the tests wrote the 22-byte stub #!/bin/sh\necho mytool\n into the real user data root /home/vscode/.local/share/devops-cli/tools/<tool>/<version>/. This content is _EXECUTABLE in tests/support/tools.py. On 2026-11-11, 18 files are still stubs: k9s, argocd, cloudflared, gh-dash, gitleaks, golangci-lint, kube-linter, kubeconform, kubectl-argo-rollouts, osv-scanner, pluto, popeye, tflint, tuicr, bandit/1.9.4/bin/bandit, semgrep/1.179.0/bin/semgrep, bin/pysemgrep and devcontainers-cli/0.89.0/node_modules/@devcontainers/cli/devcontainer.js.
Cause (proved). An agent ran a test helper outside pytest. At 19:18:48 UTC, an Antigravity agent session that worked on #1336 (worktree issue1336_openspec_plans) ran this command from the root of its worktree:
python3 -c '
from pathlib import Path
import tempfile
from tests.support.tools import link_every_tool_at_pin
from devops_cli.commands.devcontainer import _bootstrap_managed_tools
with tempfile.TemporaryDirectory() as td:
p = Path(td)
link_every_tool_at_pin(p)
res = _bootstrap_managed_tools(p)
print("At pin result:", res)
file_path = p / "a_file"
file_path.write_text("x")
warn = _bootstrap_managed_tools(file_path)
print("Warn result:", warn)
'No pytest run started, so no conftest ran:
- The autouse fixture
isolate_user_data_root(tests/conftest.py) did not setDEVOPS_CLI_USER_DATA_ROOT. isolate_home(tests/support/bootstrap.py) did not changeHOME.link_at_pingets each path frominstalled_commands(), which callsuser_data_root()(src/devops_cli/core/repo.py).- With no variable,
user_data_root()returnsCONST_USER_DATA_ROOT, which isPath.home() / ".local/share/devops-cli"(src/devops_cli/config/constants.py). - The temporary directory held only the links. The helper wrote the stub into the version directory of each tool of
tools.lock, in the real home.
The second call, _bootstrap_managed_tools(file_path), started a real install_managed_tools into the real root with a file as the target directory. It downloaded kustomize (19:18:59 UTC) and argo (19:19:06 UTC) again and started argocd. The agent stopped the task at 19:19:06 UTC. The empty folder argocd/.stage-uih9h51c stays.
Why the floor did not stop it. Inside pytest, the floor isolates HOME and the user data root, so this helper is safe there. The helper itself has no guard: it writes to the path that the product code resolves, also when no pytest run is active. The two write guards of the floor (config_write_guard.py, spend_write_guard.py) refuse only config files and spend ledgers. No guard refuses another file under the real home.
Ruled out. A pytest run with --noconftest, a different rootdir, a copied test file, a test that clears the environment, and a fixture order problem. The full devops ci run of another worktree ran from 19:05 to 19:21 UTC, but its tests ran under the floor.
Effects. ~/.local/bin comes before /usr/local/bin on PATH, so each stub hides the real tool. In another worktree, devops openspec archive reported "Archived" at 19:21:23 and 19:21:47 UTC and moved nothing. A third agent found openspec list --json printing mytool and repaired openspec.js by hand at 19:22:01 UTC. devops install-tools --check and status still report each stub as at pin (comment on #4363).
Reproduction Steps
This reproduction sets HOME to a new temporary folder. Do not run it with the real HOME.
tmp=$(mktemp -d); mkdir -p "$tmp/home" "$tmp/links"
cd <repository root>
env -u DEVOPS_CLI_USER_DATA_ROOT HOME="$tmp/home" .venv/bin/python -c '
import sys; sys.path.insert(0, ".")
from pathlib import Path
from tests.support.tools import link_at_pin
link_at_pin("gitleaks", Path(sys.argv[1]) / "links")
' "$tmp"
find "$tmp/home" -type fResult on 2026-11-11 at d2e75974: $tmp/home/.local/share/devops-cli/tools/gitleaks/8.30.1/gitleaks, 22 bytes, #!/bin/sh\necho mytool\n. With the real HOME, the same call writes into the tools of the developer.
Expected vs Actual Behavior
Expected: A helper of the tests writes only inside the temporary directory of a pytest run, and refuses to write when no pytest run is active. A test that writes a file under the real home of the developer fails at that write and names itself.
Actual: The helper writes to the path that the product code resolves. With no pytest run, that path is in the real home. The floor refuses only config files and spend ledgers outside the run directory.
Proposed fix at the source:
- A support helper that writes a file gets its root from a fixture (
tmp_pathorisolate_user_data_root), not from a product default. - Before each write, the helper refuses a path outside the temporary directory of the pytest run (the root that
config_write_guard.pyrecords atpytest_configure). With no run, there is no root, so the helper refuses. pytest 8.2 and later setsPYTEST_VERSIONin the environment during a run; the helper can also refuse at once when this variable is absent. - The floor adds a PEP 578 audit hook (
sys.addaudithook), in the same form asconfig_write_guard.pyandspend_write_guard.py. It fails a test that opens for writing, renames onto or removes a file under the real home (theHOMEbeforeisolate_homechanges it) and outside the run directory. - A test proves each refusal: a helper call outside a run, and a write under the recorded real home in a test.
#4363 removes tests/support/tools.py together with tools_lock. The guard is still necessary, because other support code can run outside pytest in the same way, and the floor has no guard for a write under the real home.
Environment Diagnostics
- devops-cli 0.112.2 (
d2e75974) for the reproduction. At the event,tests/support/tools.pyheld the text ofaea5adc8(the agent read it at 19:18:44 UTC). - Python 3.14.10, pytest 9.1.1.
- Devcontainer on a Linux host (WSL2, rootless Podman).
/home/vscodeis on a persistent home volume.
Logs, Traces, or Terminal Output
- Antigravity transcript of session
4279abea:.system_generated/logs/transcript_full.jsonl, steps 3153 to 3160. Step 3153 (19:18:44 UTC) sends the command. Step 3159 (19:19:00 UTC) stops the task.tasks/task-3154.logholdsAt pin result: []. - File times (UTC), in the order of
tools.lock:argocd19:18:52.922,cloudflared.927,kubectl-argo-rollouts.931,kube-linter.940,popeye.945,pluto.948,kubeconform.952,tflint.960,k9s.970,gh-dash.977,tuicr.981,gitleaks.983,osv-scanner.987,golangci-lint.990,semgrep19:18:53.015,pysemgrep.016,bandit.027,devcontainer.js.034. - Real binaries from the second call:
kustomize/5.8.3/kustomize19:18:59.608 (13443232 bytes),argo/4.1.5/argo19:19:06.324 (196450586 bytes). Empty folderargocd/.stage-uih9h51c19:19:06.672. - Probable, not proved: the helper also wrote kubectl 1.37.1, helm 4.3.0, trivy 0.75.0 and promtool 3.15.1. The second call replaced kubectl and helm, and later installs on 2026-11-10 replaced trivy and promtool. The repair of
openspec.jsat 19:22:01 UTC is proved (sessiona862087a, steps 1744 to 1777).
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(tests)scope of the title gives the scope.The helper already corrupted 18 files in a real home, but triggering it requires a non-standard manual call outside pytest.It prevents silent corruption of the user's real tool stubs when a helper is run outside the pytest isolation floor.Adding a guard that checks for an active pytest session or a set environment variable in the helper is a small change.Both address test code writing outside its intended scope, but #1311 covers writes during pytest runs while this candidate covers writes when a helper is invoked outside pytest.devops-cli-service commentedon Nov 12, 2026
Released in v0.115.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.115.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 04:08 UTC
dan-petty commentedon Nov 12, 2026
On 2026-11-12 one stub of this incident is still in the workstation home:
~/.local/share/devops-cli/tools/kubeconform/0.8.0/kubeconformis a 22-byte script that printsmytool(date 2026-11-09).~/.local/bin/kubeconformlinks to it, sokubeconformand the commands that start it (devops k8s validate,devops security kubeconform) validate nothing. kubectl, helm, promtool and kustomize are real binaries. A person must install kubeconform 0.8.0 again. Found during #4991 (PR #5030).