You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three issues raised by the Rust PR Reviewer on #691:
1. **Lexicographic sort wrong for multi-digit run IDs.** Previously
`find_artifact_dir` / `find_verdict_path` / `top_level_dirs_with_prefix`
picked the "lexicographically last" `<prefix>_<id>` directory, which
sorts `_9` after `_10` (because `'9' > '1'`). On a build retry that
produced both `analyzed_outputs_9` and `analyzed_outputs_10`, the
older verdict would be read and the run could be mis-classified as
safe.
New `crate::audit::cmp_numeric_suffix` extracts the trailing token
after the final `_`, parses it as `u64`, and compares numerically
with a lexicographic tie-breaker for non-numeric suffixes. All three
call sites now use it. Regression tests added in mod.rs, detection.rs,
and cli.rs.
2. **Security: `ADO_AW_TEST_ORG_URL` was always active in production.**
The override was `#[doc(hidden)]` but not gated by build mode, so a
stray env var (debugging leftover, hostile CI environment) could
silently redirect ADO REST calls to an attacker-controlled URL in a
release binary.
Gated on `cfg(debug_assertions)`: debug builds (`cargo test`,
`cargo run`) keep the override AND emit a loud `warn!` on every
invocation; release builds (all published artifacts via
`cargo build --release`) replace the body with a no-op so a stray
env var has no effect. The integration test in `tests/audit_it.rs`
continues to work because `cargo test` builds in debug mode.
3. **Blocking `std::fs::read_dir` in async context.** `safe_outputs.rs`
had two helpers (`top_level_dirs_with_prefix`, `collect_named_files`)
using sync I/O from inside `async fn analyze_safe_outputs`. On a
Tokio multi-thread runtime this blocks an executor thread for the
duration of the directory walk.
Both helpers converted to `async fn` using `tokio::fs::read_dir`.
The recursive `collect_named_files` uses `Box::pin` to satisfy the
async-recursion shape (consistent with the existing pattern in
`crate::detect::scan_directory`).
Tests: 1745 unit tests + 3 integration tests pass (up from 1740 — 5
new regression tests for the numeric-suffix bug).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments