Commit 3b5fd5c
committed
fix: drop the check-then-use file access in the stub-tar test
CodeQL flagged js/file-system-race (high) on the test: existsSync + statSync +
readFileSync on the same path is a time-of-check-to-time-of-use race. Read the
file once and assert on the buffer instead (readFileSync throws if missing,
length covers the size check, the first two bytes are the gzip magic). Same
assertions, one access, no race.
Note: AI-assisted (Claude Code). Manually verified: the 3 stub-tar tests pass,
eslint and prettier clean, and no existsSync/statSync remain on the path so the
CodeQL check-then-use pattern is gone.1 parent b89cc61 commit 3b5fd5c
1 file changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
0 commit comments