Skip to content

Commit

Permalink
add test for sync unzipping a zip-slip attack file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mostafa-Samir committed Dec 30, 2021
1 parent 6bb9b59 commit 949446a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unzip.sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ describe("Unzipping synchronously", function () {
zipper.sync.unzip("./tests/assets/hello.zip").save("./tests/assets/hello-sync-unzip/");
});

it("should raise an error when an entry is outside extraction path", function () {
fs.mkdirSync("./tests/assets/zip-slip-sync");
expect(
zipper.sync.unzip("./tests/assets/zip-slip.zip").save("./tests/assets/zip-slip-sync")
).to.throw("Entry is outside the extraction path")
});

it("checks if unzipped files on disk contain correct data", function (done) {

fs.readFile("./tests/assets/hello-sync-unzip/hello/says-hello", 'utf8', function (err, data) {
Expand Down

0 comments on commit 949446a

Please sign in to comment.