fix: regressions in the sweep surfaced by adversarial code review - #250
Merged
Conversation
… of the sweep An adversarial code-review pass over the merged sweep PRs (#248, #249) found four high/med regressions that passed CI at 100% coverage because the tests had blind spots. This fixes them and closes the test gaps. binder:vm default boot was broken (HIGH, #162/#174/#176): - _pid_is_qemu() matched the instance dir in /proc/<pid>/cmdline, but the DEFAULT plain `up` argv (boot_cache=false) resolves kernel/rootfs from a shared artifacts cache OUTSIDE the instance dir and references nothing under it. So is_running() was always False on the plain path, which made _wait_for_adb_connect() abort instantly on a healthy boot (#176) and made terminate() orphan the QEMU instead of killing it (#174). e2e missed it because it forces boot_cache=true (where overlay/monitor live under the instance dir). Identity is now keyed on the instance-unique hostfwd ADB port, present in EVERY launch argv; the config-gone orphan teardown falls back to a best-effort qemu-system check. Tests now drive a real build_qemu_argv with paths outside the instance dir. frida truncated-download accepted (HIGH, #228): - The incremental LZMA loop never checked decompressor.eof, so a stream that ended before its end-of-stream marker (a truncated download) was silently accepted as a complete binary — the one-shot lzma.decompress this replaced raised. Now rejects truncation, and caps per-call output (max_length) so a single compressed chunk can't expand without bound. gapps_vendor override note re-emitted (MED, #220): - The note was an Android model_validator firing on every construction, so a fleet scan reprinted it once per pinned-vendor instance. Moved to load_yaml, deduped per resolved path (the #202 pattern). ls/modes off-TTY table still folded wide cells (MED, #204): - rich clamps a print(width=…) request to the console width (80 off-TTY), so a load-bearing cell wider than 80 was folded across lines. The render width is now set on the console so it stays on one line. Also completes module.sha256 shape validation (#194, the deferred half) and fixes the sha256 regex to reject a trailing newline (fullmatch, not match). Full gate green: ruff, mypy --strict src+tests, pytest 100% line+branch (1837 passed), shellcheck/shfmt, codespell, changelog lint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P1YsNMpGizhSDDPCBu5cut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An adversarial code-review workflow over the two merged sweep PRs (#248, #249) found four high/med regressions that passed CI at 100% coverage because the existing tests had blind spots. This PR fixes them and closes the test gaps.
HIGH — the default
binder: vmboot was broken (#162 / #174 / #176)QemuProcess._pid_is_qemu()matchedstr(instance_dir)in/proc/<pid>/cmdline, but the default plainupargv (boot_cache: false, the shipped default) resolves kernel/rootfs from a shared artifacts cache outside the instance dir and references nothing under it. Sois_running()was alwaysFalseon the plain path, which:_wait_for_adb_connect()abort instantly on a perfectly healthy boot (Warm boot_cache resume has no cold-boot fallback and never polls is_running() during the adb wait, so an unrestorable snapshot burns the full timeout then misreports TCG slowness #176), andterminate()orphan the QEMU instead of killing it (VM up()/_up_cached() leak the running QEMU process when the adb-connect wait times out, orphaning the emulator and trapping the nextup#174).The e2e tier missed it because it forces
boot_cache: true(where the overlay/monitor do live under the instance dir). Fix: key identity on the instance-uniquehostfwdADB port, which every launch argv carries; the config-gone orphan teardown falls back to a best-effortqemu-systemcheck. Tests now drive a realbuild_qemu_argvwith paths outside the instance dir.HIGH — frida accepted a truncated download (#228)
The incremental LZMA loop never checked
decompressor.eof, so a stream that ended before its end-of-stream marker (a truncated download) was silently accepted as a complete binary — the one-shotlzma.decompressit replaced would have raised. Now rejects truncation, and caps per-call output (max_length) so a single compressed chunk can't expand without bound.MED —
gapps_vendoroverride note re-emitted per construction (#220)The note was an
Androidmodel_validatorfiring on every construction, so a fleet scan reprinted it once per pinned-vendor instance — the repeated-note anti-pattern #202 had just fixed for its sibling. Moved toload_yaml, deduped per resolved path.MED —
ls/modesoff-TTY table still folded wide cells (#204)rich clamps a
print(width=…)request to the console width (80 off-TTY), so a load-bearing cell wider than 80 was folded across lines. The render width is now set on the console so it stays on one physical line.Also
module.sha256shape validation (frida.sha256 / module.sha256 accept any string (no 64-char-hex check), so a fat-fingered digest fails late with a misleading hostile-mirror message #194 — the half deferred in fix: config validation, download hardening, builder robustness & isolated bug sweep #249) and fixes the sha256 regex to reject a trailing newline (fullmatch, notmatch).Testing
Full local gate green:
ruff,ruff format --check,mypy --strict(src+tests),pytest -p no:randomlyat 100% line+branch coverage (1837 passed, 6 docker-daemon skips),shellcheck/shfmt,codespell, changelog lint. New tests drive the real plain-path argv, a truncated.xz, the per-path note dedup, the >80-col table cell, andmodule.sha256rejection.🤖 Generated with Claude Code
https://claude.ai/code/session_01P1YsNMpGizhSDDPCBu5cut
Generated by Claude Code