Commit f43e2ce
committed
address review round 5: ancestor-resolves-outside check + TOCTOU-safe write
- Per-component walk now also re-resolves each existing ancestor and
requires it to land under project_root.resolve(). This catches
non-symlink directory aliases (e.g. Windows junctions / mount points)
that resolve outside the project even though no component is itself
a symlink.
- ZIP write now uses os.open(O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0o600).
O_NOFOLLOW (POSIX) refuses a symlink swapped in between the cache
validation and the write, closing the TOCTOU window. O_EXCL guarantees
the unique UUID filename is freshly created and cannot be pre-staged.
O_NOFOLLOW falls back to 0 on Windows.
- Add TestExtensionAddFromAncestorEscape: simulates a junction-like
alias by patching Path.resolve() so .cache resolves outside; command
must refuse with 'escapes project root'.
- Add TestExtensionAddFromTOCTOUWrite: races a symlink swap into the
cache between validation and write; O_NOFOLLOW/O_EXCL must reject.1 parent 77b083c commit f43e2ce
2 files changed
Lines changed: 117 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3646 | 3646 | | |
3647 | 3647 | | |
3648 | 3648 | | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
3649 | 3652 | | |
3650 | 3653 | | |
| 3654 | + | |
3651 | 3655 | | |
3652 | 3656 | | |
3653 | 3657 | | |
3654 | 3658 | | |
3655 | 3659 | | |
3656 | 3660 | | |
3657 | | - | |
3658 | | - | |
3659 | | - | |
3660 | | - | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
3661 | 3666 | | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
3662 | 3672 | | |
3663 | 3673 | | |
3664 | 3674 | | |
| |||
3676 | 3686 | | |
3677 | 3687 | | |
3678 | 3688 | | |
3679 | | - | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
3680 | 3707 | | |
3681 | 3708 | | |
3682 | 3709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
0 commit comments