Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zip Slip Vulnerabilities #2847

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/shared.sc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def unpackZip(zipDest: os.Path, url: String) = {
case null => false
case entry =>
if (!entry.isDirectory) {
val dest = zipDest / os.RelPath(entry.getName)
val dest = zipDest / os.SubPath(entry.getName)
os.makeDir.all(dest / os.up)
val fileOut = new java.io.FileOutputStream(dest.toString)
val buffer = new Array[Byte](4096)
Expand Down
7 changes: 5 additions & 2 deletions main/api/src/mill/api/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ object IO extends StreamSupport {
* @param ctx The target context
* @return The [[PathRef]] to the unpacked folder.
*/
def unpackZip(src: os.Path, dest: os.RelPath = os.rel / "unpacked")(implicit
def unpackZip(
src: os.Path,
dest: os.RelPath = os.rel / "unpacked"
)(implicit
ctx: Ctx.Dest
): PathRef = {

Expand All @@ -24,7 +27,7 @@ object IO extends StreamSupport {
case null => false
case entry =>
if (!entry.isDirectory) {
val entryDest = ctx.dest / dest / os.RelPath(entry.getName)
val entryDest = ctx.dest / dest / os.SubPath(entry.getName)
os.makeDir.all(entryDest / os.up)
val fileOut = new java.io.FileOutputStream(entryDest.toString)
IO.stream(zipStream, fileOut)
Expand Down
Loading