Repository navigation
test(accessibility): helper cache dir and reply-id matching - #162
Conversation
Split private_cache_dir into a wrapper over private_cache_dir_in(temp_dir) and the reply-wait loop into await_reply(rx, id, timeout), with no behaviour change, so both can be tested: a symlinked cache dir and a group-writable temp dir are refused, an existing dir is reused and made 0700, and only the line carrying the request id answers it.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): test(accessibility): helper cache dir and reply-id matching. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changedThe helper cache-directory check is split: `private_cache_dir` canonicalizes the temp dir and calls the new `private_cache_dir_in(temp_dir, name)` on a changed_path `crates/tinycomputer-accessibility/src/helper.rs` (new symbols `private_cache_dir_in`; per the whole-PR description the ownership, symlink, non-directory, and permission checks are unchanged). In a changed_path `crates/tinycomputer-accessibility/src/helper/process.rs`, the reply-wait loop of `helper_send_receive` moved into a new function `await_reply(rx_slot, id_str, timeout) -> Result<Option<Value>, String>`: `None` signals a timeout, and the caller still calls `reset_helper_process()` and returns the same timeout error string; a matching id still returns the parsed value. Two test modules are added: a changed_path `crates/tinycomputer-accessibility/src/helper/process_tests.rs` (macOS-gated) and a cache-dir module added to a changed_path `crates/tinycomputer-accessibility/src/helper_tests.rs`. The whole-PR diffstat reports 153 additions and 12 deletions across 4 files. No behavior change is claimed by the PR; the description notes the uid-mismatch branch remains untested. Features
Tests
FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
Summary
Test-only, with two no-behaviour-change extractions so the code can be tested.
The macOS Swift helper is compiled into a cache directory under the temp dir, and
private_cache_dirrefuses a temp dir others can write and a cache dir that is a symlink, not a directory, or someone else's. Its replies are read off a channel, and only the line carrying the request's id may answer a request. Stale, blank and unnumbered lines are skipped. None of these checks was tested, so a refactor could drop one silently.private_cache_dir(name)now resolves the temp dir and callsprivate_cache_dir_in(temp_dir, name), which holds the unchanged checks.helper_send_receivemoved intoawait_reply(rx, id, timeout) -> Result<Option<Value>, String>.Nonemeans it timed out, and the caller still resets the helper and returns the same timeout error.Related issue
None.
API or behavior changes
None.
Validation
Commands actually run, with their outcome:
cargo fmt --all -- --check: rustfmt run on the touched files only; CI runs the full checkcargo clippy --all-targets --all-features -- -D warnings: left to CIcargo build --all-targets --all-features: left to CIcargo test --all-features: only the new tests were run locally (below, macOS); CI runs the suiteCARGO_INCREMENTAL=0 cargo test -p tinycomputer-accessibility --lib -- helper::tests::cache_dir helper::process::testsok. 7 passed; 0 failed.0o077check removed, and any reply id accepted), restored before commit:FAILED. 3 passed; 4 failed. The failures are the symlink, writable-temp-dir, stale-line and timeout tests.Tests
helper_tests.rs(cache_dir, macOS): a new cache dir is created 0700; an existing own dir is reused and tightened to 0700; a symlinked cache dir is refused; a temp dir with group access is refused and nothing is created in it.helper/process_tests.rs(macOS): stale, blank and unnumbered lines are skipped until the id matches; no match before the timeout isNone; a non-JSON line is an error.Not tested: the uid-mismatch branch, which needs a directory owned by another user.
Documentation
Not needed.
Checklist
#[allow(...)],#[ignore], or relaxed lints: the two new test modules carry the crate's usual test-only#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)].envcontents in the diff or the description