Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory
まだ誰も着手していません。
評価
調査の方向性
src/code/InstallHelper.cs の InstallHelper.TryExtractToDirectory から始め、ディレクトリ作成と containment チェックのロジック周辺を確認します。entry.FullName がどのように destinationPath になるかを追跡し、ディレクトリやファイルに対する副作用が発生する前に containment がチェックされていることを検証します。完了条件は、containment によって拒否されたエントリがディレクトリを一切残さず、有効なエントリは引き続き通常どおり展開されることです。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C#
- スター
- 576
- フォーク
- 114
- 平均マージ
- 23時間 17分
- マージ済み PR(30日)
- 8
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PowerShell/PSResourceGet のほかの issue
-
feature_request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
PowerShell/PSResourceGet#2013 · コメント 3 件 ·
-
feature_request Needs-Triage
PowerShell/PSResourceGet#2057 · 担当者 1 名 ·
-
Needs-Triage
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
PowerShell/PSResourceGet#2055 ·
-
Needs-Triage
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
PowerShell/PSResourceGet#2054 ·
-
(dsc): Export ignores `--input` filter for `Repository` and `PSResourceList` on DSC 3.3.* or above オープンNeeds-Triage
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
PowerShell/PSResourceGet#2053 ·
PowerShell/PSResourceGet の issue をすべて見る
似ている issue
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
t/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
ci-failure-cause test-failure
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
area:auth FE mvp P3
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
klasolsson81/jobbliggaren#1788 ·