snyk 1.694.0 → 1.695.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -64214,6 +64214,2650 @@ function lexSort (a, b) {
64214
64214
  }
64215
64215
 
64216
64216
 
64217
+ /***/ }),
64218
+
64219
+ /***/ 55285:
64220
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64221
+
64222
+ const Utils = __webpack_require__(85173);
64223
+ const pth = __webpack_require__(85622);
64224
+ const ZipEntry = __webpack_require__(47396);
64225
+ const ZipFile = __webpack_require__(56333);
64226
+
64227
+ const fs = Utils.FileSystem.require();
64228
+ fs.existsSync = fs.existsSync || pth.existsSync;
64229
+
64230
+ const defaultOptions = {
64231
+ // read entries during load (initial loading may be slower)
64232
+ readEntries: false,
64233
+ // default method is none
64234
+ method: Utils.Constants.NONE
64235
+ }
64236
+
64237
+ function canonical(p) {
64238
+ // trick normalize think path is absolute
64239
+ var safeSuffix = pth.posix.normalize("/" + p.split("\\").join("/"));
64240
+ return pth.join(".", safeSuffix);
64241
+ }
64242
+
64243
+ module.exports = function (/**String*/input, /** object */options) {
64244
+ let inBuffer = null;
64245
+
64246
+ // create object based default options, allowing them to be overwritten
64247
+ const opts = Object.assign(Object.create( null ), defaultOptions);
64248
+
64249
+ // test input variable
64250
+ if (input && "object" === typeof input){
64251
+ // if value is not buffer we accept it to be object with options
64252
+ if (!(input instanceof Uint8Array)){
64253
+ Object.assign(opts, input);
64254
+ input = opts.input ? opts.input : undefined;
64255
+ if (opts.input) delete opts.input;
64256
+ }
64257
+
64258
+ // if input is buffer
64259
+ if (input instanceof Uint8Array){
64260
+ inBuffer = input;
64261
+ opts.method = Utils.Constants.BUFFER;
64262
+ input = undefined;
64263
+ }
64264
+ }
64265
+
64266
+ // assign options
64267
+ Object.assign(opts, options);
64268
+
64269
+ // if input is file name we retrieve its content
64270
+ if (input && "string" === typeof input) {
64271
+ // load zip file
64272
+ if (fs.existsSync(input)) {
64273
+ opts.method = Utils.Constants.FILE;
64274
+ opts.filename = input;
64275
+ inBuffer = fs.readFileSync(input);
64276
+ } else {
64277
+ throw new Error(Utils.Errors.INVALID_FILENAME);
64278
+ }
64279
+ }
64280
+
64281
+ // create variable
64282
+ const _zip = new ZipFile(inBuffer, opts);
64283
+
64284
+ function sanitize(prefix, name) {
64285
+ prefix = pth.resolve(pth.normalize(prefix));
64286
+ var parts = name.split('/');
64287
+ for (var i = 0, l = parts.length; i < l; i++) {
64288
+ var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
64289
+ if (path.indexOf(prefix) === 0) {
64290
+ return path;
64291
+ }
64292
+ }
64293
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
64294
+ }
64295
+
64296
+ function getEntry(/**Object*/entry) {
64297
+ if (entry && _zip) {
64298
+ var item;
64299
+ // If entry was given as a file name
64300
+ if (typeof entry === "string")
64301
+ item = _zip.getEntry(entry);
64302
+ // if entry was given as a ZipEntry object
64303
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
64304
+ item = _zip.getEntry(entry.entryName);
64305
+
64306
+ if (item) {
64307
+ return item;
64308
+ }
64309
+ }
64310
+ return null;
64311
+ }
64312
+
64313
+ function fixPath(zipPath){
64314
+ const { join, normalize, sep } = pth.posix;
64315
+ // convert windows file separators and normalize
64316
+ return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
64317
+ }
64318
+
64319
+ return {
64320
+ /**
64321
+ * Extracts the given entry from the archive and returns the content as a Buffer object
64322
+ * @param entry ZipEntry object or String with the full path of the entry
64323
+ *
64324
+ * @return Buffer or Null in case of error
64325
+ */
64326
+ readFile: function (/**Object*/entry, /*String, Buffer*/pass) {
64327
+ var item = getEntry(entry);
64328
+ return item && item.getData(pass) || null;
64329
+ },
64330
+
64331
+ /**
64332
+ * Asynchronous readFile
64333
+ * @param entry ZipEntry object or String with the full path of the entry
64334
+ * @param callback
64335
+ *
64336
+ * @return Buffer or Null in case of error
64337
+ */
64338
+ readFileAsync: function (/**Object*/entry, /**Function*/callback) {
64339
+ var item = getEntry(entry);
64340
+ if (item) {
64341
+ item.getDataAsync(callback);
64342
+ } else {
64343
+ callback(null, "getEntry failed for:" + entry)
64344
+ }
64345
+ },
64346
+
64347
+ /**
64348
+ * Extracts the given entry from the archive and returns the content as plain text in the given encoding
64349
+ * @param entry ZipEntry object or String with the full path of the entry
64350
+ * @param encoding Optional. If no encoding is specified utf8 is used
64351
+ *
64352
+ * @return String
64353
+ */
64354
+ readAsText: function (/**Object*/entry, /**String=*/encoding) {
64355
+ var item = getEntry(entry);
64356
+ if (item) {
64357
+ var data = item.getData();
64358
+ if (data && data.length) {
64359
+ return data.toString(encoding || "utf8");
64360
+ }
64361
+ }
64362
+ return "";
64363
+ },
64364
+
64365
+ /**
64366
+ * Asynchronous readAsText
64367
+ * @param entry ZipEntry object or String with the full path of the entry
64368
+ * @param callback
64369
+ * @param encoding Optional. If no encoding is specified utf8 is used
64370
+ *
64371
+ * @return String
64372
+ */
64373
+ readAsTextAsync: function (/**Object*/entry, /**Function*/callback, /**String=*/encoding) {
64374
+ var item = getEntry(entry);
64375
+ if (item) {
64376
+ item.getDataAsync(function (data, err) {
64377
+ if (err) {
64378
+ callback(data, err);
64379
+ return;
64380
+ }
64381
+
64382
+ if (data && data.length) {
64383
+ callback(data.toString(encoding || "utf8"));
64384
+ } else {
64385
+ callback("");
64386
+ }
64387
+ })
64388
+ } else {
64389
+ callback("");
64390
+ }
64391
+ },
64392
+
64393
+ /**
64394
+ * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
64395
+ *
64396
+ * @param entry
64397
+ */
64398
+ deleteFile: function (/**Object*/entry) { // @TODO: test deleteFile
64399
+ var item = getEntry(entry);
64400
+ if (item) {
64401
+ _zip.deleteEntry(item.entryName);
64402
+ }
64403
+ },
64404
+
64405
+ /**
64406
+ * Adds a comment to the zip. The zip must be rewritten after adding the comment.
64407
+ *
64408
+ * @param comment
64409
+ */
64410
+ addZipComment: function (/**String*/comment) { // @TODO: test addZipComment
64411
+ _zip.comment = comment;
64412
+ },
64413
+
64414
+ /**
64415
+ * Returns the zip comment
64416
+ *
64417
+ * @return String
64418
+ */
64419
+ getZipComment: function () {
64420
+ return _zip.comment || '';
64421
+ },
64422
+
64423
+ /**
64424
+ * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
64425
+ * The comment cannot exceed 65535 characters in length
64426
+ *
64427
+ * @param entry
64428
+ * @param comment
64429
+ */
64430
+ addZipEntryComment: function (/**Object*/entry, /**String*/comment) {
64431
+ var item = getEntry(entry);
64432
+ if (item) {
64433
+ item.comment = comment;
64434
+ }
64435
+ },
64436
+
64437
+ /**
64438
+ * Returns the comment of the specified entry
64439
+ *
64440
+ * @param entry
64441
+ * @return String
64442
+ */
64443
+ getZipEntryComment: function (/**Object*/entry) {
64444
+ var item = getEntry(entry);
64445
+ if (item) {
64446
+ return item.comment || '';
64447
+ }
64448
+ return ''
64449
+ },
64450
+
64451
+ /**
64452
+ * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
64453
+ *
64454
+ * @param entry
64455
+ * @param content
64456
+ */
64457
+ updateFile: function (/**Object*/entry, /**Buffer*/content) {
64458
+ var item = getEntry(entry);
64459
+ if (item) {
64460
+ item.setData(content);
64461
+ }
64462
+ },
64463
+
64464
+ /**
64465
+ * Adds a file from the disk to the archive
64466
+ *
64467
+ * @param localPath File to add to zip
64468
+ * @param zipPath Optional path inside the zip
64469
+ * @param zipName Optional name for the file
64470
+ */
64471
+ addLocalFile: function (/**String*/localPath, /**String=*/zipPath, /**String=*/zipName, /**String*/comment) {
64472
+ if (fs.existsSync(localPath)) {
64473
+ // fix ZipPath
64474
+ zipPath = (zipPath) ? fixPath(zipPath) : "";
64475
+
64476
+ // p - local file name
64477
+ var p = localPath.split("\\").join("/").split("/").pop();
64478
+
64479
+ // add file name into zippath
64480
+ zipPath += (zipName) ? zipName : p;
64481
+
64482
+ // read file attributes
64483
+ const _attr = fs.statSync(localPath);
64484
+
64485
+ // add file into zip file
64486
+ this.addFile(zipPath, fs.readFileSync(localPath), comment, _attr)
64487
+ } else {
64488
+ throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
64489
+ }
64490
+ },
64491
+
64492
+ /**
64493
+ * Adds a local directory and all its nested files and directories to the archive
64494
+ *
64495
+ * @param localPath
64496
+ * @param zipPath optional path inside zip
64497
+ * @param filter optional RegExp or Function if files match will
64498
+ * be included.
64499
+ */
64500
+ addLocalFolder: function (/**String*/localPath, /**String=*/zipPath, /**=RegExp|Function*/filter) {
64501
+ // Prepare filter
64502
+ if (filter instanceof RegExp) { // if filter is RegExp wrap it
64503
+ filter = (function (rx){
64504
+ return function (filename) {
64505
+ return rx.test(filename);
64506
+ }
64507
+ })(filter);
64508
+ } else if ('function' !== typeof filter) { // if filter is not function we will replace it
64509
+ filter = function () {
64510
+ return true;
64511
+ };
64512
+ }
64513
+
64514
+ // fix ZipPath
64515
+ zipPath = (zipPath) ? fixPath(zipPath) : "";
64516
+
64517
+ // normalize the path first
64518
+ localPath = pth.normalize(localPath);
64519
+
64520
+ if (fs.existsSync(localPath)) {
64521
+
64522
+ var items = Utils.findFiles(localPath),
64523
+ self = this;
64524
+
64525
+ if (items.length) {
64526
+ items.forEach(function (filepath) {
64527
+ var p = pth.relative(localPath, filepath).split("\\").join("/"); //windows fix
64528
+ if (filter(p)) {
64529
+ var stats = fs.statSync(filepath);
64530
+ if (stats.isFile()) {
64531
+ self.addFile(zipPath + p, fs.readFileSync(filepath), "", stats);
64532
+ } else {
64533
+ self.addFile(zipPath + p + '/', Buffer.alloc(0), "", stats);
64534
+ }
64535
+ }
64536
+ });
64537
+ }
64538
+ } else {
64539
+ throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
64540
+ }
64541
+ },
64542
+
64543
+ /**
64544
+ * Asynchronous addLocalFile
64545
+ * @param localPath
64546
+ * @param callback
64547
+ * @param zipPath optional path inside zip
64548
+ * @param filter optional RegExp or Function if files match will
64549
+ * be included.
64550
+ */
64551
+ addLocalFolderAsync: function (/*String*/localPath, /*Function*/callback, /*String*/zipPath, /*RegExp|Function*/filter) {
64552
+ if (filter instanceof RegExp) {
64553
+ filter = (function (rx) {
64554
+ return function (filename) {
64555
+ return rx.test(filename);
64556
+ };
64557
+ })(filter);
64558
+ } else if ("function" !== typeof filter) {
64559
+ filter = function () {
64560
+ return true;
64561
+ };
64562
+ }
64563
+
64564
+ // fix ZipPath
64565
+ zipPath = zipPath ? fixPath(zipPath) : "";
64566
+
64567
+ // normalize the path first
64568
+ localPath = pth.normalize(localPath);
64569
+
64570
+ var self = this;
64571
+ fs.open(localPath, 'r', function (err) {
64572
+ if (err && err.code === 'ENOENT') {
64573
+ callback(undefined, Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
64574
+ } else if (err) {
64575
+ callback(undefined, err);
64576
+ } else {
64577
+ var items = Utils.findFiles(localPath);
64578
+ var i = -1;
64579
+
64580
+ var next = function () {
64581
+ i += 1;
64582
+ if (i < items.length) {
64583
+ var filepath = items[i];
64584
+ var p = pth.relative(localPath, filepath).split("\\").join("/"); //windows fix
64585
+ p = p.normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^\x20-\x7E]/g, '') // accent fix
64586
+ if (filter(p)) {
64587
+ fs.stat(filepath, function (er0, stats) {
64588
+ if (er0) callback(undefined, er0);
64589
+ if (stats.isFile()) {
64590
+ fs.readFile(filepath, function (er1, data) {
64591
+ if (er1) {
64592
+ callback(undefined, er1);
64593
+ } else {
64594
+ self.addFile(zipPath + p, data, "", stats);
64595
+ next();
64596
+ }
64597
+ });
64598
+ } else {
64599
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
64600
+ next();
64601
+ }
64602
+ });
64603
+ } else {
64604
+ next();
64605
+ }
64606
+
64607
+ } else {
64608
+ callback(true, undefined);
64609
+ }
64610
+ }
64611
+
64612
+ next();
64613
+ }
64614
+ });
64615
+ },
64616
+
64617
+ addLocalFolderPromise: function (/*String*/ localPath, /* object */ options) {
64618
+ return new Promise((resolve, reject) => {
64619
+ const { filter, zipPath } = Object.assign({}, options);
64620
+ this.addLocalFolderAsync(localPath,
64621
+ (done, err) => {
64622
+ if (err) reject(err);
64623
+ if (done) resolve(this);
64624
+ }, zipPath, filter
64625
+ );
64626
+ });
64627
+ },
64628
+
64629
+ /**
64630
+ * Allows you to create a entry (file or directory) in the zip file.
64631
+ * If you want to create a directory the entryName must end in / and a null buffer should be provided.
64632
+ * Comment and attributes are optional
64633
+ *
64634
+ * @param {string} entryName
64635
+ * @param {Buffer | string} content - file content as buffer or utf8 coded string
64636
+ * @param {string} comment - file comment
64637
+ * @param {number | object} attr - number as unix file permissions, object as filesystem Stats object
64638
+ */
64639
+ addFile: function (/**String*/ entryName, /**Buffer*/ content, /**String*/ comment, /**Number*/ attr) {
64640
+ let entry = getEntry(entryName);
64641
+ const update = entry != null;
64642
+
64643
+ // prepare new entry
64644
+ if (!update){
64645
+ entry = new ZipEntry();
64646
+ entry.entryName = entryName;
64647
+ }
64648
+ entry.comment = comment || "";
64649
+
64650
+ const isStat = ('object' === typeof attr) && (attr instanceof fs.Stats);
64651
+
64652
+ // last modification time from file stats
64653
+ if (isStat){
64654
+ entry.header.time = attr.mtime;
64655
+ }
64656
+
64657
+ // Set file attribute
64658
+ var fileattr = (entry.isDirectory) ? 0x10 : 0; // (MS-DOS directory flag)
64659
+
64660
+ // extended attributes field for Unix
64661
+ if('win32' !== process.platform){
64662
+ // set file type either S_IFDIR / S_IFREG
64663
+ let unix = (entry.isDirectory) ? 0x4000 : 0x8000;
64664
+
64665
+ if (isStat) { // File attributes from file stats
64666
+ unix |= (0xfff & attr.mode);
64667
+ }else if ('number' === typeof attr){ // attr from given attr values
64668
+ unix |= (0xfff & attr);
64669
+ }else{ // Default values:
64670
+ unix |= (entry.isDirectory) ? 0o755 : 0o644; // permissions (drwxr-xr-x) or (-r-wr--r--)
64671
+ }
64672
+
64673
+ fileattr = (fileattr | (unix << 16)) >>> 0; // add attributes
64674
+ }
64675
+
64676
+ entry.attr = fileattr;
64677
+
64678
+ entry.setData(content);
64679
+ if (!update) _zip.setEntry(entry);
64680
+ },
64681
+
64682
+ /**
64683
+ * Returns an array of ZipEntry objects representing the files and folders inside the archive
64684
+ *
64685
+ * @return Array
64686
+ */
64687
+ getEntries: function () {
64688
+ if (_zip) {
64689
+ return _zip.entries;
64690
+ } else {
64691
+ return [];
64692
+ }
64693
+ },
64694
+
64695
+ /**
64696
+ * Returns a ZipEntry object representing the file or folder specified by ``name``.
64697
+ *
64698
+ * @param name
64699
+ * @return ZipEntry
64700
+ */
64701
+ getEntry: function (/**String*/name) {
64702
+ return getEntry(name);
64703
+ },
64704
+
64705
+ getEntryCount: function() {
64706
+ return _zip.getEntryCount();
64707
+ },
64708
+
64709
+ forEach: function(callback) {
64710
+ return _zip.forEach(callback);
64711
+ },
64712
+
64713
+ /**
64714
+ * Extracts the given entry to the given targetPath
64715
+ * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
64716
+ *
64717
+ * @param entry ZipEntry object or String with the full path of the entry
64718
+ * @param targetPath Target folder where to write the file
64719
+ * @param maintainEntryPath If maintainEntryPath is true and the entry is inside a folder, the entry folder
64720
+ * will be created in targetPath as well. Default is TRUE
64721
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
64722
+ * Default is FALSE
64723
+ * @param outFileName String If set will override the filename of the extracted file (Only works if the entry is a file)
64724
+ *
64725
+ * @return Boolean
64726
+ */
64727
+ extractEntryTo: function (/**Object*/entry, /**String*/targetPath, /**Boolean*/maintainEntryPath, /**Boolean*/overwrite, /**String**/outFileName) {
64728
+ overwrite = overwrite || false;
64729
+ maintainEntryPath = typeof maintainEntryPath === "undefined" ? true : maintainEntryPath;
64730
+
64731
+ var item = getEntry(entry);
64732
+ if (!item) {
64733
+ throw new Error(Utils.Errors.NO_ENTRY);
64734
+ }
64735
+
64736
+ var entryName = canonical(item.entryName);
64737
+
64738
+ var target = sanitize(targetPath,outFileName && !item.isDirectory ? outFileName : (maintainEntryPath ? entryName : pth.basename(entryName)));
64739
+
64740
+ if (item.isDirectory) {
64741
+ target = pth.resolve(target, "..");
64742
+ var children = _zip.getEntryChildren(item);
64743
+ children.forEach(function (child) {
64744
+ if (child.isDirectory) return;
64745
+ var content = child.getData();
64746
+ if (!content) {
64747
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
64748
+ }
64749
+ var name = canonical(child.entryName)
64750
+ var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
64751
+ // The reverse operation for attr depend on method addFile()
64752
+ var fileAttr = child.attr ? (((child.attr >>> 0) | 0) >> 16) & 0xfff : 0;
64753
+ Utils.writeFileTo(childName, content, overwrite, fileAttr);
64754
+ });
64755
+ return true;
64756
+ }
64757
+
64758
+ var content = item.getData();
64759
+ if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
64760
+
64761
+ if (fs.existsSync(target) && !overwrite) {
64762
+ throw new Error(Utils.Errors.CANT_OVERRIDE);
64763
+ }
64764
+ // The reverse operation for attr depend on method addFile()
64765
+ var fileAttr = item.attr ? (((item.attr >>> 0) | 0) >> 16) & 0xfff : 0;
64766
+ Utils.writeFileTo(target, content, overwrite, fileAttr);
64767
+
64768
+ return true;
64769
+ },
64770
+
64771
+ /**
64772
+ * Test the archive
64773
+ *
64774
+ */
64775
+ test: function (pass) {
64776
+ if (!_zip) {
64777
+ return false;
64778
+ }
64779
+
64780
+ for (var entry in _zip.entries) {
64781
+ try {
64782
+ if (entry.isDirectory) {
64783
+ continue;
64784
+ }
64785
+ var content = _zip.entries[entry].getData(pass);
64786
+ if (!content) {
64787
+ return false;
64788
+ }
64789
+ } catch (err) {
64790
+ return false;
64791
+ }
64792
+ }
64793
+ return true;
64794
+ },
64795
+
64796
+ /**
64797
+ * Extracts the entire archive to the given location
64798
+ *
64799
+ * @param targetPath Target location
64800
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
64801
+ * Default is FALSE
64802
+ */
64803
+ extractAllTo: function (/**String*/targetPath, /**Boolean*/overwrite, /*String, Buffer*/pass) {
64804
+ overwrite = overwrite || false;
64805
+ if (!_zip) {
64806
+ throw new Error(Utils.Errors.NO_ZIP);
64807
+ }
64808
+ _zip.entries.forEach(function (entry) {
64809
+ var entryName = sanitize(targetPath, canonical(entry.entryName.toString()));
64810
+ if (entry.isDirectory) {
64811
+ Utils.makeDir(entryName);
64812
+ return;
64813
+ }
64814
+ var content = entry.getData(pass);
64815
+ if (!content) {
64816
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
64817
+ }
64818
+ // The reverse operation for attr depend on method addFile()
64819
+ var fileAttr = entry.attr ? (((entry.attr >>> 0) | 0) >> 16) & 0xfff : 0;
64820
+ Utils.writeFileTo(entryName, content, overwrite, fileAttr);
64821
+ try {
64822
+ fs.utimesSync(entryName, entry.header.time, entry.header.time)
64823
+ } catch (err) {
64824
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
64825
+ }
64826
+ })
64827
+ },
64828
+
64829
+ /**
64830
+ * Asynchronous extractAllTo
64831
+ *
64832
+ * @param targetPath Target location
64833
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
64834
+ * Default is FALSE
64835
+ * @param callback
64836
+ */
64837
+ extractAllToAsync: function (/**String*/targetPath, /**Boolean*/overwrite, /**Function*/callback) {
64838
+ if (!callback) {
64839
+ callback = function() {}
64840
+ }
64841
+ overwrite = overwrite || false;
64842
+ if (!_zip) {
64843
+ callback(new Error(Utils.Errors.NO_ZIP));
64844
+ return;
64845
+ }
64846
+
64847
+ var entries = _zip.entries;
64848
+ var i = entries.length;
64849
+ entries.forEach(function (entry) {
64850
+ if (i <= 0) return; // Had an error already
64851
+
64852
+ var entryName = pth.normalize(canonical(entry.entryName.toString()));
64853
+
64854
+ if (entry.isDirectory) {
64855
+ Utils.makeDir(sanitize(targetPath, entryName));
64856
+ if (--i === 0)
64857
+ callback(undefined);
64858
+ return;
64859
+ }
64860
+ entry.getDataAsync(function (content, err) {
64861
+ if (i <= 0) return;
64862
+ if (err) {
64863
+ callback(new Error(err));
64864
+ return;
64865
+ }
64866
+ if (!content) {
64867
+ i = 0;
64868
+ callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));
64869
+ return;
64870
+ }
64871
+
64872
+ // The reverse operation for attr depend on method addFile()
64873
+ var fileAttr = entry.attr ? (((entry.attr >>> 0) | 0) >> 16) & 0xfff : 0;
64874
+ Utils.writeFileToAsync(sanitize(targetPath, entryName), content, overwrite, fileAttr, function (succ) {
64875
+ try {
64876
+ fs.utimesSync(pth.resolve(targetPath, entryName), entry.header.time, entry.header.time);
64877
+ } catch (err) {
64878
+ callback(new Error('Unable to set utimes'));
64879
+ }
64880
+ if (i <= 0) return;
64881
+ if (!succ) {
64882
+ i = 0;
64883
+ callback(new Error('Unable to write'));
64884
+ return;
64885
+ }
64886
+ if (--i === 0)
64887
+ callback(undefined);
64888
+ });
64889
+ });
64890
+ })
64891
+ },
64892
+
64893
+ /**
64894
+ * Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
64895
+ *
64896
+ * @param targetFileName
64897
+ * @param callback
64898
+ */
64899
+ writeZip: function (/**String*/targetFileName, /**Function*/callback) {
64900
+ if (arguments.length === 1) {
64901
+ if (typeof targetFileName === "function") {
64902
+ callback = targetFileName;
64903
+ targetFileName = "";
64904
+ }
64905
+ }
64906
+
64907
+ if (!targetFileName && opts.filename) {
64908
+ targetFileName = opts.filename;
64909
+ }
64910
+ if (!targetFileName) return;
64911
+
64912
+ var zipData = _zip.compressToBuffer();
64913
+ if (zipData) {
64914
+ var ok = Utils.writeFileTo(targetFileName, zipData, true);
64915
+ if (typeof callback === 'function') callback(!ok ? new Error("failed") : null, "");
64916
+ }
64917
+ },
64918
+
64919
+ writeZipPromise: function (/**String*/ targetFileName, /* object */ options) {
64920
+ const { overwrite, perm } = Object.assign({ overwrite: true }, options);
64921
+
64922
+ return new Promise((resolve, reject) => {
64923
+ // find file name
64924
+ if (!targetFileName && opts.filename) targetFileName = opts.filename;
64925
+ if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
64926
+
64927
+ this.toBufferPromise().then((zipData) => {
64928
+ const ret = (done) => (done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file"));
64929
+ Utils.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
64930
+ }, reject);
64931
+ });
64932
+ },
64933
+
64934
+ toBufferPromise: function () {
64935
+ return new Promise((resolve, reject) => {
64936
+ _zip.toAsyncBuffer(resolve, reject);
64937
+ });
64938
+ },
64939
+
64940
+ /**
64941
+ * Returns the content of the entire zip file as a Buffer object
64942
+ *
64943
+ * @return Buffer
64944
+ */
64945
+ toBuffer: function (/**Function=*/onSuccess, /**Function=*/onFail, /**Function=*/onItemStart, /**Function=*/onItemEnd) {
64946
+ this.valueOf = 2;
64947
+ if (typeof onSuccess === "function") {
64948
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
64949
+ return null;
64950
+ }
64951
+ return _zip.compressToBuffer()
64952
+ }
64953
+ }
64954
+ };
64955
+
64956
+
64957
+ /***/ }),
64958
+
64959
+ /***/ 42907:
64960
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64961
+
64962
+ var Utils = __webpack_require__(85173),
64963
+ Constants = Utils.Constants;
64964
+
64965
+ /* The central directory file header */
64966
+ module.exports = function () {
64967
+ var _verMade = 0x14,
64968
+ _version = 0x0A,
64969
+ _flags = 0,
64970
+ _method = 0,
64971
+ _time = 0,
64972
+ _crc = 0,
64973
+ _compressedSize = 0,
64974
+ _size = 0,
64975
+ _fnameLen = 0,
64976
+ _extraLen = 0,
64977
+
64978
+ _comLen = 0,
64979
+ _diskStart = 0,
64980
+ _inattr = 0,
64981
+ _attr = 0,
64982
+ _offset = 0;
64983
+
64984
+ switch(process.platform){
64985
+ case 'win32':
64986
+ _verMade |= 0x0A00;
64987
+ default:
64988
+ _verMade |= 0x0300;
64989
+ }
64990
+
64991
+ var _dataHeader = {};
64992
+
64993
+ function setTime(val) {
64994
+ val = new Date(val);
64995
+ _time = (val.getFullYear() - 1980 & 0x7f) << 25 // b09-16 years from 1980
64996
+ | (val.getMonth() + 1) << 21 // b05-08 month
64997
+ | val.getDate() << 16 // b00-04 hour
64998
+
64999
+ // 2 bytes time
65000
+ | val.getHours() << 11 // b11-15 hour
65001
+ | val.getMinutes() << 5 // b05-10 minute
65002
+ | val.getSeconds() >> 1; // b00-04 seconds divided by 2
65003
+ }
65004
+
65005
+ setTime(+new Date());
65006
+
65007
+ return {
65008
+ get made () { return _verMade; },
65009
+ set made (val) { _verMade = val; },
65010
+
65011
+ get version () { return _version; },
65012
+ set version (val) { _version = val },
65013
+
65014
+ get flags () { return _flags },
65015
+ set flags (val) { _flags = val; },
65016
+
65017
+ get method () { return _method; },
65018
+ set method (val) {
65019
+ switch (val){
65020
+ case Constants.STORED:
65021
+ this.version = 10;
65022
+ case Constants.DEFLATED:
65023
+ default:
65024
+ this.version = 20;
65025
+ }
65026
+ _method = val;
65027
+ },
65028
+
65029
+ get time () { return new Date(
65030
+ ((_time >> 25) & 0x7f) + 1980,
65031
+ ((_time >> 21) & 0x0f) - 1,
65032
+ (_time >> 16) & 0x1f,
65033
+ (_time >> 11) & 0x1f,
65034
+ (_time >> 5) & 0x3f,
65035
+ (_time & 0x1f) << 1
65036
+ );
65037
+ },
65038
+ set time (val) {
65039
+ setTime(val);
65040
+ },
65041
+
65042
+ get crc () { return _crc; },
65043
+ set crc (val) { _crc = val; },
65044
+
65045
+ get compressedSize () { return _compressedSize; },
65046
+ set compressedSize (val) { _compressedSize = val; },
65047
+
65048
+ get size () { return _size; },
65049
+ set size (val) { _size = val; },
65050
+
65051
+ get fileNameLength () { return _fnameLen; },
65052
+ set fileNameLength (val) { _fnameLen = val; },
65053
+
65054
+ get extraLength () { return _extraLen },
65055
+ set extraLength (val) { _extraLen = val; },
65056
+
65057
+ get commentLength () { return _comLen },
65058
+ set commentLength (val) { _comLen = val },
65059
+
65060
+ get diskNumStart () { return _diskStart },
65061
+ set diskNumStart (val) { _diskStart = val },
65062
+
65063
+ get inAttr () { return _inattr },
65064
+ set inAttr (val) { _inattr = val },
65065
+
65066
+ get attr () { return _attr },
65067
+ set attr (val) { _attr = val },
65068
+
65069
+ get offset () { return _offset },
65070
+ set offset (val) { _offset = val },
65071
+
65072
+ get encripted () { return (_flags & 1) === 1 },
65073
+
65074
+ get entryHeaderSize () {
65075
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
65076
+ },
65077
+
65078
+ get realDataOffset () {
65079
+ return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen;
65080
+ },
65081
+
65082
+ get dataHeader () {
65083
+ return _dataHeader;
65084
+ },
65085
+
65086
+ loadDataHeaderFromBinary : function(/*Buffer*/input) {
65087
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
65088
+ // 30 bytes and should start with "PK\003\004"
65089
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
65090
+ throw new Error(Utils.Errors.INVALID_LOC);
65091
+ }
65092
+ _dataHeader = {
65093
+ // version needed to extract
65094
+ version : data.readUInt16LE(Constants.LOCVER),
65095
+ // general purpose bit flag
65096
+ flags : data.readUInt16LE(Constants.LOCFLG),
65097
+ // compression method
65098
+ method : data.readUInt16LE(Constants.LOCHOW),
65099
+ // modification time (2 bytes time, 2 bytes date)
65100
+ time : data.readUInt32LE(Constants.LOCTIM),
65101
+ // uncompressed file crc-32 value
65102
+ crc : data.readUInt32LE(Constants.LOCCRC),
65103
+ // compressed size
65104
+ compressedSize : data.readUInt32LE(Constants.LOCSIZ),
65105
+ // uncompressed size
65106
+ size : data.readUInt32LE(Constants.LOCLEN),
65107
+ // filename length
65108
+ fnameLen : data.readUInt16LE(Constants.LOCNAM),
65109
+ // extra field length
65110
+ extraLen : data.readUInt16LE(Constants.LOCEXT)
65111
+ }
65112
+ },
65113
+
65114
+ loadFromBinary : function(/*Buffer*/data) {
65115
+ // data should be 46 bytes and start with "PK 01 02"
65116
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
65117
+ throw new Error(Utils.Errors.INVALID_CEN);
65118
+ }
65119
+ // version made by
65120
+ _verMade = data.readUInt16LE(Constants.CENVEM);
65121
+ // version needed to extract
65122
+ _version = data.readUInt16LE(Constants.CENVER);
65123
+ // encrypt, decrypt flags
65124
+ _flags = data.readUInt16LE(Constants.CENFLG);
65125
+ // compression method
65126
+ _method = data.readUInt16LE(Constants.CENHOW);
65127
+ // modification time (2 bytes time, 2 bytes date)
65128
+ _time = data.readUInt32LE(Constants.CENTIM);
65129
+ // uncompressed file crc-32 value
65130
+ _crc = data.readUInt32LE(Constants.CENCRC);
65131
+ // compressed size
65132
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
65133
+ // uncompressed size
65134
+ _size = data.readUInt32LE(Constants.CENLEN);
65135
+ // filename length
65136
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
65137
+ // extra field length
65138
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
65139
+ // file comment length
65140
+ _comLen = data.readUInt16LE(Constants.CENCOM);
65141
+ // volume number start
65142
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
65143
+ // internal file attributes
65144
+ _inattr = data.readUInt16LE(Constants.CENATT);
65145
+ // external file attributes
65146
+ _attr = data.readUInt32LE(Constants.CENATX);
65147
+ // LOC header offset
65148
+ _offset = data.readUInt32LE(Constants.CENOFF);
65149
+ },
65150
+
65151
+ dataHeaderToBinary : function() {
65152
+ // LOC header size (30 bytes)
65153
+ var data = Buffer.alloc(Constants.LOCHDR);
65154
+ // "PK\003\004"
65155
+ data.writeUInt32LE(Constants.LOCSIG, 0);
65156
+ // version needed to extract
65157
+ data.writeUInt16LE(_version, Constants.LOCVER);
65158
+ // general purpose bit flag
65159
+ data.writeUInt16LE(_flags, Constants.LOCFLG);
65160
+ // compression method
65161
+ data.writeUInt16LE(_method, Constants.LOCHOW);
65162
+ // modification time (2 bytes time, 2 bytes date)
65163
+ data.writeUInt32LE(_time, Constants.LOCTIM);
65164
+ // uncompressed file crc-32 value
65165
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
65166
+ // compressed size
65167
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
65168
+ // uncompressed size
65169
+ data.writeUInt32LE(_size, Constants.LOCLEN);
65170
+ // filename length
65171
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
65172
+ // extra field length
65173
+ data.writeUInt16LE(_extraLen, Constants.LOCEXT);
65174
+ return data;
65175
+ },
65176
+
65177
+ entryHeaderToBinary : function() {
65178
+ // CEN header size (46 bytes)
65179
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
65180
+ // "PK\001\002"
65181
+ data.writeUInt32LE(Constants.CENSIG, 0);
65182
+ // version made by
65183
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
65184
+ // version needed to extract
65185
+ data.writeUInt16LE(_version, Constants.CENVER);
65186
+ // encrypt, decrypt flags
65187
+ data.writeUInt16LE(_flags, Constants.CENFLG);
65188
+ // compression method
65189
+ data.writeUInt16LE(_method, Constants.CENHOW);
65190
+ // modification time (2 bytes time, 2 bytes date)
65191
+ data.writeUInt32LE(_time, Constants.CENTIM);
65192
+ // uncompressed file crc-32 value
65193
+ data.writeUInt32LE(_crc, Constants.CENCRC);
65194
+ // compressed size
65195
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
65196
+ // uncompressed size
65197
+ data.writeUInt32LE(_size, Constants.CENLEN);
65198
+ // filename length
65199
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
65200
+ // extra field length
65201
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
65202
+ // file comment length
65203
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
65204
+ // volume number start
65205
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
65206
+ // internal file attributes
65207
+ data.writeUInt16LE(_inattr, Constants.CENATT);
65208
+ // external file attributes
65209
+ data.writeUInt32LE(_attr, Constants.CENATX);
65210
+ // LOC header offset
65211
+ data.writeUInt32LE(_offset, Constants.CENOFF);
65212
+ // fill all with
65213
+ data.fill(0x00, Constants.CENHDR);
65214
+ return data;
65215
+ },
65216
+
65217
+ toString : function() {
65218
+ return '{\n' +
65219
+ '\t"made" : ' + _verMade + ",\n" +
65220
+ '\t"version" : ' + _version + ",\n" +
65221
+ '\t"flags" : ' + _flags + ",\n" +
65222
+ '\t"method" : ' + Utils.methodToString(_method) + ",\n" +
65223
+ '\t"time" : ' + this.time + ",\n" +
65224
+ '\t"crc" : 0x' + _crc.toString(16).toUpperCase() + ",\n" +
65225
+ '\t"compressedSize" : ' + _compressedSize + " bytes,\n" +
65226
+ '\t"size" : ' + _size + " bytes,\n" +
65227
+ '\t"fileNameLength" : ' + _fnameLen + ",\n" +
65228
+ '\t"extraLength" : ' + _extraLen + " bytes,\n" +
65229
+ '\t"commentLength" : ' + _comLen + " bytes,\n" +
65230
+ '\t"diskNumStart" : ' + _diskStart + ",\n" +
65231
+ '\t"inAttr" : ' + _inattr + ",\n" +
65232
+ '\t"attr" : ' + _attr + ",\n" +
65233
+ '\t"offset" : ' + _offset + ",\n" +
65234
+ '\t"entryHeaderSize" : ' + (Constants.CENHDR + _fnameLen + _extraLen + _comLen) + " bytes\n" +
65235
+ '}';
65236
+ }
65237
+ }
65238
+ };
65239
+
65240
+
65241
+ /***/ }),
65242
+
65243
+ /***/ 53854:
65244
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65245
+
65246
+ exports.EntryHeader = __webpack_require__(42907);
65247
+ exports.MainHeader = __webpack_require__(83519);
65248
+
65249
+
65250
+ /***/ }),
65251
+
65252
+ /***/ 83519:
65253
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65254
+
65255
+ var Utils = __webpack_require__(85173),
65256
+ Constants = Utils.Constants;
65257
+
65258
+ /* The entries in the end of central directory */
65259
+ module.exports = function () {
65260
+ var _volumeEntries = 0,
65261
+ _totalEntries = 0,
65262
+ _size = 0,
65263
+ _offset = 0,
65264
+ _commentLength = 0;
65265
+
65266
+ return {
65267
+ get diskEntries () { return _volumeEntries },
65268
+ set diskEntries (/*Number*/val) { _volumeEntries = _totalEntries = val; },
65269
+
65270
+ get totalEntries () { return _totalEntries },
65271
+ set totalEntries (/*Number*/val) { _totalEntries = _volumeEntries = val; },
65272
+
65273
+ get size () { return _size },
65274
+ set size (/*Number*/val) { _size = val; },
65275
+
65276
+ get offset () { return _offset },
65277
+ set offset (/*Number*/val) { _offset = val; },
65278
+
65279
+ get commentLength () { return _commentLength },
65280
+ set commentLength (/*Number*/val) { _commentLength = val; },
65281
+
65282
+ get mainHeaderSize () {
65283
+ return Constants.ENDHDR + _commentLength;
65284
+ },
65285
+
65286
+ loadFromBinary : function(/*Buffer*/data) {
65287
+ // data should be 22 bytes and start with "PK 05 06"
65288
+ // or be 56+ bytes and start with "PK 06 06" for Zip64
65289
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) &&
65290
+ (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
65291
+
65292
+ throw new Error(Utils.Errors.INVALID_END);
65293
+ }
65294
+
65295
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
65296
+ // number of entries on this volume
65297
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
65298
+ // total number of entries
65299
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
65300
+ // central directory size in bytes
65301
+ _size = data.readUInt32LE(Constants.ENDSIZ);
65302
+ // offset of first CEN header
65303
+ _offset = data.readUInt32LE(Constants.ENDOFF);
65304
+ // zip file comment length
65305
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
65306
+ } else {
65307
+ // number of entries on this volume
65308
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
65309
+ // total number of entries
65310
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
65311
+ // central directory size in bytes
65312
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZ);
65313
+ // offset of first CEN header
65314
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
65315
+
65316
+ _commentLength = 0;
65317
+ }
65318
+
65319
+ },
65320
+
65321
+ toBinary : function() {
65322
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
65323
+ // "PK 05 06" signature
65324
+ b.writeUInt32LE(Constants.ENDSIG, 0);
65325
+ b.writeUInt32LE(0, 4);
65326
+ // number of entries on this volume
65327
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
65328
+ // total number of entries
65329
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
65330
+ // central directory size in bytes
65331
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
65332
+ // offset of first CEN header
65333
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
65334
+ // zip file comment length
65335
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
65336
+ // fill comment memory with spaces so no garbage is left there
65337
+ b.fill(" ", Constants.ENDHDR);
65338
+
65339
+ return b;
65340
+ },
65341
+
65342
+ toString : function() {
65343
+ return '{\n' +
65344
+ '\t"diskEntries" : ' + _volumeEntries + ",\n" +
65345
+ '\t"totalEntries" : ' + _totalEntries + ",\n" +
65346
+ '\t"size" : ' + _size + " bytes,\n" +
65347
+ '\t"offset" : 0x' + _offset.toString(16).toUpperCase() + ",\n" +
65348
+ '\t"commentLength" : 0x' + _commentLength + "\n" +
65349
+ '}';
65350
+ }
65351
+ }
65352
+ };
65353
+
65354
+ /***/ }),
65355
+
65356
+ /***/ 10278:
65357
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65358
+
65359
+ module.exports = function (/*Buffer*/inbuf) {
65360
+
65361
+ var zlib = __webpack_require__(78761);
65362
+
65363
+ var opts = {chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024};
65364
+
65365
+ return {
65366
+ deflate: function () {
65367
+ return zlib.deflateRawSync(inbuf, opts);
65368
+ },
65369
+
65370
+ deflateAsync: function (/*Function*/callback) {
65371
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
65372
+ tmp.on('data', function (data) {
65373
+ parts.push(data);
65374
+ total += data.length;
65375
+ });
65376
+ tmp.on('end', function () {
65377
+ var buf = Buffer.alloc(total), written = 0;
65378
+ buf.fill(0);
65379
+ for (var i = 0; i < parts.length; i++) {
65380
+ var part = parts[i];
65381
+ part.copy(buf, written);
65382
+ written += part.length;
65383
+ }
65384
+ callback && callback(buf);
65385
+ });
65386
+ tmp.end(inbuf);
65387
+ }
65388
+ }
65389
+ };
65390
+
65391
+
65392
+ /***/ }),
65393
+
65394
+ /***/ 81004:
65395
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65396
+
65397
+ exports.Deflater = __webpack_require__(10278);
65398
+ exports.Inflater = __webpack_require__(61269);
65399
+ exports.ZipCrypto = __webpack_require__(94729);
65400
+
65401
+ /***/ }),
65402
+
65403
+ /***/ 61269:
65404
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65405
+
65406
+ module.exports = function (/*Buffer*/inbuf) {
65407
+
65408
+ var zlib = __webpack_require__(78761);
65409
+
65410
+ return {
65411
+ inflate: function () {
65412
+ return zlib.inflateRawSync(inbuf);
65413
+ },
65414
+
65415
+ inflateAsync: function (/*Function*/callback) {
65416
+ var tmp = zlib.createInflateRaw(), parts = [], total = 0;
65417
+ tmp.on('data', function (data) {
65418
+ parts.push(data);
65419
+ total += data.length;
65420
+ });
65421
+ tmp.on('end', function () {
65422
+ var buf = Buffer.alloc(total), written = 0;
65423
+ buf.fill(0);
65424
+ for (var i = 0; i < parts.length; i++) {
65425
+ var part = parts[i];
65426
+ part.copy(buf, written);
65427
+ written += part.length;
65428
+ }
65429
+ callback && callback(buf);
65430
+ });
65431
+ tmp.end(inbuf);
65432
+ }
65433
+ }
65434
+ };
65435
+
65436
+
65437
+ /***/ }),
65438
+
65439
+ /***/ 94729:
65440
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65441
+
65442
+ // node crypt, we use it for generate salt
65443
+ const { randomFillSync } = __webpack_require__(76417);
65444
+
65445
+ "use strict";
65446
+
65447
+ // generate CRC32 lookup table
65448
+ const crctable = new Uint32Array(256).map((t, crc) => {
65449
+ for (let j = 0; j < 8; j++) {
65450
+ if (0 !== (crc & 1)) {
65451
+ crc = (crc >>> 1) ^ 0xedb88320;
65452
+ } else {
65453
+ crc >>>= 1;
65454
+ }
65455
+ }
65456
+ return crc >>> 0;
65457
+ });
65458
+
65459
+ // C-style uInt32 Multiply (discards higher bits, when JS multiply discards lower bits)
65460
+ const uMul = (a, b) => Math.imul(a, b) >>> 0;
65461
+
65462
+ // crc32 byte single update (actually same function is part of utils.crc32 function :) )
65463
+ const crc32update = (pCrc32, bval) => {
65464
+ return crctable[(pCrc32 ^ bval) & 0xff] ^ (pCrc32 >>> 8);
65465
+ };
65466
+
65467
+ // function for generating salt for encrytion header
65468
+ const genSalt = () => {
65469
+ if ("function" === typeof randomFillSync) {
65470
+ return randomFillSync(Buffer.alloc(12));
65471
+ } else {
65472
+ // fallback if function is not defined
65473
+ return genSalt.node();
65474
+ }
65475
+ };
65476
+
65477
+ // salt generation with node random function (mainly as fallback)
65478
+ genSalt.node = () => {
65479
+ const salt = Buffer.alloc(12);
65480
+ const len = salt.length;
65481
+ for (let i = 0; i < len; i++) salt[i] = (Math.random() * 256) & 0xff;
65482
+ return salt;
65483
+ };
65484
+
65485
+ // general config
65486
+ const config = {
65487
+ genSalt
65488
+ };
65489
+
65490
+ // Class Initkeys handles same basic ops with keys
65491
+ function Initkeys(pw) {
65492
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
65493
+ this.keys = new Uint32Array([0x12345678, 0x23456789, 0x34567890]);
65494
+ for (let i = 0; i < pass.length; i++) {
65495
+ this.updateKeys(pass[i]);
65496
+ }
65497
+ }
65498
+
65499
+ Initkeys.prototype.updateKeys = function (byteValue) {
65500
+ const keys = this.keys;
65501
+ keys[0] = crc32update(keys[0], byteValue);
65502
+ keys[1] += keys[0] & 0xff;
65503
+ keys[1] = uMul(keys[1], 134775813) + 1;
65504
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
65505
+ return byteValue;
65506
+ };
65507
+
65508
+ Initkeys.prototype.next = function () {
65509
+ const k = (this.keys[2] | 2) >>> 0; // key
65510
+ return (uMul(k, k ^ 1) >> 8) & 0xff; // decode
65511
+ };
65512
+
65513
+ function make_decrypter(/*Buffer*/ pwd) {
65514
+ // 1. Stage initialize key
65515
+ const keys = new Initkeys(pwd);
65516
+
65517
+ // return decrypter function
65518
+ return function (/*Buffer*/ data) {
65519
+ // result - we create new Buffer for results
65520
+ const result = Buffer.alloc(data.length);
65521
+ let pos = 0;
65522
+ // process input data
65523
+ for (let c of data) {
65524
+ //c ^= keys.next();
65525
+ //result[pos++] = c; // decode & Save Value
65526
+ result[pos++] = keys.updateKeys(c ^ keys.next()); // update keys with decoded byte
65527
+ }
65528
+ return result;
65529
+ };
65530
+ }
65531
+
65532
+ function make_encrypter(/*Buffer*/ pwd) {
65533
+ // 1. Stage initialize key
65534
+ const keys = new Initkeys(pwd);
65535
+
65536
+ // return encrypting function, result and pos is here so we dont have to merge buffers later
65537
+ return function (/*Buffer*/ data, /*Buffer*/ result, /* Number */ pos = 0) {
65538
+ // result - we create new Buffer for results
65539
+ if (!result) result = Buffer.alloc(data.length);
65540
+ // process input data
65541
+ for (let c of data) {
65542
+ const k = keys.next(); // save key byte
65543
+ result[pos++] = c ^ k; // save val
65544
+ keys.updateKeys(c); // update keys with decoded byte
65545
+ }
65546
+ return result;
65547
+ };
65548
+ }
65549
+
65550
+ function decrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd) {
65551
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
65552
+ return Buffer.alloc(0);
65553
+ }
65554
+
65555
+ // 1. We Initialize and generate decrypting function
65556
+ const decrypter = make_decrypter(pwd);
65557
+
65558
+ // 2. decrypt salt what is always 12 bytes and is a part of file content
65559
+ const salt = decrypter(data.slice(0, 12));
65560
+
65561
+ // 3. does password meet expectations
65562
+ if (salt[11] !== header.crc >>> 24) {
65563
+ throw "ADM-ZIP: Wrong Password";
65564
+ }
65565
+
65566
+ // 4. decode content
65567
+ return decrypter(data.slice(12));
65568
+ }
65569
+
65570
+ // lets add way to populate salt, NOT RECOMMENDED for production but maybe useful for testing general functionality
65571
+ function _salter(data) {
65572
+ if (Buffer.isBuffer(data) && data.length >= 12) {
65573
+ // be aware - currently salting buffer data is modified
65574
+ config.genSalt = function () {
65575
+ return data.slice(0, 12);
65576
+ };
65577
+ } else if (data === "node") {
65578
+ // test salt generation with node random function
65579
+ config.genSalt = genSalt.node;
65580
+ } else {
65581
+ // if value is not acceptable config gets reset.
65582
+ config.genSalt = genSalt;
65583
+ }
65584
+ }
65585
+
65586
+ function encrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd, /*Boolean*/ oldlike = false) {
65587
+ // 1. test data if data is not Buffer we make buffer from it
65588
+ if (data == null) data = Buffer.alloc(0);
65589
+ // if data is not buffer be make buffer from it
65590
+ if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
65591
+
65592
+ // 2. We Initialize and generate encrypting function
65593
+ const encrypter = make_encrypter(pwd);
65594
+
65595
+ // 3. generate salt (12-bytes of random data)
65596
+ const salt = config.genSalt();
65597
+ salt[11] = (header.crc >>> 24) & 0xff;
65598
+
65599
+ // old implementations (before PKZip 2.04g) used two byte check
65600
+ if (oldlike) salt[10] = (header.crc >>> 16) & 0xff;
65601
+
65602
+ // 4. create output
65603
+ const result = Buffer.alloc(data.length + 12);
65604
+ encrypter(salt, result);
65605
+
65606
+ // finally encode content
65607
+ return encrypter(data, result, 12);
65608
+ }
65609
+
65610
+ module.exports = { decrypt, encrypt, _salter };
65611
+
65612
+
65613
+ /***/ }),
65614
+
65615
+ /***/ 55991:
65616
+ /***/ ((module) => {
65617
+
65618
+ module.exports = {
65619
+ /* The local file header */
65620
+ LOCHDR : 30, // LOC header size
65621
+ LOCSIG : 0x04034b50, // "PK\003\004"
65622
+ LOCVER : 4, // version needed to extract
65623
+ LOCFLG : 6, // general purpose bit flag
65624
+ LOCHOW : 8, // compression method
65625
+ LOCTIM : 10, // modification time (2 bytes time, 2 bytes date)
65626
+ LOCCRC : 14, // uncompressed file crc-32 value
65627
+ LOCSIZ : 18, // compressed size
65628
+ LOCLEN : 22, // uncompressed size
65629
+ LOCNAM : 26, // filename length
65630
+ LOCEXT : 28, // extra field length
65631
+
65632
+ /* The Data descriptor */
65633
+ EXTSIG : 0x08074b50, // "PK\007\008"
65634
+ EXTHDR : 16, // EXT header size
65635
+ EXTCRC : 4, // uncompressed file crc-32 value
65636
+ EXTSIZ : 8, // compressed size
65637
+ EXTLEN : 12, // uncompressed size
65638
+
65639
+ /* The central directory file header */
65640
+ CENHDR : 46, // CEN header size
65641
+ CENSIG : 0x02014b50, // "PK\001\002"
65642
+ CENVEM : 4, // version made by
65643
+ CENVER : 6, // version needed to extract
65644
+ CENFLG : 8, // encrypt, decrypt flags
65645
+ CENHOW : 10, // compression method
65646
+ CENTIM : 12, // modification time (2 bytes time, 2 bytes date)
65647
+ CENCRC : 16, // uncompressed file crc-32 value
65648
+ CENSIZ : 20, // compressed size
65649
+ CENLEN : 24, // uncompressed size
65650
+ CENNAM : 28, // filename length
65651
+ CENEXT : 30, // extra field length
65652
+ CENCOM : 32, // file comment length
65653
+ CENDSK : 34, // volume number start
65654
+ CENATT : 36, // internal file attributes
65655
+ CENATX : 38, // external file attributes (host system dependent)
65656
+ CENOFF : 42, // LOC header offset
65657
+
65658
+ /* The entries in the end of central directory */
65659
+ ENDHDR : 22, // END header size
65660
+ ENDSIG : 0x06054b50, // "PK\005\006"
65661
+ ENDSUB : 8, // number of entries on this disk
65662
+ ENDTOT : 10, // total number of entries
65663
+ ENDSIZ : 12, // central directory size in bytes
65664
+ ENDOFF : 16, // offset of first CEN header
65665
+ ENDCOM : 20, // zip file comment length
65666
+
65667
+ END64HDR : 20, // zip64 END header size
65668
+ END64SIG : 0x07064b50, // zip64 Locator signature, "PK\006\007"
65669
+ END64START : 4, // number of the disk with the start of the zip64
65670
+ END64OFF : 8, // relative offset of the zip64 end of central directory
65671
+ END64NUMDISKS : 16, // total number of disks
65672
+
65673
+ ZIP64SIG : 0x06064b50, // zip64 signature, "PK\006\006"
65674
+ ZIP64HDR : 56, // zip64 record minimum size
65675
+ ZIP64LEAD : 12, // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
65676
+ ZIP64SIZE : 4, // zip64 size of the central directory record
65677
+ ZIP64VEM : 12, // zip64 version made by
65678
+ ZIP64VER : 14, // zip64 version needed to extract
65679
+ ZIP64DSK : 16, // zip64 number of this disk
65680
+ ZIP64DSKDIR : 20, // number of the disk with the start of the record directory
65681
+ ZIP64SUB : 24, // number of entries on this disk
65682
+ ZIP64TOT : 32, // total number of entries
65683
+ ZIP64SIZB : 40, // zip64 central directory size in bytes
65684
+ ZIP64OFF : 48, // offset of start of central directory with respect to the starting disk number
65685
+ ZIP64EXTRA : 56, // extensible data sector
65686
+
65687
+ /* Compression methods */
65688
+ STORED : 0, // no compression
65689
+ SHRUNK : 1, // shrunk
65690
+ REDUCED1 : 2, // reduced with compression factor 1
65691
+ REDUCED2 : 3, // reduced with compression factor 2
65692
+ REDUCED3 : 4, // reduced with compression factor 3
65693
+ REDUCED4 : 5, // reduced with compression factor 4
65694
+ IMPLODED : 6, // imploded
65695
+ // 7 reserved
65696
+ DEFLATED : 8, // deflated
65697
+ ENHANCED_DEFLATED: 9, // enhanced deflated
65698
+ PKWARE : 10,// PKWare DCL imploded
65699
+ // 11 reserved
65700
+ BZIP2 : 12, // compressed using BZIP2
65701
+ // 13 reserved
65702
+ LZMA : 14, // LZMA
65703
+ // 15-17 reserved
65704
+ IBM_TERSE : 18, // compressed using IBM TERSE
65705
+ IBM_LZ77 : 19, //IBM LZ77 z
65706
+
65707
+ /* General purpose bit flag */
65708
+ FLG_ENC : 0, // encripted file
65709
+ FLG_COMP1 : 1, // compression option
65710
+ FLG_COMP2 : 2, // compression option
65711
+ FLG_DESC : 4, // data descriptor
65712
+ FLG_ENH : 8, // enhanced deflation
65713
+ FLG_STR : 16, // strong encryption
65714
+ FLG_LNG : 1024, // language encoding
65715
+ FLG_MSK : 4096, // mask header values
65716
+
65717
+ /* Load type */
65718
+ FILE : 2,
65719
+ BUFFER : 1,
65720
+ NONE : 0,
65721
+
65722
+ /* 4.5 Extensible data fields */
65723
+ EF_ID : 0,
65724
+ EF_SIZE : 2,
65725
+
65726
+ /* Header IDs */
65727
+ ID_ZIP64 : 0x0001,
65728
+ ID_AVINFO : 0x0007,
65729
+ ID_PFS : 0x0008,
65730
+ ID_OS2 : 0x0009,
65731
+ ID_NTFS : 0x000a,
65732
+ ID_OPENVMS : 0x000c,
65733
+ ID_UNIX : 0x000d,
65734
+ ID_FORK : 0x000e,
65735
+ ID_PATCH : 0x000f,
65736
+ ID_X509_PKCS7 : 0x0014,
65737
+ ID_X509_CERTID_F : 0x0015,
65738
+ ID_X509_CERTID_C : 0x0016,
65739
+ ID_STRONGENC : 0x0017,
65740
+ ID_RECORD_MGT : 0x0018,
65741
+ ID_X509_PKCS7_RL : 0x0019,
65742
+ ID_IBM1 : 0x0065,
65743
+ ID_IBM2 : 0x0066,
65744
+ ID_POSZIP : 0x4690,
65745
+
65746
+ EF_ZIP64_OR_32 : 0xffffffff,
65747
+ EF_ZIP64_OR_16 : 0xffff,
65748
+ EF_ZIP64_SUNCOMP : 0,
65749
+ EF_ZIP64_SCOMP : 8,
65750
+ EF_ZIP64_RHO : 16,
65751
+ EF_ZIP64_DSN : 24
65752
+ };
65753
+
65754
+
65755
+ /***/ }),
65756
+
65757
+ /***/ 12190:
65758
+ /***/ ((module) => {
65759
+
65760
+ module.exports = {
65761
+ /* Header error messages */
65762
+ "INVALID_LOC" : "Invalid LOC header (bad signature)",
65763
+ "INVALID_CEN" : "Invalid CEN header (bad signature)",
65764
+ "INVALID_END" : "Invalid END header (bad signature)",
65765
+
65766
+ /* ZipEntry error messages*/
65767
+ "NO_DATA" : "Nothing to decompress",
65768
+ "BAD_CRC" : "CRC32 checksum failed",
65769
+ "FILE_IN_THE_WAY" : "There is a file in the way: %s",
65770
+ "UNKNOWN_METHOD" : "Invalid/unsupported compression method",
65771
+
65772
+ /* Inflater error messages */
65773
+ "AVAIL_DATA" : "inflate::Available inflate data did not terminate",
65774
+ "INVALID_DISTANCE" : "inflate::Invalid literal/length or distance code in fixed or dynamic block",
65775
+ "TO_MANY_CODES" : "inflate::Dynamic block code description: too many length or distance codes",
65776
+ "INVALID_REPEAT_LEN" : "inflate::Dynamic block code description: repeat more than specified lengths",
65777
+ "INVALID_REPEAT_FIRST" : "inflate::Dynamic block code description: repeat lengths with no first length",
65778
+ "INCOMPLETE_CODES" : "inflate::Dynamic block code description: code lengths codes incomplete",
65779
+ "INVALID_DYN_DISTANCE": "inflate::Dynamic block code description: invalid distance code lengths",
65780
+ "INVALID_CODES_LEN": "inflate::Dynamic block code description: invalid literal/length code lengths",
65781
+ "INVALID_STORE_BLOCK" : "inflate::Stored block length did not match one's complement",
65782
+ "INVALID_BLOCK_TYPE" : "inflate::Invalid block type (type == 3)",
65783
+
65784
+ /* ADM-ZIP error messages */
65785
+ "CANT_EXTRACT_FILE" : "Could not extract the file",
65786
+ "CANT_OVERRIDE" : "Target file already exists",
65787
+ "NO_ZIP" : "No zip file was loaded",
65788
+ "NO_ENTRY" : "Entry doesn't exist",
65789
+ "DIRECTORY_CONTENT_ERROR" : "A directory cannot have content",
65790
+ "FILE_NOT_FOUND" : "File not found: %s",
65791
+ "NOT_IMPLEMENTED" : "Not implemented",
65792
+ "INVALID_FILENAME" : "Invalid filename",
65793
+ "INVALID_FORMAT" : "Invalid or unsupported zip format. No END header found"
65794
+ };
65795
+
65796
+ /***/ }),
65797
+
65798
+ /***/ 13455:
65799
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65800
+
65801
+ var fs = __webpack_require__(65147).require(),
65802
+ pth = __webpack_require__(85622);
65803
+
65804
+ fs.existsSync = fs.existsSync || pth.existsSync;
65805
+
65806
+ module.exports = function(/*String*/path) {
65807
+
65808
+ var _path = path || "",
65809
+ _permissions = 0,
65810
+ _obj = newAttr(),
65811
+ _stat = null;
65812
+
65813
+ function newAttr() {
65814
+ return {
65815
+ directory : false,
65816
+ readonly : false,
65817
+ hidden : false,
65818
+ executable : false,
65819
+ mtime : 0,
65820
+ atime : 0
65821
+ }
65822
+ }
65823
+
65824
+ if (_path && fs.existsSync(_path)) {
65825
+ _stat = fs.statSync(_path);
65826
+ _obj.directory = _stat.isDirectory();
65827
+ _obj.mtime = _stat.mtime;
65828
+ _obj.atime = _stat.atime;
65829
+ _obj.executable = (0o111 & _stat.mode) != 0; // file is executable who ever har right not just owner
65830
+ _obj.readonly = (0o200 & _stat.mode) == 0; // readonly if owner has no write right
65831
+ _obj.hidden = pth.basename(_path)[0] === ".";
65832
+ } else {
65833
+ console.warn("Invalid path: " + _path)
65834
+ }
65835
+
65836
+ return {
65837
+
65838
+ get directory () {
65839
+ return _obj.directory;
65840
+ },
65841
+
65842
+ get readOnly () {
65843
+ return _obj.readonly;
65844
+ },
65845
+
65846
+ get hidden () {
65847
+ return _obj.hidden;
65848
+ },
65849
+
65850
+ get mtime () {
65851
+ return _obj.mtime;
65852
+ },
65853
+
65854
+ get atime () {
65855
+ return _obj.atime;
65856
+ },
65857
+
65858
+
65859
+ get executable () {
65860
+ return _obj.executable;
65861
+ },
65862
+
65863
+ decodeAttributes : function(val) {
65864
+
65865
+ },
65866
+
65867
+ encodeAttributes : function (val) {
65868
+
65869
+ },
65870
+
65871
+ toString : function() {
65872
+ return '{\n' +
65873
+ '\t"path" : "' + _path + ",\n" +
65874
+ '\t"isDirectory" : ' + _obj.directory + ",\n" +
65875
+ '\t"isReadOnly" : ' + _obj.readonly + ",\n" +
65876
+ '\t"isHidden" : ' + _obj.hidden + ",\n" +
65877
+ '\t"isExecutable" : ' + _obj.executable + ",\n" +
65878
+ '\t"mTime" : ' + _obj.mtime + "\n" +
65879
+ '\t"aTime" : ' + _obj.atime + "\n" +
65880
+ '}';
65881
+ }
65882
+ }
65883
+
65884
+ };
65885
+
65886
+
65887
+ /***/ }),
65888
+
65889
+ /***/ 65147:
65890
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65891
+
65892
+ exports.require = function() {
65893
+ var fs = __webpack_require__(35747);
65894
+ if (process && process.versions && process.versions['electron']) {
65895
+ try {
65896
+ originalFs = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module 'original-fs'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
65897
+ if (Object.keys(originalFs).length > 0) {
65898
+ fs = originalFs;
65899
+ }
65900
+ } catch (e) {}
65901
+ }
65902
+ return fs
65903
+ };
65904
+
65905
+
65906
+ /***/ }),
65907
+
65908
+ /***/ 85173:
65909
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65910
+
65911
+ module.exports = __webpack_require__(7646);
65912
+ module.exports.FileSystem = __webpack_require__(65147);
65913
+ module.exports.Constants = __webpack_require__(55991);
65914
+ module.exports.Errors = __webpack_require__(12190);
65915
+ module.exports.FileAttr = __webpack_require__(13455);
65916
+
65917
+ /***/ }),
65918
+
65919
+ /***/ 7646:
65920
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65921
+
65922
+ var fs = __webpack_require__(65147).require(),
65923
+ pth = __webpack_require__(85622);
65924
+
65925
+ fs.existsSync = fs.existsSync || pth.existsSync;
65926
+
65927
+ module.exports = (function() {
65928
+
65929
+ var crcTable = [],
65930
+ Constants = __webpack_require__(55991),
65931
+ Errors = __webpack_require__(12190),
65932
+
65933
+ PATH_SEPARATOR = pth.sep;
65934
+
65935
+
65936
+ function mkdirSync(/*String*/path) {
65937
+ var resolvedPath = path.split(PATH_SEPARATOR)[0];
65938
+ path.split(PATH_SEPARATOR).forEach(function(name) {
65939
+ if (!name || name.substr(-1,1) === ":") return;
65940
+ resolvedPath += PATH_SEPARATOR + name;
65941
+ var stat;
65942
+ try {
65943
+ stat = fs.statSync(resolvedPath);
65944
+ } catch (e) {
65945
+ fs.mkdirSync(resolvedPath);
65946
+ }
65947
+ if (stat && stat.isFile())
65948
+ throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
65949
+ });
65950
+ }
65951
+
65952
+ function findSync(/*String*/dir, /*RegExp*/pattern, /*Boolean*/recoursive) {
65953
+ if (typeof pattern === 'boolean') {
65954
+ recoursive = pattern;
65955
+ pattern = undefined;
65956
+ }
65957
+ var files = [];
65958
+ fs.readdirSync(dir).forEach(function(file) {
65959
+ var path = pth.join(dir, file);
65960
+
65961
+ if (fs.statSync(path).isDirectory() && recoursive)
65962
+ files = files.concat(findSync(path, pattern, recoursive));
65963
+
65964
+ if (!pattern || pattern.test(path)) {
65965
+ files.push(pth.normalize(path) + (fs.statSync(path).isDirectory() ? PATH_SEPARATOR : ""));
65966
+ }
65967
+
65968
+ });
65969
+ return files;
65970
+ }
65971
+
65972
+ function readBigUInt64LE(/*Buffer*/buffer, /*int*/index) {
65973
+ var slice = Buffer.from(buffer.slice(index, index + 8));
65974
+ slice.swap64();
65975
+
65976
+ return parseInt(`0x${ slice.toString('hex') }`);
65977
+ }
65978
+
65979
+ return {
65980
+ makeDir : function(/*String*/path) {
65981
+ mkdirSync(path);
65982
+ },
65983
+
65984
+ crc32 : function(buf) {
65985
+ if (typeof buf === 'string') {
65986
+ buf = Buffer.from(buf);
65987
+ }
65988
+ var b = Buffer.alloc(4);
65989
+ if (!crcTable.length) {
65990
+ for (var n = 0; n < 256; n++) {
65991
+ var c = n;
65992
+ for (var k = 8; --k >= 0;) //
65993
+ if ((c & 1) !== 0) { c = 0xedb88320 ^ (c >>> 1); } else { c = c >>> 1; }
65994
+ if (c < 0) {
65995
+ b.writeInt32LE(c, 0);
65996
+ c = b.readUInt32LE(0);
65997
+ }
65998
+ crcTable[n] = c;
65999
+ }
66000
+ }
66001
+ var crc = 0, off = 0, len = buf.length, c1 = ~crc;
66002
+ while(--len >= 0) c1 = crcTable[(c1 ^ buf[off++]) & 0xff] ^ (c1 >>> 8);
66003
+ crc = ~c1;
66004
+ b.writeInt32LE(crc & 0xffffffff, 0);
66005
+ return b.readUInt32LE(0);
66006
+ },
66007
+
66008
+ methodToString : function(/*Number*/method) {
66009
+ switch (method) {
66010
+ case Constants.STORED:
66011
+ return 'STORED (' + method + ')';
66012
+ case Constants.DEFLATED:
66013
+ return 'DEFLATED (' + method + ')';
66014
+ default:
66015
+ return 'UNSUPPORTED (' + method + ')';
66016
+ }
66017
+
66018
+ },
66019
+
66020
+ writeFileTo : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr) {
66021
+ if (fs.existsSync(path)) {
66022
+ if (!overwrite)
66023
+ return false; // cannot overwrite
66024
+
66025
+ var stat = fs.statSync(path);
66026
+ if (stat.isDirectory()) {
66027
+ return false;
66028
+ }
66029
+ }
66030
+ var folder = pth.dirname(path);
66031
+ if (!fs.existsSync(folder)) {
66032
+ mkdirSync(folder);
66033
+ }
66034
+
66035
+ var fd;
66036
+ try {
66037
+ fd = fs.openSync(path, 'w', 438); // 0666
66038
+ } catch(e) {
66039
+ fs.chmodSync(path, 438);
66040
+ fd = fs.openSync(path, 'w', 438);
66041
+ }
66042
+ if (fd) {
66043
+ try {
66044
+ fs.writeSync(fd, content, 0, content.length, 0);
66045
+ }
66046
+ catch (e){
66047
+ throw e;
66048
+ }
66049
+ finally {
66050
+ fs.closeSync(fd);
66051
+ }
66052
+ }
66053
+ fs.chmodSync(path, attr || 438);
66054
+ return true;
66055
+ },
66056
+
66057
+ writeFileToAsync : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr, /*Function*/callback) {
66058
+ if(typeof attr === 'function') {
66059
+ callback = attr;
66060
+ attr = undefined;
66061
+ }
66062
+
66063
+ fs.exists(path, function(exists) {
66064
+ if(exists && !overwrite)
66065
+ return callback(false);
66066
+
66067
+ fs.stat(path, function(err, stat) {
66068
+ if(exists &&stat.isDirectory()) {
66069
+ return callback(false);
66070
+ }
66071
+
66072
+ var folder = pth.dirname(path);
66073
+ fs.exists(folder, function(exists) {
66074
+ if(!exists)
66075
+ mkdirSync(folder);
66076
+
66077
+ fs.open(path, 'w', 438, function(err, fd) {
66078
+ if(err) {
66079
+ fs.chmod(path, 438, function() {
66080
+ fs.open(path, 'w', 438, function(err, fd) {
66081
+ fs.write(fd, content, 0, content.length, 0, function() {
66082
+ fs.close(fd, function() {
66083
+ fs.chmod(path, attr || 438, function() {
66084
+ callback(true);
66085
+ })
66086
+ });
66087
+ });
66088
+ });
66089
+ })
66090
+ } else {
66091
+ if(fd) {
66092
+ fs.write(fd, content, 0, content.length, 0, function() {
66093
+ fs.close(fd, function() {
66094
+ fs.chmod(path, attr || 438, function() {
66095
+ callback(true);
66096
+ })
66097
+ });
66098
+ });
66099
+ } else {
66100
+ fs.chmod(path, attr || 438, function() {
66101
+ callback(true);
66102
+ })
66103
+ }
66104
+ }
66105
+ });
66106
+ })
66107
+ })
66108
+ })
66109
+ },
66110
+
66111
+ findFiles : function(/*String*/path) {
66112
+ return findSync(path, true);
66113
+ },
66114
+
66115
+ getAttributes : function(/*String*/path) {
66116
+
66117
+ },
66118
+
66119
+ setAttributes : function(/*String*/path) {
66120
+
66121
+ },
66122
+
66123
+ toBuffer : function(input) {
66124
+ if (Buffer.isBuffer(input)) {
66125
+ return input;
66126
+ } else {
66127
+ if (input.length === 0) {
66128
+ return Buffer.alloc(0)
66129
+ }
66130
+ return Buffer.from(input, 'utf8');
66131
+ }
66132
+ },
66133
+
66134
+ readBigUInt64LE,
66135
+
66136
+ Constants : Constants,
66137
+ Errors : Errors
66138
+ }
66139
+ })();
66140
+
66141
+
66142
+ /***/ }),
66143
+
66144
+ /***/ 47396:
66145
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
66146
+
66147
+ var Utils = __webpack_require__(85173),
66148
+ Headers = __webpack_require__(53854),
66149
+ Constants = Utils.Constants,
66150
+ Methods = __webpack_require__(81004);
66151
+
66152
+ module.exports = function (/*Buffer*/input) {
66153
+ var _entryHeader = new Headers.EntryHeader(),
66154
+ _entryName = Buffer.alloc(0),
66155
+ _comment = Buffer.alloc(0),
66156
+ _isDirectory = false,
66157
+ uncompressedData = null,
66158
+ _extra = Buffer.alloc(0);
66159
+
66160
+ function getCompressedDataFromZip() {
66161
+ if (!input || !Buffer.isBuffer(input)) {
66162
+ return Buffer.alloc(0);
66163
+ }
66164
+ _entryHeader.loadDataHeaderFromBinary(input);
66165
+ return input.slice(_entryHeader.realDataOffset, _entryHeader.realDataOffset + _entryHeader.compressedSize)
66166
+ }
66167
+
66168
+ function crc32OK(data) {
66169
+ // if bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written
66170
+ if ((_entryHeader.flags & 0x8) !== 0x8) {
66171
+ if (Utils.crc32(data) !== _entryHeader.dataHeader.crc) {
66172
+ return false;
66173
+ }
66174
+ } else {
66175
+ // @TODO: load and check data descriptor header
66176
+ // The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure
66177
+ // (optionally preceded by a 4-byte signature) immediately after the compressed data:
66178
+ }
66179
+ return true;
66180
+ }
66181
+
66182
+ function decompress(/*Boolean*/async, /*Function*/callback, /*String, Buffer*/pass) {
66183
+ if(typeof callback === 'undefined' && typeof async === 'string') {
66184
+ pass=async;
66185
+ async=void 0;
66186
+ }
66187
+ if (_isDirectory) {
66188
+ if (async && callback) {
66189
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR); //si added error.
66190
+ }
66191
+ return Buffer.alloc(0);
66192
+ }
66193
+
66194
+ var compressedData = getCompressedDataFromZip();
66195
+
66196
+ if (compressedData.length === 0) {
66197
+ // File is empty, nothing to decompress.
66198
+ if (async && callback) callback(compressedData);
66199
+ return compressedData;
66200
+ }
66201
+
66202
+ if (_entryHeader.encripted){
66203
+ if ('string' !== typeof pass && !Buffer.isBuffer(pass)){
66204
+ throw new Error('ADM-ZIP: Incompatible password parameter');
66205
+ }
66206
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _entryHeader, pass);
66207
+ }
66208
+
66209
+ var data = Buffer.alloc(_entryHeader.size);
66210
+
66211
+ switch (_entryHeader.method) {
66212
+ case Utils.Constants.STORED:
66213
+ compressedData.copy(data);
66214
+ if (!crc32OK(data)) {
66215
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC);//si added error
66216
+ throw new Error(Utils.Errors.BAD_CRC);
66217
+ } else {//si added otherwise did not seem to return data.
66218
+ if (async && callback) callback(data);
66219
+ return data;
66220
+ }
66221
+ case Utils.Constants.DEFLATED:
66222
+ var inflater = new Methods.Inflater(compressedData);
66223
+ if (!async) {
66224
+ var result = inflater.inflate(data);
66225
+ result.copy(data, 0);
66226
+ if (!crc32OK(data)) {
66227
+ throw new Error(Utils.Errors.BAD_CRC + " " + _entryName.toString());
66228
+ }
66229
+ return data;
66230
+ } else {
66231
+ inflater.inflateAsync(function(result) {
66232
+ result.copy(data, 0);
66233
+ if (!crc32OK(data)) {
66234
+ if (callback) callback(data, Utils.Errors.BAD_CRC); //si added error
66235
+ } else { //si added otherwise did not seem to return data.
66236
+ if (callback) callback(data);
66237
+ }
66238
+ });
66239
+ }
66240
+ break;
66241
+ default:
66242
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD);
66243
+ throw new Error(Utils.Errors.UNKNOWN_METHOD);
66244
+ }
66245
+ }
66246
+
66247
+ function compress(/*Boolean*/async, /*Function*/callback) {
66248
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
66249
+ // no data set or the data wasn't changed to require recompression
66250
+ if (async && callback) callback(getCompressedDataFromZip());
66251
+ return getCompressedDataFromZip();
66252
+ }
66253
+
66254
+ if (uncompressedData.length && !_isDirectory) {
66255
+ var compressedData;
66256
+ // Local file header
66257
+ switch (_entryHeader.method) {
66258
+ case Utils.Constants.STORED:
66259
+ _entryHeader.compressedSize = _entryHeader.size;
66260
+
66261
+ compressedData = Buffer.alloc(uncompressedData.length);
66262
+ uncompressedData.copy(compressedData);
66263
+
66264
+ if (async && callback) callback(compressedData);
66265
+ return compressedData;
66266
+ default:
66267
+ case Utils.Constants.DEFLATED:
66268
+
66269
+ var deflater = new Methods.Deflater(uncompressedData);
66270
+ if (!async) {
66271
+ var deflated = deflater.deflate();
66272
+ _entryHeader.compressedSize = deflated.length;
66273
+ return deflated;
66274
+ } else {
66275
+ deflater.deflateAsync(function(data) {
66276
+ compressedData = Buffer.alloc(data.length);
66277
+ _entryHeader.compressedSize = data.length;
66278
+ data.copy(compressedData);
66279
+ callback && callback(compressedData);
66280
+ });
66281
+ }
66282
+ deflater = null;
66283
+ break;
66284
+ }
66285
+ } else {
66286
+ if (async && callback) {
66287
+ callback(Buffer.alloc(0));
66288
+ } else {
66289
+ return Buffer.alloc(0);
66290
+ }
66291
+ }
66292
+ }
66293
+
66294
+ function readUInt64LE(buffer, offset) {
66295
+ return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
66296
+ }
66297
+
66298
+ function parseExtra(data) {
66299
+ var offset = 0;
66300
+ var signature, size, part;
66301
+ while(offset<data.length) {
66302
+ signature = data.readUInt16LE(offset);
66303
+ offset += 2;
66304
+ size = data.readUInt16LE(offset);
66305
+ offset += 2;
66306
+ part = data.slice(offset, offset+size);
66307
+ offset += size;
66308
+ if(Constants.ID_ZIP64 === signature) {
66309
+ parseZip64ExtendedInformation(part);
66310
+ }
66311
+ }
66312
+ }
66313
+
66314
+ //Override header field values with values from the ZIP64 extra field
66315
+ function parseZip64ExtendedInformation(data) {
66316
+ var size, compressedSize, offset, diskNumStart;
66317
+
66318
+ if(data.length >= Constants.EF_ZIP64_SCOMP) {
66319
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
66320
+ if(_entryHeader.size === Constants.EF_ZIP64_OR_32) {
66321
+ _entryHeader.size = size;
66322
+ }
66323
+ }
66324
+ if(data.length >= Constants.EF_ZIP64_RHO) {
66325
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
66326
+ if(_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
66327
+ _entryHeader.compressedSize = compressedSize;
66328
+ }
66329
+ }
66330
+ if(data.length >= Constants.EF_ZIP64_DSN) {
66331
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
66332
+ if(_entryHeader.offset === Constants.EF_ZIP64_OR_32) {
66333
+ _entryHeader.offset = offset;
66334
+ }
66335
+ }
66336
+ if(data.length >= Constants.EF_ZIP64_DSN+4) {
66337
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
66338
+ if(_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
66339
+ _entryHeader.diskNumStart = diskNumStart;
66340
+ }
66341
+ }
66342
+ }
66343
+
66344
+
66345
+ return {
66346
+ get entryName () { return _entryName.toString(); },
66347
+ get rawEntryName() { return _entryName; },
66348
+ set entryName (val) {
66349
+ _entryName = Utils.toBuffer(val);
66350
+ var lastChar = _entryName[_entryName.length - 1];
66351
+ _isDirectory = (lastChar === 47) || (lastChar === 92);
66352
+ _entryHeader.fileNameLength = _entryName.length;
66353
+ },
66354
+
66355
+ get extra () { return _extra; },
66356
+ set extra (val) {
66357
+ _extra = val;
66358
+ _entryHeader.extraLength = val.length;
66359
+ parseExtra(val);
66360
+ },
66361
+
66362
+ get comment () { return _comment.toString(); },
66363
+ set comment (val) {
66364
+ _comment = Utils.toBuffer(val);
66365
+ _entryHeader.commentLength = _comment.length;
66366
+ },
66367
+
66368
+ get name () { var n = _entryName.toString(); return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop(); },
66369
+ get isDirectory () { return _isDirectory },
66370
+
66371
+ getCompressedData : function() {
66372
+ return compress(false, null)
66373
+ },
66374
+
66375
+ getCompressedDataAsync : function(/*Function*/callback) {
66376
+ compress(true, callback)
66377
+ },
66378
+
66379
+ setData : function(value) {
66380
+ uncompressedData = Utils.toBuffer(value);
66381
+ if (!_isDirectory && uncompressedData.length) {
66382
+ _entryHeader.size = uncompressedData.length;
66383
+ _entryHeader.method = Utils.Constants.DEFLATED;
66384
+ _entryHeader.crc = Utils.crc32(value);
66385
+ _entryHeader.changed = true;
66386
+ } else { // folders and blank files should be stored
66387
+ _entryHeader.method = Utils.Constants.STORED;
66388
+ }
66389
+ },
66390
+
66391
+ getData : function(pass) {
66392
+ if (_entryHeader.changed) {
66393
+ return uncompressedData;
66394
+ } else {
66395
+ return decompress(false, null, pass);
66396
+ }
66397
+ },
66398
+
66399
+ getDataAsync : function(/*Function*/callback, pass) {
66400
+ if (_entryHeader.changed) {
66401
+ callback(uncompressedData);
66402
+ } else {
66403
+ decompress(true, callback, pass);
66404
+ }
66405
+ },
66406
+
66407
+ set attr(attr) { _entryHeader.attr = attr; },
66408
+ get attr() { return _entryHeader.attr; },
66409
+
66410
+ set header(/*Buffer*/data) {
66411
+ _entryHeader.loadFromBinary(data);
66412
+ },
66413
+
66414
+ get header() {
66415
+ return _entryHeader;
66416
+ },
66417
+
66418
+ packHeader : function() {
66419
+ // 1. create header (buffer)
66420
+ var header = _entryHeader.entryHeaderToBinary();
66421
+ var addpos = Utils.Constants.CENHDR;
66422
+ // 2. add file name
66423
+ _entryName.copy(header, addpos);
66424
+ addpos += _entryName.length;
66425
+ // 3. add extra data
66426
+ if (_entryHeader.extraLength) {
66427
+ _extra.copy(header, addpos);
66428
+ addpos += _entryHeader.extraLength;
66429
+ }
66430
+ // 4. add file comment
66431
+ if (_entryHeader.commentLength) {
66432
+ _comment.copy(header, addpos);
66433
+ }
66434
+ return header;
66435
+ },
66436
+
66437
+ toString : function() {
66438
+ return '{\n' +
66439
+ '\t"entryName" : "' + _entryName.toString() + "\",\n" +
66440
+ '\t"name" : "' + (_isDirectory ? _entryName.toString().replace(/\/$/, '').split("/").pop() : _entryName.toString().split("/").pop()) + "\",\n" +
66441
+ '\t"comment" : "' + _comment.toString() + "\",\n" +
66442
+ '\t"isDirectory" : ' + _isDirectory + ",\n" +
66443
+ '\t"header" : ' + _entryHeader.toString().replace(/\t/mg, "\t\t").replace(/}/mg, "\t}") + ",\n" +
66444
+ '\t"compressedData" : <' + (input && input.length + " bytes buffer" || "null") + ">\n" +
66445
+ '\t"data" : <' + (uncompressedData && uncompressedData.length + " bytes buffer" || "null") + ">\n" +
66446
+ '}';
66447
+ }
66448
+ }
66449
+ };
66450
+
66451
+
66452
+ /***/ }),
66453
+
66454
+ /***/ 56333:
66455
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
66456
+
66457
+ const ZipEntry = __webpack_require__(47396);
66458
+ const Headers = __webpack_require__(53854);
66459
+ const Utils = __webpack_require__(85173);
66460
+
66461
+ module.exports = function (/*Buffer|null*/inBuffer, /** object */options) {
66462
+ var entryList = [],
66463
+ entryTable = {},
66464
+ _comment = Buffer.alloc(0),
66465
+ mainHeader = new Headers.MainHeader(),
66466
+ loadedEntries = false;
66467
+
66468
+ // assign options
66469
+ const opts = Object.assign(Object.create(null), options);
66470
+
66471
+ if (inBuffer){
66472
+ // is a memory buffer
66473
+ readMainHeader(opts.readEntries);
66474
+ } else {
66475
+ // none. is a new file
66476
+ loadedEntries = true;
66477
+ }
66478
+
66479
+ function iterateEntries(callback) {
66480
+ const totalEntries = mainHeader.diskEntries; // total number of entries
66481
+ let index = mainHeader.offset; // offset of first CEN header
66482
+
66483
+ for (let i = 0; i < totalEntries; i++) {
66484
+ let tmp = index;
66485
+ const entry = new ZipEntry(inBuffer);
66486
+
66487
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
66488
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
66489
+
66490
+ index += entry.header.entryHeaderSize;
66491
+
66492
+ callback(entry);
66493
+ }
66494
+ }
66495
+
66496
+ function readEntries() {
66497
+ loadedEntries = true;
66498
+ entryTable = {};
66499
+ entryList = new Array(mainHeader.diskEntries); // total number of entries
66500
+ var index = mainHeader.offset; // offset of first CEN header
66501
+ for (var i = 0; i < entryList.length; i++) {
66502
+
66503
+ var tmp = index,
66504
+ entry = new ZipEntry(inBuffer);
66505
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
66506
+
66507
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
66508
+
66509
+ if (entry.header.extraLength) {
66510
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
66511
+ }
66512
+
66513
+ if (entry.header.commentLength)
66514
+ entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
66515
+
66516
+ index += entry.header.entryHeaderSize;
66517
+
66518
+ entryList[i] = entry;
66519
+ entryTable[entry.entryName] = entry;
66520
+ }
66521
+ }
66522
+
66523
+ function readMainHeader(/*Boolean*/ readNow) {
66524
+ var i = inBuffer.length - Utils.Constants.ENDHDR, // END header size
66525
+ max = Math.max(0, i - 0xFFFF), // 0xFFFF is the max zip file comment length
66526
+ n = max,
66527
+ endStart = inBuffer.length,
66528
+ endOffset = -1, // Start offset of the END header
66529
+ commentEnd = 0;
66530
+
66531
+ for (i; i >= n; i--) {
66532
+ if (inBuffer[i] !== 0x50) continue; // quick check that the byte is 'P'
66533
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) { // "PK\005\006"
66534
+ endOffset = i;
66535
+ commentEnd = i;
66536
+ endStart = i + Utils.Constants.ENDHDR;
66537
+ // We already found a regular signature, let's look just a bit further to check if there's any zip64 signature
66538
+ n = i - Utils.Constants.END64HDR;
66539
+ continue;
66540
+ }
66541
+
66542
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
66543
+ // Found a zip64 signature, let's continue reading the whole zip64 record
66544
+ n = max;
66545
+ continue;
66546
+ }
66547
+
66548
+ if (inBuffer.readUInt32LE(i) == Utils.Constants.ZIP64SIG) {
66549
+ // Found the zip64 record, let's determine it's size
66550
+ endOffset = i;
66551
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
66552
+ break;
66553
+ }
66554
+ }
66555
+
66556
+ if (!~endOffset)
66557
+ throw new Error(Utils.Errors.INVALID_FORMAT);
66558
+
66559
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
66560
+ if (mainHeader.commentLength) {
66561
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
66562
+ }
66563
+ if (readNow) readEntries();
66564
+ }
66565
+
66566
+ return {
66567
+ /**
66568
+ * Returns an array of ZipEntry objects existent in the current opened archive
66569
+ * @return Array
66570
+ */
66571
+ get entries() {
66572
+ if (!loadedEntries) {
66573
+ readEntries();
66574
+ }
66575
+ return entryList;
66576
+ },
66577
+
66578
+ /**
66579
+ * Archive comment
66580
+ * @return {String}
66581
+ */
66582
+ get comment() {
66583
+ return _comment.toString();
66584
+ },
66585
+ set comment(val) {
66586
+ _comment = Utils.toBuffer(val);
66587
+ mainHeader.commentLength = _comment.length;
66588
+ },
66589
+
66590
+ getEntryCount: function() {
66591
+ if (!loadedEntries) {
66592
+ return mainHeader.diskEntries;
66593
+ }
66594
+
66595
+ return entryList.length;
66596
+ },
66597
+
66598
+ forEach: function(callback) {
66599
+ if (!loadedEntries) {
66600
+ iterateEntries(callback);
66601
+ return;
66602
+ }
66603
+
66604
+ entryList.forEach(callback);
66605
+ },
66606
+
66607
+ /**
66608
+ * Returns a reference to the entry with the given name or null if entry is inexistent
66609
+ *
66610
+ * @param entryName
66611
+ * @return ZipEntry
66612
+ */
66613
+ getEntry: function (/*String*/entryName) {
66614
+ if (!loadedEntries) {
66615
+ readEntries();
66616
+ }
66617
+ return entryTable[entryName] || null;
66618
+ },
66619
+
66620
+ /**
66621
+ * Adds the given entry to the entry list
66622
+ *
66623
+ * @param entry
66624
+ */
66625
+ setEntry: function (/*ZipEntry*/entry) {
66626
+ if (!loadedEntries) {
66627
+ readEntries();
66628
+ }
66629
+ entryList.push(entry);
66630
+ entryTable[entry.entryName] = entry;
66631
+ mainHeader.totalEntries = entryList.length;
66632
+ },
66633
+
66634
+ /**
66635
+ * Removes the entry with the given name from the entry list.
66636
+ *
66637
+ * If the entry is a directory, then all nested files and directories will be removed
66638
+ * @param entryName
66639
+ */
66640
+ deleteEntry: function (/*String*/entryName) {
66641
+ if (!loadedEntries) {
66642
+ readEntries();
66643
+ }
66644
+ var entry = entryTable[entryName];
66645
+ if (entry && entry.isDirectory) {
66646
+ var _self = this;
66647
+ this.getEntryChildren(entry).forEach(function (child) {
66648
+ if (child.entryName !== entryName) {
66649
+ _self.deleteEntry(child.entryName)
66650
+ }
66651
+ })
66652
+ }
66653
+ entryList.splice(entryList.indexOf(entry), 1);
66654
+ delete(entryTable[entryName]);
66655
+ mainHeader.totalEntries = entryList.length;
66656
+ },
66657
+
66658
+ /**
66659
+ * Iterates and returns all nested files and directories of the given entry
66660
+ *
66661
+ * @param entry
66662
+ * @return Array
66663
+ */
66664
+ getEntryChildren: function (/*ZipEntry*/entry) {
66665
+ if (!loadedEntries) {
66666
+ readEntries();
66667
+ }
66668
+ if (entry.isDirectory) {
66669
+ var list = [],
66670
+ name = entry.entryName,
66671
+ len = name.length;
66672
+
66673
+ entryList.forEach(function (zipEntry) {
66674
+ if (zipEntry.entryName.substr(0, len) === name) {
66675
+ list.push(zipEntry);
66676
+ }
66677
+ });
66678
+ return list;
66679
+ }
66680
+ return []
66681
+ },
66682
+
66683
+ /**
66684
+ * Returns the zip file
66685
+ *
66686
+ * @return Buffer
66687
+ */
66688
+ compressToBuffer: function () {
66689
+ if (!loadedEntries) {
66690
+ readEntries();
66691
+ }
66692
+ if (entryList.length > 1) {
66693
+ entryList.sort(function (a, b) {
66694
+ var nameA = a.entryName.toLowerCase();
66695
+ var nameB = b.entryName.toLowerCase();
66696
+ if (nameA < nameB) {
66697
+ return -1
66698
+ }
66699
+ if (nameA > nameB) {
66700
+ return 1
66701
+ }
66702
+ return 0;
66703
+ });
66704
+ }
66705
+
66706
+ var totalSize = 0,
66707
+ dataBlock = [],
66708
+ entryHeaders = [],
66709
+ dindex = 0;
66710
+
66711
+ mainHeader.size = 0;
66712
+ mainHeader.offset = 0;
66713
+
66714
+ entryList.forEach(function (entry) {
66715
+ // compress data and set local and entry header accordingly. Reason why is called first
66716
+ var compressedData = entry.getCompressedData();
66717
+ // data header
66718
+ entry.header.offset = dindex;
66719
+ var dataHeader = entry.header.dataHeaderToBinary();
66720
+ var entryNameLen = entry.rawEntryName.length;
66721
+ var extra = entry.extra.toString();
66722
+ var postHeader = Buffer.alloc(entryNameLen + extra.length);
66723
+ entry.rawEntryName.copy(postHeader, 0);
66724
+ postHeader.fill(extra, entryNameLen);
66725
+
66726
+ var dataLength = dataHeader.length + postHeader.length + compressedData.length;
66727
+
66728
+ dindex += dataLength;
66729
+
66730
+ dataBlock.push(dataHeader);
66731
+ dataBlock.push(postHeader);
66732
+ dataBlock.push(compressedData);
66733
+
66734
+ var entryHeader = entry.packHeader();
66735
+ entryHeaders.push(entryHeader);
66736
+ mainHeader.size += entryHeader.length;
66737
+ totalSize += (dataLength + entryHeader.length);
66738
+ });
66739
+
66740
+ totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
66741
+ // point to end of data and beginning of central directory first record
66742
+ mainHeader.offset = dindex;
66743
+
66744
+ dindex = 0;
66745
+ var outBuffer = Buffer.alloc(totalSize);
66746
+ dataBlock.forEach(function (content) {
66747
+ content.copy(outBuffer, dindex); // write data blocks
66748
+ dindex += content.length;
66749
+ });
66750
+ entryHeaders.forEach(function (content) {
66751
+ content.copy(outBuffer, dindex); // write central directory entries
66752
+ dindex += content.length;
66753
+ });
66754
+
66755
+ var mh = mainHeader.toBinary();
66756
+ if (_comment) {
66757
+ Buffer.from(_comment).copy(mh, Utils.Constants.ENDHDR); // add zip file comment
66758
+ }
66759
+
66760
+ mh.copy(outBuffer, dindex); // write main header
66761
+
66762
+ return outBuffer;
66763
+ },
66764
+
66765
+ toAsyncBuffer: function (/*Function*/onSuccess, /*Function*/onFail, /*Function*/onItemStart, /*Function*/onItemEnd) {
66766
+ if (!loadedEntries) {
66767
+ readEntries();
66768
+ }
66769
+ if (entryList.length > 1) {
66770
+ entryList.sort(function (a, b) {
66771
+ var nameA = a.entryName.toLowerCase();
66772
+ var nameB = b.entryName.toLowerCase();
66773
+ if (nameA > nameB) {
66774
+ return -1
66775
+ }
66776
+ if (nameA < nameB) {
66777
+ return 1
66778
+ }
66779
+ return 0;
66780
+ });
66781
+ }
66782
+
66783
+ var totalSize = 0,
66784
+ dataBlock = [],
66785
+ entryHeaders = [],
66786
+ dindex = 0;
66787
+
66788
+ mainHeader.size = 0;
66789
+ mainHeader.offset = 0;
66790
+
66791
+ var compress = function (entryList) {
66792
+ var self = arguments.callee;
66793
+ if (entryList.length) {
66794
+ var entry = entryList.pop();
66795
+ var name = entry.entryName + entry.extra.toString();
66796
+ if (onItemStart) onItemStart(name);
66797
+ entry.getCompressedDataAsync(function (compressedData) {
66798
+ if (onItemEnd) onItemEnd(name);
66799
+
66800
+ entry.header.offset = dindex;
66801
+ // data header
66802
+ var dataHeader = entry.header.dataHeaderToBinary();
66803
+ var postHeader;
66804
+ try {
66805
+ postHeader = Buffer.alloc(name.length, name); // using alloc will work on node 5.x+
66806
+ } catch(e){
66807
+ postHeader = new Buffer(name); // use deprecated method if alloc fails...
66808
+ }
66809
+ var dataLength = dataHeader.length + postHeader.length + compressedData.length;
66810
+
66811
+ dindex += dataLength;
66812
+
66813
+ dataBlock.push(dataHeader);
66814
+ dataBlock.push(postHeader);
66815
+ dataBlock.push(compressedData);
66816
+
66817
+ var entryHeader = entry.packHeader();
66818
+ entryHeaders.push(entryHeader);
66819
+ mainHeader.size += entryHeader.length;
66820
+ totalSize += (dataLength + entryHeader.length);
66821
+
66822
+ if (entryList.length) {
66823
+ self(entryList);
66824
+ } else {
66825
+
66826
+
66827
+ totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
66828
+ // point to end of data and beginning of central directory first record
66829
+ mainHeader.offset = dindex;
66830
+
66831
+ dindex = 0;
66832
+ var outBuffer = Buffer.alloc(totalSize);
66833
+ dataBlock.forEach(function (content) {
66834
+ content.copy(outBuffer, dindex); // write data blocks
66835
+ dindex += content.length;
66836
+ });
66837
+ entryHeaders.forEach(function (content) {
66838
+ content.copy(outBuffer, dindex); // write central directory entries
66839
+ dindex += content.length;
66840
+ });
66841
+
66842
+ var mh = mainHeader.toBinary();
66843
+ if (_comment) {
66844
+ _comment.copy(mh, Utils.Constants.ENDHDR); // add zip file comment
66845
+ }
66846
+
66847
+ mh.copy(outBuffer, dindex); // write main header
66848
+
66849
+ onSuccess(outBuffer);
66850
+ }
66851
+ });
66852
+ }
66853
+ };
66854
+
66855
+ compress(entryList);
66856
+ }
66857
+ }
66858
+ };
66859
+
66860
+
64217
66861
  /***/ }),
64218
66862
 
64219
66863
  /***/ 45018:
@@ -203565,7 +206209,9 @@ Object.defineProperty(exports, "nodeFilesToScannedProjects", ({ enumerable: true
203565
206209
 
203566
206210
  Object.defineProperty(exports, "__esModule", ({ value: true }));
203567
206211
  exports.jarFilesToScannedProjects = void 0;
206212
+ const admzip = __webpack_require__(55285);
203568
206213
  const path = __webpack_require__(85622);
206214
+ const buffer_utils_1 = __webpack_require__(29098);
203569
206215
  function groupJarFingerprintsByPath(input) {
203570
206216
  const jarFingerprints = Object.entries(input).map(([filePath, digest]) => {
203571
206217
  return {
@@ -203581,17 +206227,21 @@ function groupJarFingerprintsByPath(input) {
203581
206227
  }, {});
203582
206228
  return resultAggregatedByPath;
203583
206229
  }
203584
- async function jarFilesToScannedProjects(filePathToContent, targetImage) {
206230
+ async function jarFilesToScannedProjects(filePathToContent, targetImage, shadedJars) {
203585
206231
  const mappedResult = groupJarFingerprintsByPath(filePathToContent);
203586
206232
  const scanResults = [];
203587
206233
  for (const path in mappedResult) {
203588
206234
  if (!mappedResult.hasOwnProperty(path)) {
203589
206235
  continue;
203590
206236
  }
206237
+ let getJarFingerprints = getJarSha;
206238
+ if (shadedJars) {
206239
+ getJarFingerprints = checkIfFatJarsAndUnpack;
206240
+ }
203591
206241
  const jarFingerprintsFact = {
203592
206242
  type: "jarFingerprints",
203593
206243
  data: {
203594
- fingerprints: mappedResult[path],
206244
+ fingerprints: getJarFingerprints(mappedResult[path]),
203595
206245
  origin: targetImage,
203596
206246
  path,
203597
206247
  },
@@ -203607,6 +206257,40 @@ async function jarFilesToScannedProjects(filePathToContent, targetImage) {
203607
206257
  return scanResults;
203608
206258
  }
203609
206259
  exports.jarFilesToScannedProjects = jarFilesToScannedProjects;
206260
+ function getJarSha(jarBuffers) {
206261
+ return jarBuffers.map((element) => {
206262
+ return Object.assign(Object.assign({}, element), { digest: buffer_utils_1.bufferToSha1(element.digest) });
206263
+ });
206264
+ }
206265
+ function checkIfFatJarsAndUnpack(jarBuffers) {
206266
+ const fingerprints = [];
206267
+ for (const jarBuffer of jarBuffers) {
206268
+ const nestedJars = [];
206269
+ const buffer = jarBuffer.digest;
206270
+ const zip = new admzip(buffer);
206271
+ const zipEntries = zip.getEntries();
206272
+ for (const zipEntry of zipEntries) {
206273
+ if (zipEntry.entryName.endsWith(".jar")) {
206274
+ nestedJars.push({
206275
+ location: zipEntry.entryName,
206276
+ digest: zipEntry.getData(),
206277
+ });
206278
+ }
206279
+ }
206280
+ if (nestedJars.length > 0) {
206281
+ fingerprints.push(...nestedJars.map((element) => {
206282
+ return Object.assign(Object.assign({}, element), { digest: buffer_utils_1.bufferToSha1(element.digest) });
206283
+ }));
206284
+ }
206285
+ else {
206286
+ fingerprints.push({
206287
+ location: jarBuffer.location,
206288
+ digest: buffer_utils_1.bufferToSha1(jarBuffer.digest),
206289
+ });
206290
+ }
206291
+ }
206292
+ return fingerprints;
206293
+ }
203610
206294
  //# sourceMappingURL=java.js.map
203611
206295
 
203612
206296
  /***/ }),
@@ -204384,6 +207068,7 @@ const static_5 = __webpack_require__(92212);
204384
207068
  const static_6 = __webpack_require__(5809);
204385
207069
  const static_7 = __webpack_require__(96704);
204386
207070
  const static_8 = __webpack_require__(45330);
207071
+ const option_utils_1 = __webpack_require__(48587);
204387
207072
  const applications_1 = __webpack_require__(19551);
204388
207073
  const java_1 = __webpack_require__(3823);
204389
207074
  const osReleaseDetector = __webpack_require__(69975);
@@ -204391,7 +207076,7 @@ const apk_1 = __webpack_require__(86555);
204391
207076
  const apt_1 = __webpack_require__(21332);
204392
207077
  const rpm_1 = __webpack_require__(851);
204393
207078
  const debug = Debug("snyk");
204394
- async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, appScan) {
207079
+ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, options) {
204395
207080
  const staticAnalysisActions = [
204396
207081
  static_1.getApkDbFileContentAction,
204397
207082
  static_2.getDpkgFileContentAction,
@@ -204406,6 +207091,7 @@ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, gl
204406
207091
  if (checkForGlobs) {
204407
207092
  staticAnalysisActions.push(filePatternStatic.generateExtractAction(globsToFind.include, globsToFind.exclude));
204408
207093
  }
207094
+ const appScan = option_utils_1.isTrue(options["app-vulns"]);
204409
207095
  if (appScan) {
204410
207096
  staticAnalysisActions.push(...[
204411
207097
  static_6.getNodeAppFileContentAction,
@@ -204450,7 +207136,8 @@ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, gl
204450
207136
  const applicationDependenciesScanResults = [];
204451
207137
  if (appScan) {
204452
207138
  const nodeDependenciesScanResults = await applications_1.nodeFilesToScannedProjects(inputs_1.getFileContent(extractedLayers, static_6.getNodeAppFileContentAction.actionName));
204453
- const jarFingerprintScanResults = await java_1.jarFilesToScannedProjects(inputs_1.getFileContent(extractedLayers, static_5.getJarFileContentAction.actionName), targetImage);
207139
+ const shadedJars = option_utils_1.isTrue(options["shaded-jars"]);
207140
+ const jarFingerprintScanResults = await java_1.jarFilesToScannedProjects(inputs_1.getBufferContent(extractedLayers, static_5.getJarFileContentAction.actionName), targetImage, shadedJars);
204454
207141
  const goModulesScanResult = await go_parser_1.goModulesToScannedProjects(inputs_1.getElfFileContent(extractedLayers, go_parser_1.getGoModulesContentAction.actionName));
204455
207142
  applicationDependenciesScanResults.push(...nodeDependenciesScanResults, ...jarFingerprintScanResults, ...goModulesScanResult);
204456
207143
  }
@@ -204495,6 +207182,28 @@ var AnalysisType;
204495
207182
 
204496
207183
  /***/ }),
204497
207184
 
207185
+ /***/ 29098:
207186
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
207187
+
207188
+ "use strict";
207189
+
207190
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
207191
+ exports.bufferToSha1 = void 0;
207192
+ const crypto = __webpack_require__(76417);
207193
+ const types_1 = __webpack_require__(93677);
207194
+ const HASH_ENCODING = "hex";
207195
+ function bufferToSha1(buffer) {
207196
+ const hash = crypto.createHash(types_1.HashAlgorithm.Sha1);
207197
+ hash.setEncoding(HASH_ENCODING);
207198
+ hash.update(buffer);
207199
+ hash.end();
207200
+ return hash.read().toString(HASH_ENCODING);
207201
+ }
207202
+ exports.bufferToSha1 = bufferToSha1;
207203
+ //# sourceMappingURL=buffer-utils.js.map
207204
+
207205
+ /***/ }),
207206
+
204498
207207
  /***/ 95997:
204499
207208
  /***/ ((__unused_webpack_module, exports) => {
204500
207209
 
@@ -206537,43 +209246,66 @@ exports.getMatchingFiles = getMatchingFiles;
206537
209246
  "use strict";
206538
209247
 
206539
209248
  Object.defineProperty(exports, "__esModule", ({ value: true }));
206540
- exports.getElfFileContent = exports.getFileContent = void 0;
206541
- function getFileContent(extractedLayers, searchedAction) {
209249
+ exports.getBufferContent = exports.getElfFileContent = exports.getFileContent = exports.getContent = void 0;
209250
+ function getContent(extractedLayers, searchedAction, contentTypeValidation) {
206542
209251
  const foundAppFiles = {};
206543
209252
  for (const filePath of Object.keys(extractedLayers)) {
206544
209253
  for (const actionName of Object.keys(extractedLayers[filePath])) {
206545
209254
  if (actionName !== searchedAction) {
206546
209255
  continue;
206547
209256
  }
206548
- if (!(typeof extractedLayers[filePath][actionName] === "string")) {
206549
- throw new Error("expected string");
209257
+ if (!contentTypeValidation(extractedLayers[filePath][actionName])) {
209258
+ throw new Error("unexpected content type");
206550
209259
  }
206551
209260
  foundAppFiles[filePath] = extractedLayers[filePath][actionName];
206552
209261
  }
206553
209262
  }
206554
209263
  return foundAppFiles;
206555
209264
  }
209265
+ exports.getContent = getContent;
209266
+ function isStringType(type) {
209267
+ return typeof type === "string";
209268
+ }
209269
+ function getFileContent(extractedLayers, searchedAction) {
209270
+ let foundAppFiles;
209271
+ try {
209272
+ foundAppFiles = getContent(extractedLayers, searchedAction, isStringType);
209273
+ }
209274
+ catch (_a) {
209275
+ throw new Error("expected string");
209276
+ }
209277
+ return foundAppFiles;
209278
+ }
206556
209279
  exports.getFileContent = getFileContent;
206557
209280
  function isElfType(type) {
206558
209281
  const elf = type;
206559
209282
  return !!(elf.body && elf.body.programs && elf.body.sections);
206560
209283
  }
206561
209284
  function getElfFileContent(extractedLayers, searchedAction) {
206562
- const foundAppFiles = {};
206563
- for (const filePath of Object.keys(extractedLayers)) {
206564
- for (const actionName of Object.keys(extractedLayers[filePath])) {
206565
- if (actionName !== searchedAction) {
206566
- continue;
206567
- }
206568
- if (!isElfType(extractedLayers[filePath][actionName])) {
206569
- throw new Error("elf file expected to contain programs and sections");
206570
- }
206571
- foundAppFiles[filePath] = extractedLayers[filePath][actionName];
206572
- }
209285
+ let foundAppFiles;
209286
+ try {
209287
+ foundAppFiles = getContent(extractedLayers, searchedAction, isElfType);
209288
+ }
209289
+ catch (_a) {
209290
+ throw new Error("elf file expected to contain programs and sections");
206573
209291
  }
206574
209292
  return foundAppFiles;
206575
209293
  }
206576
209294
  exports.getElfFileContent = getElfFileContent;
209295
+ function isTypeBuffer(type) {
209296
+ return Buffer.isBuffer(type);
209297
+ }
209298
+ function getBufferContent(extractedLayers, searchedAction) {
209299
+ let foundAppFiles;
209300
+ try {
209301
+ foundAppFiles = getContent(extractedLayers, searchedAction, isTypeBuffer);
209302
+ }
209303
+ catch (_a) {
209304
+ throw new Error("expected Buffer");
209305
+ }
209306
+ return foundAppFiles;
209307
+ }
209308
+ exports.getBufferContent = getBufferContent;
206577
209309
  //# sourceMappingURL=index.js.map
206578
209310
 
206579
209311
  /***/ }),
@@ -206596,7 +209328,7 @@ function filePathMatches(filePath) {
206596
209328
  exports.getJarFileContentAction = {
206597
209329
  actionName: "jar",
206598
209330
  filePathMatches,
206599
- callback: stream_utils_1.streamToSha1,
209331
+ callback: stream_utils_1.streamToBuffer,
206600
209332
  };
206601
209333
  //# sourceMappingURL=static.js.map
206602
209334
 
@@ -206759,6 +209491,21 @@ exports.getRpmDbFileContent = getRpmDbFileContent;
206759
209491
 
206760
209492
  /***/ }),
206761
209493
 
209494
+ /***/ 48587:
209495
+ /***/ ((__unused_webpack_module, exports) => {
209496
+
209497
+ "use strict";
209498
+
209499
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
209500
+ exports.isTrue = void 0;
209501
+ function isTrue(value) {
209502
+ return String(value).toLowerCase() === "true";
209503
+ }
209504
+ exports.isTrue = isTrue;
209505
+ //# sourceMappingURL=option-utils.js.map
209506
+
209507
+ /***/ }),
209508
+
206762
209509
  /***/ 45062:
206763
209510
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
206764
209511
 
@@ -207014,6 +209761,7 @@ const image_inspector_1 = __webpack_require__(91379);
207014
209761
  const dockerfile_1 = __webpack_require__(79652);
207015
209762
  const image_save_path_1 = __webpack_require__(89313);
207016
209763
  const image_type_1 = __webpack_require__(38932);
209764
+ const option_utils_1 = __webpack_require__(48587);
207017
209765
  const staticModule = __webpack_require__(60317);
207018
209766
  const types_1 = __webpack_require__(93677);
207019
209767
  // Registry credentials may also be provided by env vars. When both are set, flags take precedence.
@@ -207030,6 +209778,9 @@ async function scan(options) {
207030
209778
  if (!options.path) {
207031
209779
  throw new Error("No image identifier or path provided");
207032
209780
  }
209781
+ if (option_utils_1.isTrue(options["shaded-jars"] && !option_utils_1.isTrue(options["app-vulns"]))) {
209782
+ throw new Error("To use shaded-jars, you must also use app-vulns");
209783
+ }
207033
209784
  const targetImage = appendLatestTagIfMissing(options.path);
207034
209785
  const dockerfilePath = options.file;
207035
209786
  const dockerfileAnalysis = await dockerfile_1.readDockerfileAndAnalyse(dockerfilePath);
@@ -207047,8 +209798,6 @@ async function scan(options) {
207047
209798
  exports.scan = scan;
207048
209799
  async function localArchiveAnalysis(targetImage, imageType, dockerfileAnalysis, options) {
207049
209800
  var _a, _b;
207050
- const excludeBaseImageVulns = isTrue(options["exclude-base-image-vulns"]);
207051
- const appScan = isTrue(options["app-vulns"]);
207052
209801
  const globToFind = {
207053
209802
  include: ((_a = options.globsToFind) === null || _a === void 0 ? void 0 : _a.include) || [],
207054
209803
  exclude: ((_b = options.globsToFind) === null || _b === void 0 ? void 0 : _b.exclude) || [],
@@ -207063,12 +209812,10 @@ async function localArchiveAnalysis(targetImage, imageType, dockerfileAnalysis,
207063
209812
  const imageIdentifier = options.imageNameAndTag ||
207064
209813
  // The target image becomes the base of the path, e.g. "archive.tar" for "/var/tmp/archive.tar"
207065
209814
  path.basename(archivePath);
207066
- return await staticModule.analyzeStatically(imageIdentifier, dockerfileAnalysis, imageType, archivePath, excludeBaseImageVulns, globToFind, appScan);
209815
+ return await staticModule.analyzeStatically(imageIdentifier, dockerfileAnalysis, imageType, archivePath, globToFind, options);
207067
209816
  }
207068
209817
  async function imageIdentifierAnalysis(targetImage, imageType, dockerfileAnalysis, options) {
207069
209818
  var _a, _b;
207070
- const excludeBaseImageVulns = isTrue(options["exclude-base-image-vulns"]);
207071
- const appScan = isTrue(options["app-vulns"]);
207072
209819
  const globToFind = {
207073
209820
  include: ((_a = options.globsToFind) === null || _a === void 0 ? void 0 : _a.include) || [],
207074
209821
  exclude: ((_b = options.globsToFind) === null || _b === void 0 ? void 0 : _b.exclude) || [],
@@ -207077,15 +209824,12 @@ async function imageIdentifierAnalysis(targetImage, imageType, dockerfileAnalysi
207077
209824
  const archiveResult = await image_inspector_1.getImageArchive(targetImage, imageSavePath, options.username, options.password, options.platform);
207078
209825
  const imagePath = archiveResult.path;
207079
209826
  try {
207080
- return await staticModule.analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, excludeBaseImageVulns, globToFind, appScan);
209827
+ return await staticModule.analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globToFind, options);
207081
209828
  }
207082
209829
  finally {
207083
209830
  archiveResult.removeArchive();
207084
209831
  }
207085
209832
  }
207086
- function isTrue(value) {
207087
- return String(value).toLowerCase() === "true";
207088
- }
207089
209833
  function appendLatestTagIfMissing(targetImage) {
207090
209834
  if (image_type_1.getImageType(targetImage) === types_1.ImageType.Identifier &&
207091
209835
  !targetImage.includes(":")) {
@@ -207107,14 +209851,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
207107
209851
  exports.analyzeStatically = void 0;
207108
209852
  const analyzer = __webpack_require__(55269);
207109
209853
  const dependency_tree_1 = __webpack_require__(95997);
209854
+ const option_utils_1 = __webpack_require__(48587);
207110
209855
  const parser_1 = __webpack_require__(45062);
207111
209856
  const response_builder_1 = __webpack_require__(75319);
207112
- async function analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, excludeBaseImageVulns, globsToFind, appScan) {
207113
- const staticAnalysis = await analyzer.analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, appScan);
209857
+ async function analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, options) {
209858
+ const staticAnalysis = await analyzer.analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, options);
207114
209859
  const parsedAnalysisResult = parser_1.parseAnalysisResults(targetImage, staticAnalysis);
207115
209860
  /** @deprecated Should try to build a dependency graph instead. */
207116
209861
  const dependenciesTree = await dependency_tree_1.buildTree(targetImage, parsedAnalysisResult.type, parsedAnalysisResult.depInfosList, parsedAnalysisResult.targetOS);
207117
209862
  const analysis = Object.assign(Object.assign({}, staticAnalysis), { depTree: dependenciesTree, imageId: parsedAnalysisResult.imageId, imageLayers: parsedAnalysisResult.imageLayers, packageManager: parsedAnalysisResult.type });
209863
+ const excludeBaseImageVulns = option_utils_1.isTrue(options["exclude-base-image-vulns"]);
207118
209864
  return response_builder_1.buildResponse(analysis, dockerfileAnalysis, excludeBaseImageVulns);
207119
209865
  }
207120
209866
  exports.analyzeStatically = analyzeStatically;