Repository navigation
Commit 7bf2654
committed
Copy the target's mode onto the staged file so the publish cannot widen it
CWE-732: the commit rename lands the staged file onto the target, so the file that survives carries
the staged file's mode. A 0o600 target was being published 0o644 from the umask-derived default,
which is the third ubuntu failure at e3d6327 - "preserves a restrictive 0o600 target mode through
the atomic publish", AssertionError: expected 420 to be 384 at safeWriteJson.test.ts:1047.
The helper is grafted verbatim from the Zoo-Code-Org#1912 head 085fbf8: stat the target, chmod the staged
file, log and continue on a stat or chmod failure, nothing to copy for a target that is not there
yet. Call site and ordering match 085fbf8 - after the staging write, before the flush - and the
call names the same resolved string the staging, the commit rename, the escape re-checks and the
rollback rename name, which is the seam rule for this file.
That head is not an ancestor of 73931fe (git merge-base --is-ancestor, exit 1), so this does not
claim main accepted and dropped it - only that the two resolutions differ on a permission property,
which is the leftover recorded on the PR rather than a thing to resolve silently inside one unit.
Two variants of this helper now exist on the series, both in src/utils/safeWriteJson.ts and nowhere
in src/services/file-safety/safeWriteText.ts: log-and-continue here (impl blob 1e4031a
92f6547955ebca26c9f5, same as 8fa7d85) and at 085fbf8 (blob eebd1ff
30d2bf), and fail-closed at the Zoo-Code-Org#1917 head c4bd9a2 (blob
fbe8b07). Whichever merge lands first supplies the canonical text:
merge order, not merit. Zoo-Code-Org#2350 plus merge order is the arbiter, and this copy is not being converged
onto the fail-closed text.
Both failure branches carry rows, because a helper grafted for a permission property with two
unexercised error paths is a changed-line coverage hole whatever the mutation gate decides:
"logs and still publishes when the target's mode cannot be read" and "logs and still publishes when
the staged file's mode cannot be set". They drive fs.stat and fs.chmod through the file's existing
fs/promises mock factory (chmod is newly a vi.fn() delegating to the real implementation) rather
than a real EACCES/EPERM, which needs privileges neither this box nor a CI runner has, so - unlike
the symlink and mode rows above - these two run on every platform. A name-filtered run of this spec
selects exactly those two rows and both pass.
Gates on this commit's tree, pinned node v22.23.4 (box node 25.9.0): misc exit 0 at 2118 passed / 17
skipped (2135 total, +2 rows); tsc -p src/tsconfig.json exit 0; prettier --check clean; eslint
--max-warnings=0 exit 0 on both touched files, run without --prune-suppressions so
src/eslint-suppressions.json is untouched; knip --production exit 0 run from the repo root, where
knip.json lives. git diff --name-only 8fa7d85 HEAD lists only this spec file, so the implementation
is byte-identical to the head whose CI is running and only test rows were added on top of it. The
three ubuntu rows themselves remain answered by CI's ubuntu leg, not by this box.
Refs: Zoo-Code-Org#1375, Zoo-Code-Org#1991, Zoo-Code-Org#2019.1 parent 1871993 commit 7bf2654
2 files changed
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
1048 | 1049 | | |
1049 | 1050 | | |
1050 | 1051 | | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1051 | 1094 | | |
1052 | 1095 | | |
1053 | 1096 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
397 | 405 | | |
398 | 406 | | |
399 | 407 | | |
| |||
570 | 578 | | |
571 | 579 | | |
572 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
573 | 607 | | |
574 | 608 | | |
575 | 609 | | |
| |||
0 commit comments