Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu trong src/code/InstallHelper.cs tại InstallHelper.TryExtractToDirectory, xung quanh logic tạo thư mục và kiểm tra containment. Theo dõi cách entry.FullName trở thành destinationPath và xác minh rằng containment được kiểm tra trước mọi side effect đối với thư mục hoặc tệp. Hoàn thành nghĩa là các entry bị từ chối do kiểm tra containment không để lại thư mục nào, trong khi các entry hợp lệ vẫn được giải nén bình thường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary of the new feature / enhancement
During package extraction, entry-derived parent directories are created before the path-containment decision runs. An entry whose file write the containment check would reject can still leave empty directories outside the extraction root (directory-only effect — no file content is written outside). As a user, I want each entry's extraction side effects to be all-or-nothing, so a malformed package cannot leave stray directories anywhere on disk.
Proposed technical implementation details
In src/code/InstallHelper.cs, TryExtractToDirectory (~L1299 on current main):
- For entries containing a path separator,
Directory.CreateDirectory(Path.Combine(extractPath, parentDirs))runs first (~L1372-1377), using the raw entry prefix. - Only afterwards is
destinationPath = Path.GetFullPath(Path.Combine(extractPath, entry.FullName))computed and theStartsWith(extractPath)containment verified (~L1381-1386) — and that check gates only theExtractToFilecall (~L1388).
So a package containing an entry such as ../../../../empty/dir/x (this loop is reached on installs from HTTP repositories, which do not go through a BCL extraction up front) creates empty/dir relative to the extraction temp directory as empty directories, and then the file write is skipped by the containment check.
Suggested reordering, so containment gates every side effect:
- Compute
destinationPath = Path.GetFullPath(Path.Combine(extractPath, entry.FullName))first. - Verify containment of
destinationPathunderextractPath. - Only then create
Path.GetDirectoryName(destinationPath)and callExtractToFile. - Skip entries that fail containment entirely — no partial side effects.
This also makes directory creation consistent with the resolved path rather than the raw entry string.
- Ngôn ngữ chính
- C#
- Star
- 576
- Fork
- 114
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PowerShell/PSResourceGet
-
feature_request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PowerShell/PSResourceGet#2013 · 3 bình luận ·
-
Needs-Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PowerShell/PSResourceGet#2055 ·
-
Needs-Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PowerShell/PSResourceGet#2054 ·
-
(dsc): Export ignores `--input` filter for `Repository` and `PSResourceList` on DSC 3.3.* or above Đang mởNeeds-Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PowerShell/PSResourceGet#2053 ·
-
feature_request Needs-Triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 64/100
PowerShell/PSResourceGet#2052 ·
Tất cả issue của PowerShell/PSResourceGet
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
azurenoops/spin_agent#975 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SubtitleEdit/subtitleedit#15108 · 1 bình luận ·