Commit 4b1a13f
committed
address review round 7: post-create resolve, mkdir error wrap, more payloads
Production:
- Wrap the entire ancestor validation/create loop in OSError handling
so create-time races (PermissionError, EEXIST from another process)
surface as a clean CLI error instead of an unhandled exception.
- Re-resolve every newly created component against project_root_resolved
too (not just existing ones). A parent swapped to a junction / mount
point / symlink during creation can land the new directory outside the
project even when the new component itself is not a symlink. Mirrors
shared_infra._ensure_safe_shared_directory:115-118.
- Add a final 'download_dir.resolve() under project_root_resolved' guard
immediately before opening the ZIP. Defends the Windows fallback path
of _safe_open_download_zip (no dir_fd/O_NOFOLLOW) against an ancestor
swap between validation and write that the existing
zip_path.resolve().relative_to(download_dir.resolve()) check would
silently follow.
Tests:
- Add deep relative traversal payload (../../../../../etc/shadow) that
escapes from the 4-level cache directory all the way past project_root.
- Add Windows-relevant absolute payloads: C:\tmp\evil, C:/tmp/evil,
and \\server\share\evil. CI runs these on windows-latest.
- Extract _is_absolute_like() helper covering POSIX absolute, Windows
drive-letter, and UNC roots; use it to filter the delete-side test so
sentinel creation never escapes the pytest sandbox on any platform.1 parent db4e3b3 commit 4b1a13f
2 files changed
Lines changed: 80 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3687 | 3687 | | |
3688 | 3688 | | |
3689 | 3689 | | |
3690 | | - | |
3691 | | - | |
3692 | | - | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
3693 | 3695 | | |
3694 | 3696 | | |
3695 | 3697 | | |
3696 | | - | |
3697 | | - | |
3698 | | - | |
3699 | | - | |
3700 | | - | |
3701 | | - | |
3702 | | - | |
3703 | | - | |
3704 | | - | |
3705 | | - | |
3706 | | - | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
3707 | 3720 | | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
3708 | 3725 | | |
3709 | 3726 | | |
3710 | 3727 | | |
3711 | 3728 | | |
3712 | 3729 | | |
3713 | | - | |
3714 | | - | |
3715 | | - | |
3716 | | - | |
3717 | | - | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
3718 | 3735 | | |
3719 | 3736 | | |
3720 | 3737 | | |
3721 | 3738 | | |
3722 | 3739 | | |
3723 | 3740 | | |
3724 | | - | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
3725 | 3753 | | |
3726 | 3754 | | |
3727 | 3755 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
42 | 59 | | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
46 | 63 | | |
47 | 64 | | |
48 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
49 | 76 | | |
50 | 77 | | |
51 | 78 | | |
| |||
85 | 112 | | |
86 | 113 | | |
87 | 114 | | |
88 | | - | |
| 115 | + | |
89 | 116 | | |
90 | 117 | | |
91 | 118 | | |
92 | | - | |
93 | | - | |
94 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
95 | 123 | | |
96 | 124 | | |
97 | 125 | | |
| |||
0 commit comments