From 3a426e8982cc2f69cf59eceaa7032436fa0d16d8 Mon Sep 17 00:00:00 2001 From: Rajat Date: Fri, 21 Jan 2022 00:53:14 +0530 Subject: [PATCH 1/2] avoiding use of `util.inherits` --- lib/run/secure-fs.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/run/secure-fs.js b/lib/run/secure-fs.js index 9230336c2..f1a842a27 100644 --- a/lib/run/secure-fs.js +++ b/lib/run/secure-fs.js @@ -1,7 +1,6 @@ const fs = require('fs'), _ = require('lodash'), path = require('path'), - util = require('util'), Readable = require('stream').Readable, PPERM_ERR = 'PPERM: insecure file access outside working directory', @@ -166,19 +165,17 @@ SecureFS.prototype.createReadStream = function (path, options) { return this._fs.createReadStream(this.resolvePathSync(path), options); } catch (err) { - // Create a fake read steam that emits and error and - const ErrorReadStream = function () { - // Replicating behavior of fs module of disabling emitClose on destroy - Readable.call(this, { emitClose: false }); - - // Emit the error event with insure file access error - this.emit('error', new Error(PPERM_ERR)); - - // Options exists and disables autoClose then don't destroy - (options && !options.autoClose) || this.destroy(); - }; - - util.inherits(ErrorReadStream, Readable); + // Create a fake read stream that emits and error + class ErrorReadStream extends Readable { + constructor () { + // Replicating behavior of fs module of disabling emitClose on destroy + super({ emitClose: false }); + // Emit the error event with insure file access error + this.emit('error', new Error(PPERM_ERR)); + // Options exists and disables autoClose then don't destroy + (options && !options.autoClose) || this.destroy(); + } + } return new ErrorReadStream(); } From 457546f85e29f03aca936e53a47b10b716a3601b Mon Sep 17 00:00:00 2001 From: Rajat Date: Sat, 22 Jan 2022 12:38:14 +0530 Subject: [PATCH 2/2] re-triggering checks --- lib/run/secure-fs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/run/secure-fs.js b/lib/run/secure-fs.js index f1a842a27..d7c4f9d25 100644 --- a/lib/run/secure-fs.js +++ b/lib/run/secure-fs.js @@ -182,3 +182,4 @@ SecureFS.prototype.createReadStream = function (path, options) { }; module.exports = SecureFS; +