Commit 0118ee0
test(security): fix an intermittent failure in the extraction-guard suite [DEVA11Y-484]
A reviewer running the suite alongside another run saw it fail once in seven, and
the cause is real: fixture generation is not atomic, and run_tests.sh gated on
"does legit.tar.gz exist?" — which make_fixtures.sh creates FIRST. A second run
starting behind a generating one saw the gate satisfied and began reading
bomb/manyfiles/multifile while they were still being written.
Reproduced deterministically: clear the fixtures, start one run, start a second 3
seconds later, and the second fails 5 of 51 assertions — many-files and multi-file
across all three variants, which are exactly the fixtures written last.
Generation now takes an atomic mkdir lock (macOS ships no flock CLI) and writes a
`.complete` marker as its final act; run_tests.sh gates on that marker and hard-
fails if it is still absent afterwards. A run that loses the lock waits for the
marker rather than proceeding on half-written input.
Validated: 4 concurrent cold starts, a staggered cold start, and 6 warm serial
runs — 51/51 every time, lock cleaned up, fixtures still gitignored. Mutation
validation re-run and unchanged: disabling the decompressed-size rejection,
raising the cap to 4 GB, dropping the head -c truncation, and removing both
compressed-cap layers are each still caught.
Also documents why the corrupt fixture uses /dev/urandom rather than /dev/zero:
an all-zero file is a VALID EMPTY tar archive, so zeros make bsdtar exit 0 and the
corrupt assertions pass for the wrong reason. That one bit me while building this.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 3027e92 commit 0118ee0
3 files changed
Lines changed: 54 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
9 | 38 | | |
10 | 39 | | |
11 | 40 | | |
| |||
62 | 91 | | |
63 | 92 | | |
64 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
65 | 97 | | |
66 | 98 | | |
67 | 99 | | |
| |||
74 | 106 | | |
75 | 107 | | |
76 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
77 | 112 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
0 commit comments