diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 66bb2d6348..1c18cedcda 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -8027,9 +8027,10 @@ } }, "node_modules/tmp": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", - "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz", + "integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==", + "license": "MIT", "engines": { "node": ">=14.14" } diff --git a/node_modules/tmp/CHANGELOG.md b/node_modules/tmp/CHANGELOG.md deleted file mode 100644 index 0cdbc6b686..0000000000 --- a/node_modules/tmp/CHANGELOG.md +++ /dev/null @@ -1,304 +0,0 @@ - - -## v0.2.2 (2024-02-28) - -#### :bug: Bug Fix -* [#278](https://github.com/raszi/node-tmp/pull/278) Closes [#268](https://github.com/raszi/node-tmp/issues/268): Revert "fix #246: remove any double quotes or single quotes… ([@mbargiel](https://github.com/mbargiel)) - -#### :memo: Documentation -* [#279](https://github.com/raszi/node-tmp/pull/279) Closes [#266](https://github.com/raszi/node-tmp/issues/266): move paragraph on graceful cleanup to the head of the documentation ([@silkentrance](https://github.com/silkentrance)) - -#### Committers: 5 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- Dave Nicolson ([@dnicolson](https://github.com/dnicolson)) -- KARASZI István ([@raszi](https://github.com/raszi)) -- Maxime Bargiel ([@mbargiel](https://github.com/mbargiel)) -- [@robertoaceves](https://github.com/robertoaceves) - - -## v0.2.1 (2020-04-28) - -#### :rocket: Enhancement -* [#252](https://github.com/raszi/node-tmp/pull/252) Closes [#250](https://github.com/raszi/node-tmp/issues/250): introduce tmpdir option for overriding the system tmp dir ([@silkentrance](https://github.com/silkentrance)) - -#### :house: Internal -* [#253](https://github.com/raszi/node-tmp/pull/253) Closes [#191](https://github.com/raszi/node-tmp/issues/191): generate changelog from pull requests using lerna-changelog ([@silkentrance](https://github.com/silkentrance)) - -#### Committers: 1 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) - - -## v0.2.0 (2020-04-25) - -#### :rocket: Enhancement -* [#234](https://github.com/raszi/node-tmp/pull/234) feat: stabilize tmp for v0.2.0 release ([@silkentrance](https://github.com/silkentrance)) - -#### :bug: Bug Fix -* [#231](https://github.com/raszi/node-tmp/pull/231) Closes [#230](https://github.com/raszi/node-tmp/issues/230): regression after fix for #197 ([@silkentrance](https://github.com/silkentrance)) -* [#220](https://github.com/raszi/node-tmp/pull/220) Closes [#197](https://github.com/raszi/node-tmp/issues/197): return sync callback when using the sync interface, otherwise return the async callback ([@silkentrance](https://github.com/silkentrance)) -* [#193](https://github.com/raszi/node-tmp/pull/193) Closes [#192](https://github.com/raszi/node-tmp/issues/192): tmp must not exit the process on its own ([@silkentrance](https://github.com/silkentrance)) - -#### :memo: Documentation -* [#221](https://github.com/raszi/node-tmp/pull/221) Gh 206 document name option ([@silkentrance](https://github.com/silkentrance)) - -#### :house: Internal -* [#226](https://github.com/raszi/node-tmp/pull/226) Closes [#212](https://github.com/raszi/node-tmp/issues/212): enable direct name option test ([@silkentrance](https://github.com/silkentrance)) -* [#225](https://github.com/raszi/node-tmp/pull/225) Closes [#211](https://github.com/raszi/node-tmp/issues/211): existing tests must clean up after themselves ([@silkentrance](https://github.com/silkentrance)) -* [#224](https://github.com/raszi/node-tmp/pull/224) Closes [#217](https://github.com/raszi/node-tmp/issues/217): name tests must use tmpName ([@silkentrance](https://github.com/silkentrance)) -* [#223](https://github.com/raszi/node-tmp/pull/223) Closes [#214](https://github.com/raszi/node-tmp/issues/214): refactor tests and lib ([@silkentrance](https://github.com/silkentrance)) -* [#198](https://github.com/raszi/node-tmp/pull/198) Update dependencies to latest versions ([@matsev](https://github.com/matsev)) - -#### Committers: 2 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- Mattias Severson ([@matsev](https://github.com/matsev)) - - -## v0.1.0 (2019-03-20) - -#### :rocket: Enhancement -* [#177](https://github.com/raszi/node-tmp/pull/177) fix: fail early if there is no tmp dir specified ([@silkentrance](https://github.com/silkentrance)) -* [#159](https://github.com/raszi/node-tmp/pull/159) Closes [#121](https://github.com/raszi/node-tmp/issues/121) ([@silkentrance](https://github.com/silkentrance)) -* [#161](https://github.com/raszi/node-tmp/pull/161) Closes [#155](https://github.com/raszi/node-tmp/issues/155) ([@silkentrance](https://github.com/silkentrance)) -* [#166](https://github.com/raszi/node-tmp/pull/166) fix: avoid relying on Node’s internals ([@addaleax](https://github.com/addaleax)) -* [#144](https://github.com/raszi/node-tmp/pull/144) prepend opts.dir || tmpDir to template if no path is given ([@silkentrance](https://github.com/silkentrance)) - -#### :bug: Bug Fix -* [#183](https://github.com/raszi/node-tmp/pull/183) Closes [#182](https://github.com/raszi/node-tmp/issues/182) fileSync takes empty string postfix option ([@gutte](https://github.com/gutte)) -* [#130](https://github.com/raszi/node-tmp/pull/130) Closes [#129](https://github.com/raszi/node-tmp/issues/129) install process listeners safely ([@silkentrance](https://github.com/silkentrance)) - -#### :memo: Documentation -* [#188](https://github.com/raszi/node-tmp/pull/188) HOTCloses [#187](https://github.com/raszi/node-tmp/issues/187): restore behaviour for #182 ([@silkentrance](https://github.com/silkentrance)) -* [#180](https://github.com/raszi/node-tmp/pull/180) fix gh-179: template no longer accepts arbitrary paths ([@silkentrance](https://github.com/silkentrance)) -* [#175](https://github.com/raszi/node-tmp/pull/175) docs: add `unsafeCleanup` option to jsdoc ([@kerimdzhanov](https://github.com/kerimdzhanov)) -* [#151](https://github.com/raszi/node-tmp/pull/151) docs: fix link to tmp-promise ([@silkentrance](https://github.com/silkentrance)) - -#### :house: Internal -* [#184](https://github.com/raszi/node-tmp/pull/184) test: add missing tests for #182 ([@silkentrance](https://github.com/silkentrance)) -* [#171](https://github.com/raszi/node-tmp/pull/171) chore: drop old NodeJS support ([@poppinlp](https://github.com/poppinlp)) -* [#170](https://github.com/raszi/node-tmp/pull/170) chore: update dependencies ([@raszi](https://github.com/raszi)) -* [#165](https://github.com/raszi/node-tmp/pull/165) test: add missing tests ([@raszi](https://github.com/raszi)) -* [#163](https://github.com/raszi/node-tmp/pull/163) chore: add lint npm task ([@raszi](https://github.com/raszi)) -* [#107](https://github.com/raszi/node-tmp/pull/107) chore: add coverage report ([@raszi](https://github.com/raszi)) -* [#141](https://github.com/raszi/node-tmp/pull/141) test: refactor tests for mocha ([@silkentrance](https://github.com/silkentrance)) -* [#154](https://github.com/raszi/node-tmp/pull/154) chore: change Travis configuration ([@raszi](https://github.com/raszi)) -* [#152](https://github.com/raszi/node-tmp/pull/152) fix: drop Node v0.6.0 ([@raszi](https://github.com/raszi)) - -#### Committers: 6 -- Anna Henningsen ([@addaleax](https://github.com/addaleax)) -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- Dan Kerimdzhanov ([@kerimdzhanov](https://github.com/kerimdzhanov)) -- Gustav Klingstedt ([@gutte](https://github.com/gutte)) -- KARASZI István ([@raszi](https://github.com/raszi)) -- PoppinL ([@poppinlp](https://github.com/poppinlp)) - - -## v0.0.33 (2017-08-12) - -#### :rocket: Enhancement -* [#147](https://github.com/raszi/node-tmp/pull/147) fix: with name option try at most once to get a unique tmp name ([@silkentrance](https://github.com/silkentrance)) - -#### :bug: Bug Fix -* [#149](https://github.com/raszi/node-tmp/pull/149) fix(fileSync): must honor detachDescriptor and discardDescriptor options ([@silkentrance](https://github.com/silkentrance)) -* [#119](https://github.com/raszi/node-tmp/pull/119) Closes [#115](https://github.com/raszi/node-tmp/issues/115) ([@silkentrance](https://github.com/silkentrance)) - -#### :memo: Documentation -* [#128](https://github.com/raszi/node-tmp/pull/128) Closes [#127](https://github.com/raszi/node-tmp/issues/127) add reference to tmp-promise ([@silkentrance](https://github.com/silkentrance)) - -#### :house: Internal -* [#135](https://github.com/raszi/node-tmp/pull/135) Closes [#133](https://github.com/raszi/node-tmp/issues/133), #134 ([@silkentrance](https://github.com/silkentrance)) -* [#123](https://github.com/raszi/node-tmp/pull/123) docs: update tmp.js MIT license header to 2017 ([@madnight](https://github.com/madnight)) -* [#122](https://github.com/raszi/node-tmp/pull/122) chore: add issue template ([@silkentrance](https://github.com/silkentrance)) - -#### Committers: 2 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- Fabian Beuke ([@madnight](https://github.com/madnight)) - - -## v0.0.32 (2017-03-24) - -#### :memo: Documentation -* [#106](https://github.com/raszi/node-tmp/pull/106) doc: add proper JSDoc documentation ([@raszi](https://github.com/raszi)) - -#### :house: Internal -* [#111](https://github.com/raszi/node-tmp/pull/111) test: add Windows tests ([@binki](https://github.com/binki)) -* [#110](https://github.com/raszi/node-tmp/pull/110) chore: add AppVeyor ([@binki](https://github.com/binki)) -* [#105](https://github.com/raszi/node-tmp/pull/105) chore: use const where possible ([@raszi](https://github.com/raszi)) -* [#104](https://github.com/raszi/node-tmp/pull/104) style: fix various style issues ([@raszi](https://github.com/raszi)) - -#### Committers: 2 -- KARASZI István ([@raszi](https://github.com/raszi)) -- Nathan Phillip Brink ([@binki](https://github.com/binki)) - - -## v0.0.31 (2016-11-21) - -#### :rocket: Enhancement -* [#99](https://github.com/raszi/node-tmp/pull/99) feat: add next callback functionality ([@silkentrance](https://github.com/silkentrance)) -* [#94](https://github.com/raszi/node-tmp/pull/94) feat: add options to control descriptor management ([@pabigot](https://github.com/pabigot)) - -#### :house: Internal -* [#101](https://github.com/raszi/node-tmp/pull/101) fix: Include files in the package.json ([@raszi](https://github.com/raszi)) - -#### Committers: 3 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- KARASZI István ([@raszi](https://github.com/raszi)) -- Peter A. Bigot ([@pabigot](https://github.com/pabigot)) - - -## v0.0.30 (2016-11-01) - -#### :bug: Bug Fix -* [#96](https://github.com/raszi/node-tmp/pull/96) fix: constants for Node 6 ([@jnj16180340](https://github.com/jnj16180340)) -* [#98](https://github.com/raszi/node-tmp/pull/98) fix: garbage collector ([@Ari-H](https://github.com/Ari-H)) - -#### Committers: 2 -- Nate Johnson ([@jnj16180340](https://github.com/jnj16180340)) -- [@Ari-H](https://github.com/Ari-H) - - -## v0.0.29 (2016-09-18) - -#### :rocket: Enhancement -* [#87](https://github.com/raszi/node-tmp/pull/87) fix: replace calls to deprecated fs API functions ([@OlliV](https://github.com/OlliV)) - -#### :bug: Bug Fix -* [#70](https://github.com/raszi/node-tmp/pull/70) fix: prune `_removeObjects` correctly ([@joliss](https://github.com/joliss)) -* [#71](https://github.com/raszi/node-tmp/pull/71) Fix typo ([@gcampax](https://github.com/gcampax)) - -#### :memo: Documentation -* [#77](https://github.com/raszi/node-tmp/pull/77) docs: change mkstemps to mkstemp ([@thefourtheye](https://github.com/thefourtheye)) - -#### :house: Internal -* [#92](https://github.com/raszi/node-tmp/pull/92) chore: add Travis CI support for Node 6 ([@amilajack](https://github.com/amilajack)) -* [#79](https://github.com/raszi/node-tmp/pull/79) fix: remove unneeded require statement ([@whmountains](https://github.com/whmountains)) - -#### Committers: 6 -- Amila Welihinda ([@amilajack](https://github.com/amilajack)) -- Caleb Whiting ([@whmountains](https://github.com/whmountains)) -- Giovanni Campagna ([@gcampax](https://github.com/gcampax)) -- Jo Liss ([@joliss](https://github.com/joliss)) -- Olli Vanhoja ([@OlliV](https://github.com/OlliV)) -- Sakthipriyan Vairamani ([@thefourtheye](https://github.com/thefourtheye)) - - -## v0.0.28 (2015-09-27) - -#### :bug: Bug Fix -* [#63](https://github.com/raszi/node-tmp/pull/63) fix: delete for _rmdirRecursiveSync ([@voltrevo](https://github.com/voltrevo)) - -#### :memo: Documentation -* [#64](https://github.com/raszi/node-tmp/pull/64) docs: fix typo in the README ([@JTKnox91](https://github.com/JTKnox91)) - -#### :house: Internal -* [#67](https://github.com/raszi/node-tmp/pull/67) test: add node v4.0 v4.1 to travis config ([@raszi](https://github.com/raszi)) -* [#66](https://github.com/raszi/node-tmp/pull/66) chore(deps): update deps ([@raszi](https://github.com/raszi)) - -#### Committers: 3 -- Andrew Morris ([@voltrevo](https://github.com/voltrevo)) -- John T. Knox ([@JTKnox91](https://github.com/JTKnox91)) -- KARASZI István ([@raszi](https://github.com/raszi)) - - -## v0.0.27 (2015-08-15) - -#### :bug: Bug Fix -* [#60](https://github.com/raszi/node-tmp/pull/60) fix: unlinking when the file has been already removed ([@silkentrance](https://github.com/silkentrance)) - -#### :memo: Documentation -* [#55](https://github.com/raszi/node-tmp/pull/55) docs(README): update README ([@raszi](https://github.com/raszi)) - -#### :house: Internal -* [#56](https://github.com/raszi/node-tmp/pull/56) style(jshint): fix JSHint error ([@raszi](https://github.com/raszi)) -* [#53](https://github.com/raszi/node-tmp/pull/53) chore: update license attribute ([@pdehaan](https://github.com/pdehaan)) - -#### Committers: 3 -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- KARASZI István ([@raszi](https://github.com/raszi)) -- Peter deHaan ([@pdehaan](https://github.com/pdehaan)) - - -## v0.0.26 (2015-05-12) - -#### :rocket: Enhancement -* [#40](https://github.com/raszi/node-tmp/pull/40) Fix for #39 ([@silkentrance](https://github.com/silkentrance)) -* [#42](https://github.com/raszi/node-tmp/pull/42) Fix for #17 ([@silkentrance](https://github.com/silkentrance)) -* [#41](https://github.com/raszi/node-tmp/pull/41) Fix for #37 ([@silkentrance](https://github.com/silkentrance)) -* [#32](https://github.com/raszi/node-tmp/pull/32) add ability to customize file/dir names ([@shime](https://github.com/shime)) -* [#29](https://github.com/raszi/node-tmp/pull/29) tmp.file have responsibility to close file, not only unlink file ([@vhain](https://github.com/vhain)) - -#### :bug: Bug Fix -* [#51](https://github.com/raszi/node-tmp/pull/51) fix(windows): fix tempDir on windows ([@raszi](https://github.com/raszi)) -* [#49](https://github.com/raszi/node-tmp/pull/49) remove object from _removeObjects if cleanup fn is called Closes [#48](https://github.com/raszi/node-tmp/issues/48) ([@bmeck](https://github.com/bmeck)) - -#### :memo: Documentation -* [#45](https://github.com/raszi/node-tmp/pull/45) Fix for #44 ([@silkentrance](https://github.com/silkentrance)) - -#### :house: Internal -* [#34](https://github.com/raszi/node-tmp/pull/34) Create LICENSE ([@ScottWeinstein](https://github.com/ScottWeinstein)) - -#### Committers: 6 -- Bradley Farias ([@bmeck](https://github.com/bmeck)) -- Carsten Klein ([@silkentrance](https://github.com/silkentrance)) -- Hrvoje Šimić ([@shime](https://github.com/shime)) -- Juwan Yoo ([@vhain](https://github.com/vhain)) -- KARASZI István ([@raszi](https://github.com/raszi)) -- Scott Weinstein ([@ScottWeinstein](https://github.com/ScottWeinstein)) - - -## v0.0.24 (2014-07-11) - -#### :rocket: Enhancement -* [#25](https://github.com/raszi/node-tmp/pull/25) Added removeCallback passing ([@foxel](https://github.com/foxel)) - -#### Committers: 1 -- Andrey Kupreychik ([@foxel](https://github.com/foxel)) - - -## v0.0.23 (2013-12-03) - -#### :rocket: Enhancement -* [#21](https://github.com/raszi/node-tmp/pull/21) If we are not on node 0.8, don't register an uncaughtException handler ([@wibblymat](https://github.com/wibblymat)) - -#### Committers: 1 -- Mat Scales ([@wibblymat](https://github.com/wibblymat)) - - -## v0.0.22 (2013-11-29) - -#### :rocket: Enhancement -* [#19](https://github.com/raszi/node-tmp/pull/19) Rethrow only on node v0.8. ([@mcollina](https://github.com/mcollina)) - -#### Committers: 1 -- Matteo Collina ([@mcollina](https://github.com/mcollina)) - - -## v0.0.21 (2013-08-07) - -#### :bug: Bug Fix -* [#16](https://github.com/raszi/node-tmp/pull/16) Fix bug where we delete contents of symlinks ([@lightsofapollo](https://github.com/lightsofapollo)) - -#### Committers: 1 -- James Lal ([@lightsofapollo](https://github.com/lightsofapollo)) - - -## v0.0.17 (2013-04-09) - -#### :rocket: Enhancement -* [#9](https://github.com/raszi/node-tmp/pull/9) add recursive remove option ([@oscar-broman](https://github.com/oscar-broman)) - -#### Committers: 1 -- [@oscar-broman](https://github.com/oscar-broman) - - -## v0.0.14 (2012-08-26) - -#### :rocket: Enhancement -* [#5](https://github.com/raszi/node-tmp/pull/5) Export _getTmpName for temporary file name creation ([@joscha](https://github.com/joscha)) - -#### Committers: 1 -- Joscha Feth ([@joscha](https://github.com/joscha)) - - -## Previous Releases < v0.0.14 - -- no information available diff --git a/node_modules/tmp/lib/tmp.js b/node_modules/tmp/lib/tmp.js index 84aa1c5ed3..162dca1f93 100644 --- a/node_modules/tmp/lib/tmp.js +++ b/node_modules/tmp/lib/tmp.js @@ -18,34 +18,24 @@ const _c = { fs: fs.constants, os: os.constants }; /* * The working inner variables. */ -const - // the random characters to choose from +const // the random characters to choose from RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', - TEMPLATE_PATTERN = /XXXXXX/, - DEFAULT_TRIES = 3, - CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), - // constants are off on the windows platform and will not match the actual errno codes IS_WIN32 = os.platform() === 'win32', EBADF = _c.EBADF || _c.os.errno.EBADF, ENOENT = _c.ENOENT || _c.os.errno.ENOENT, - DIR_MODE = 0o700 /* 448 */, FILE_MODE = 0o600 /* 384 */, - EXIT = 'exit', - // this will hold the objects need to be removed on exit _removeObjects = [], - // API change in fs.rmdirSync leads to error when passing in a second parameter, e.g. the callback FN_RMDIR_SYNC = fs.rmdirSync.bind(fs); -let - _gracefulCleanup = false; +let _gracefulCleanup = false; /** * Recursively remove a directory and its contents. @@ -75,38 +65,35 @@ function FN_RIMRAF_SYNC(dirPath) { * @param {?tmpNameCallback} callback the callback function */ function tmpName(options, callback) { - const - args = _parseArguments(options, callback), + const args = _parseArguments(options, callback), opts = args[0], cb = args[1]; - try { - _assertAndSanitizeOptions(opts); - } catch (err) { - return cb(err); - } + _assertAndSanitizeOptions(opts, function (err, sanitizedOptions) { + if (err) return cb(err); - let tries = opts.tries; - (function _getUniqueName() { - try { - const name = _generateTmpName(opts); + let tries = sanitizedOptions.tries; + (function _getUniqueName() { + try { + const name = _generateTmpName(sanitizedOptions); - // check whether the path exists then retry if needed - fs.stat(name, function (err) { - /* istanbul ignore else */ - if (!err) { + // check whether the path exists then retry if needed + fs.stat(name, function (err) { /* istanbul ignore else */ - if (tries-- > 0) return _getUniqueName(); + if (!err) { + /* istanbul ignore else */ + if (tries-- > 0) return _getUniqueName(); - return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name)); - } + return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name)); + } - cb(null, name); - }); - } catch (err) { - cb(err); - } - }()); + cb(null, name); + }); + } catch (err) { + cb(err); + } + })(); + }); } /** @@ -117,15 +104,14 @@ function tmpName(options, callback) { * @throws {Error} if the options are invalid or could not generate a filename */ function tmpNameSync(options) { - const - args = _parseArguments(options), + const args = _parseArguments(options), opts = args[0]; - _assertAndSanitizeOptions(opts); + const sanitizedOptions = _assertAndSanitizeOptionsSync(opts); - let tries = opts.tries; + let tries = sanitizedOptions.tries; do { - const name = _generateTmpName(opts); + const name = _generateTmpName(sanitizedOptions); try { fs.statSync(name); } catch (e) { @@ -143,8 +129,7 @@ function tmpNameSync(options) { * @param {?fileCallback} callback */ function file(options, callback) { - const - args = _parseArguments(options, callback), + const args = _parseArguments(options, callback), opts = args[0], cb = args[1]; @@ -181,13 +166,12 @@ function file(options, callback) { * @throws {Error} if cannot create a file */ function fileSync(options) { - const - args = _parseArguments(options), + const args = _parseArguments(options), opts = args[0]; const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor; const name = tmpNameSync(opts); - var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); + let fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); /* istanbul ignore else */ if (opts.discardDescriptor) { fs.closeSync(fd); @@ -208,8 +192,7 @@ function fileSync(options) { * @param {?dirCallback} callback */ function dir(options, callback) { - const - args = _parseArguments(options, callback), + const args = _parseArguments(options, callback), opts = args[0], cb = args[1]; @@ -236,8 +219,7 @@ function dir(options, callback) { * @throws {Error} if it cannot create a directory */ function dirSync(options) { - const - args = _parseArguments(options), + const args = _parseArguments(options), opts = args[0]; const name = tmpNameSync(opts); @@ -288,8 +270,7 @@ function _removeFileSync(fdPath) { } finally { try { fs.unlinkSync(fdPath[1]); - } - catch (e) { + } catch (e) { // reraise any unanticipated error if (!_isENOENT(e)) rethrownException = e; } @@ -361,7 +342,6 @@ function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCall // if sync is true, the next parameter will be ignored return function _cleanupCallback(next) { - /* istanbul ignore else */ if (!called) { // remove cleanupCallback from cache @@ -374,7 +354,7 @@ function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCall if (sync || removeFunction === FN_RMDIR_SYNC || removeFunction === FN_RIMRAF_SYNC) { return removeFunction(fileOrDirName); } else { - return removeFunction(fileOrDirName, next || function() {}); + return removeFunction(fileOrDirName, next || function () {}); } } }; @@ -409,8 +389,7 @@ function _garbageCollector() { * @private */ function _randomChars(howMany) { - let - value = [], + let value = [], rnd = null; // make sure that we do not fail because we ran out of entropy @@ -420,24 +399,13 @@ function _randomChars(howMany) { rnd = crypto.pseudoRandomBytes(howMany); } - for (var i = 0; i < howMany; i++) { + for (let i = 0; i < howMany; i++) { value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]); } return value.join(''); } -/** - * Helper which determines whether a string s is blank, that is undefined, or empty or null. - * - * @private - * @param {string} s - * @returns {Boolean} true whether the string s is blank, false otherwise - */ -function _isBlank(s) { - return s === null || _isUndefined(s) || !s.trim(); -} - /** * Checks whether the `obj` parameter is defined or not. * @@ -479,6 +447,51 @@ function _parseArguments(options, callback) { return [actualOptions, callback]; } +/** + * Resolve the specified path name in respect to tmpDir. + * + * The specified name might include relative path components, e.g. ../ + * so we need to resolve in order to be sure that is is located inside tmpDir + * + * @private + */ +function _resolvePath(name, tmpDir, cb) { + const pathToResolve = path.isAbsolute(name) ? name : path.join(tmpDir, name); + + fs.stat(pathToResolve, function (err) { + if (err) { + fs.realpath(path.dirname(pathToResolve), function (err, parentDir) { + if (err) return cb(err); + + cb(null, path.join(parentDir, path.basename(pathToResolve))); + }); + } else { + fs.realpath(path, cb); + } + }); +} + +/** + * Resolve the specified path name in respect to tmpDir. + * + * The specified name might include relative path components, e.g. ../ + * so we need to resolve in order to be sure that is is located inside tmpDir + * + * @private + */ +function _resolvePathSync(name, tmpDir) { + const pathToResolve = path.isAbsolute(name) ? name : path.join(tmpDir, name); + + try { + fs.statSync(pathToResolve); + return fs.realpathSync(pathToResolve); + } catch (_err) { + const parentDir = fs.realpathSync(path.dirname(pathToResolve)); + + return path.join(parentDir, path.basename(pathToResolve)); + } +} + /** * Generates a new temporary name. * @@ -487,16 +500,17 @@ function _parseArguments(options, callback) { * @private */ function _generateTmpName(opts) { - const tmpDir = opts.tmpdir; /* istanbul ignore else */ - if (!_isUndefined(opts.name)) + if (!_isUndefined(opts.name)) { return path.join(tmpDir, opts.dir, opts.name); + } /* istanbul ignore else */ - if (!_isUndefined(opts.template)) + if (!_isUndefined(opts.template)) { return path.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6)); + } // prefix and postfix const name = [ @@ -512,33 +526,32 @@ function _generateTmpName(opts) { } /** - * Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing - * options. + * Asserts and sanitizes the basic options. * - * @param {Options} options * @private */ -function _assertAndSanitizeOptions(options) { +function _assertOptionsBase(options) { + if (!_isUndefined(options.name)) { + const name = options.name; - options.tmpdir = _getTmpDir(options); + // assert that name is not absolute and does not contain a path + if (path.isAbsolute(name)) throw new Error(`name option must not contain an absolute path, found "${name}".`); - const tmpDir = options.tmpdir; + // must not fail on valid . or .. or similar such constructs + const basename = path.basename(name); + if (basename === '..' || basename === '.' || basename !== name) + throw new Error(`name option must not contain a path, found "${name}".`); + } /* istanbul ignore else */ - if (!_isUndefined(options.name)) - _assertIsRelative(options.name, 'name', tmpDir); - /* istanbul ignore else */ - if (!_isUndefined(options.dir)) - _assertIsRelative(options.dir, 'dir', tmpDir); - /* istanbul ignore else */ - if (!_isUndefined(options.template)) { - _assertIsRelative(options.template, 'template', tmpDir); - if (!options.template.match(TEMPLATE_PATTERN)) - throw new Error(`Invalid template, found "${options.template}".`); + if (!_isUndefined(options.template) && !options.template.match(TEMPLATE_PATTERN)) { + throw new Error(`Invalid template, found "${options.template}".`); } + /* istanbul ignore else */ - if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0) + if ((!_isUndefined(options.tries) && isNaN(options.tries)) || options.tries < 0) { throw new Error(`Invalid tries, found "${options.tries}".`); + } // if a name was specified we will try once options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1; @@ -547,65 +560,103 @@ function _assertAndSanitizeOptions(options) { options.discardDescriptor = !!options.discardDescriptor; options.unsafeCleanup = !!options.unsafeCleanup; - // sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to - options.dir = _isUndefined(options.dir) ? '' : path.relative(tmpDir, _resolvePath(options.dir, tmpDir)); - options.template = _isUndefined(options.template) ? undefined : path.relative(tmpDir, _resolvePath(options.template, tmpDir)); - // sanitize further if template is relative to options.dir - options.template = _isBlank(options.template) ? undefined : path.relative(options.dir, options.template); - // for completeness' sake only, also keep (multiple) blanks if the user, purportedly sane, requests us to - options.name = _isUndefined(options.name) ? undefined : options.name; options.prefix = _isUndefined(options.prefix) ? '' : options.prefix; options.postfix = _isUndefined(options.postfix) ? '' : options.postfix; } /** - * Resolve the specified path name in respect to tmpDir. + * Gets the relative directory to tmpDir. * - * The specified name might include relative path components, e.g. ../ - * so we need to resolve in order to be sure that is is located inside tmpDir + * @private + */ +function _getRelativePath(option, name, tmpDir, cb) { + if (_isUndefined(name)) return cb(null); + + _resolvePath(name, tmpDir, function (err, resolvedPath) { + if (err) return cb(err); + + const relativePath = path.relative(tmpDir, resolvedPath); + + if (!resolvedPath.startsWith(tmpDir)) { + return cb(new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`)); + } + + cb(null, relativePath); + }); +} + +/** + * Gets the relative path to tmpDir. * - * @param name - * @param tmpDir - * @returns {string} * @private */ -function _resolvePath(name, tmpDir) { - if (name.startsWith(tmpDir)) { - return path.resolve(name); - } else { - return path.resolve(path.join(tmpDir, name)); +function _getRelativePathSync(option, name, tmpDir) { + if (_isUndefined(name)) return; + + const resolvedPath = _resolvePathSync(name, tmpDir); + const relativePath = path.relative(tmpDir, resolvedPath); + + if (!resolvedPath.startsWith(tmpDir)) { + throw new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`); } + + return relativePath; } /** - * Asserts whether specified name is relative to the specified tmpDir. + * Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing + * options. * - * @param {string} name - * @param {string} option - * @param {string} tmpDir - * @throws {Error} * @private */ -function _assertIsRelative(name, option, tmpDir) { - if (option === 'name') { - // assert that name is not absolute and does not contain a path - if (path.isAbsolute(name)) - throw new Error(`${option} option must not contain an absolute path, found "${name}".`); - // must not fail on valid . or .. or similar such constructs - let basename = path.basename(name); - if (basename === '..' || basename === '.' || basename !== name) - throw new Error(`${option} option must not contain a path, found "${name}".`); - } - else { // if (option === 'dir' || option === 'template') { - // assert that dir or template are relative to tmpDir - if (path.isAbsolute(name) && !name.startsWith(tmpDir)) { - throw new Error(`${option} option must be relative to "${tmpDir}", found "${name}".`); +function _assertAndSanitizeOptions(options, cb) { + _getTmpDir(options, function (err, tmpDir) { + if (err) return cb(err); + + options.tmpdir = tmpDir; + + try { + _assertOptionsBase(options, tmpDir); + } catch (err) { + return cb(err); } - let resolvedPath = _resolvePath(name, tmpDir); - if (!resolvedPath.startsWith(tmpDir)) - throw new Error(`${option} option must be relative to "${tmpDir}", found "${resolvedPath}".`); - } + + // sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to + _getRelativePath('dir', options.dir, tmpDir, function (err, dir) { + if (err) return cb(err); + + options.dir = _isUndefined(dir) ? '' : dir; + + // sanitize further if template is relative to options.dir + _getRelativePath('template', options.template, tmpDir, function (err, template) { + if (err) return cb(err); + + options.template = template; + + cb(null, options); + }); + }); + }); +} + +/** + * Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing + * options. + * + * @private + */ +function _assertAndSanitizeOptionsSync(options) { + const tmpDir = (options.tmpdir = _getTmpDirSync(options)); + + _assertOptionsBase(options, tmpDir); + + const dir = _getRelativePathSync('dir', options.dir, tmpDir); + options.dir = _isUndefined(dir) ? '' : dir; + + options.template = _getRelativePathSync('template', options.template, tmpDir); + + return options; } /** @@ -663,11 +714,18 @@ function setGracefulCleanup() { * Returns the currently configured tmp dir from os.tmpdir(). * * @private - * @param {?Options} options - * @returns {string} the currently configured tmp dir */ -function _getTmpDir(options) { - return path.resolve(options && options.tmpdir || os.tmpdir()); +function _getTmpDir(options, cb) { + return fs.realpath((options && options.tmpdir) || os.tmpdir(), cb); +} + +/** + * Returns the currently configured tmp dir from os.tmpdir(). + * + * @private + */ +function _getTmpDirSync(options) { + return fs.realpathSync((options && options.tmpdir) || os.tmpdir()); } // Install process exit listener @@ -768,7 +826,7 @@ Object.defineProperty(module.exports, 'tmpdir', { enumerable: true, configurable: false, get: function () { - return _getTmpDir(); + return _getTmpDirSync(); } }); diff --git a/node_modules/tmp/package.json b/node_modules/tmp/package.json index 1efd85fad5..a5fd787809 100644 --- a/node_modules/tmp/package.json +++ b/node_modules/tmp/package.json @@ -1,8 +1,8 @@ { "name": "tmp", - "version": "0.2.3", + "version": "0.2.4", "description": "Temporary file and directory creator", - "author": "KARASZI István (http://raszi.hu/)", + "author": "KARASZI István ", "contributors": [ "Carsten Klein (https://github.com/silkentrance)" ], diff --git a/package-lock.json b/package-lock.json index 7c1d216b2b..921186fefd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8095,9 +8095,10 @@ } }, "node_modules/tmp": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", - "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz", + "integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==", + "license": "MIT", "engines": { "node": ">=14.14" }