@@ -3,27 +3,27 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
33$zip = [System.IO.Compression.ZipFile ]::OpenRead(" MyPath\to\archive.zip" )
44
55foreach ($entry in $zip.Entries ) {
6- $targetPath = Join-Path $extractPath $entry.FullName
6+ $targetPath = Join-Path $extractPath $entry.FullName # $ Source
77 $fullTargetPath = [System.IO.Path ]::GetFullPath($targetPath )
88
9- [System.IO.Compression.ZipFileExtensions ]::ExtractToFile($entry , $fullTargetPath ) # BAD
9+ [System.IO.Compression.ZipFileExtensions ]::ExtractToFile($entry , $fullTargetPath ) # $ Alert
1010}
1111
1212foreach ($entry in $zip.Entries ) {
13- $targetPath = Join-Path $extractPath $entry.FullName
13+ $targetPath = Join-Path $extractPath $entry.FullName # $ Source
1414 $fullTargetPath = [System.IO.Path ]::GetFullPath($targetPath )
1515
16- $stream = [System.IO.File ]::Open($fullTargetPath , ' Create' ) # BAD
16+ $stream = [System.IO.File ]::Open($fullTargetPath , ' Create' ) # $ Alert
1717 $entry.Open ().CopyTo($stream )
1818 $stream.Close ()
1919}
2020
2121foreach ($entry in $zip.Entries ) {
22- $targetPath = Join-Path $extractPath $entry.FullName
22+ $targetPath = Join-Path $extractPath $entry.FullName # $ Source
2323 $fullTargetPath = [System.IO.Path ]::GetFullPath($targetPath )
2424
2525 $extractRoot = [System.IO.Path ]::GetFullPath($extractPath )
2626 if ($fullTargetPath.StartsWith ($extractRoot )) {
27- [System.IO.Compression.ZipFileExtensions ]::ExtractToFile($entry , $fullTargetPath ) # GOOD [FALSE POSITIVE]
27+ [System.IO.Compression.ZipFileExtensions ]::ExtractToFile($entry , $fullTargetPath ) # $ Alert
2828 }
2929}
0 commit comments