Skip to content

Commit

Permalink
Stop using the vulnerable unzip dev dependency (#1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Aug 7, 2019
1 parent fbe7d23 commit a20c098
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -107,7 +107,6 @@
"pngjs": "^3.3.1",
"pre-commit": "^1.1.3",
"sinon": "^7.2.4",
"unzip": "^0.1.11",
"wd": "^1.5.0"
},
"greenkeeper": {
Expand Down
39 changes: 16 additions & 23 deletions test/functional/basic/file-movement-e2e-specs.js
@@ -1,10 +1,9 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import B from 'bluebird';
import stream from 'stream';
import unzip from 'unzip';
import { UICATALOG_CAPS } from '../desired';
import { initSession, deleteSession, MOCHA_TIMEOUT } from '../helpers/session';
import { fs, tempDir, zip } from 'appium-support';
import path from 'path';


chai.should();
Expand Down Expand Up @@ -67,26 +66,20 @@ if (!process.env.REAL_DEVICE && !process.env.CLOUD) {
});

it('should pull all the files in Library/AddressBook', async function () {
let entryCount = 0;
let remotePath = `Library/AddressBook`;
let data = await driver.pullFolder(remotePath);
await new B((resolve) => {
let zipStream = new stream.Readable();
zipStream._read = function noop () {};
zipStream
.pipe(unzip.Parse())
.on('entry', function (entry) {
entryCount++;
entry.autodrain();
})
.on('close', function () {
entryCount.should.be.above(1);
resolve();
});

zipStream.push(data, 'base64');
zipStream.push(null);
});
const remotePath = `Library/AddressBook`;
const data = await driver.pullFolder(remotePath);
const tmpRoot = await tempDir.openDir();
try {
const zipPath = path.resolve(tmpRoot, 'data.zip');
const extractedDataPath = path.resolve(tmpRoot, 'extracted_data');
await fs.writeFile(zipPath, Buffer.from(data, 'base64'));
await fs.mkdir(extractedDataPath);
await zip.extractAllTo(zipPath, extractedDataPath);
const itemsCount = (await fs.readdir(extractedDataPath)).length;
itemsCount.should.be.above(1);
} finally {
await fs.rimraf(tmpRoot);
}
});
});
});
Expand Down

0 comments on commit a20c098

Please sign in to comment.