Commit 65f0912
fix(scanner): rebuild stale escript to prevent silent false negatives (#278)
## Soundness audit finding
`hypatia-cli.sh` rebuilt the escript only when it was **missing**, never
when it was **older than the rule sources** (`[[ ! -x "${ESCRIPT}" ]]`).
### Adversarial reproduction
A locally-built `hypatia` escript dated 2026-05-14 (3 days behind
`lib/rules/code_safety.ex` @ 2026-05-17) was run against known-bad
samples:
| Sample | Result |
|---|---|
| Idris2 `believe_me` | caught (critical) |
| Rust `.unwrap()` | caught (high) |
| `curl \| bash` | caught (high) |
| **Elixir `System.shell("echo #{user}")`** | **0 findings (false
negative)** |
`CodeSafety.scan_content(content, "elixir")` flags that sink
**critical** when called directly, and the freshly-rebuilt escript
catches all five. The detection engine and the Idris2/Lean proofs are
sound — the deployment wrapper was serving a stale artifact that
silently dropped the entire Elixir/Erlang/Coq/Lean/Agda/Zig/F\*/Ada
pattern families.
### Fix
Add `escript_is_stale()`: rebuild when the binary is missing **or**
older than any `lib/**.ex(s)` / `mix.exs`. `HYPATIA_NO_STALE_REBUILD=1`
opts out for air-gapped deploys; warns (does not silently proceed) when
stale and `mix` is unavailable. Logic unit-tested across
missing/fresh/stale/opt-out cases.
Refs hyperpolymath/standards#124
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8f16d16 commit 65f0912
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
47 | 67 | | |
48 | 68 | | |
49 | 69 | | |
50 | 70 | | |
51 | 71 | | |
52 | 72 | | |
53 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
54 | 81 | | |
55 | 82 | | |
56 | 83 | | |
| |||
0 commit comments