From 9d0f09a6b6c84de071b3d0f0366af15e8767d4fe Mon Sep 17 00:00:00 2001 From: Jozef Izso Date: Tue, 25 Jun 2024 23:28:35 +0200 Subject: [PATCH] Fix code formatting issues --- dist/index.js | 432 ++++++++++++++++++++++++---------------------- package-lock.json | 3 + src/main.ts | 1 - 3 files changed, 226 insertions(+), 210 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3528cdcb..89beb386 100644 --- a/dist/index.js +++ b/dist/index.js @@ -693,35 +693,34 @@ exports.DartJsonParser = DartJsonParser; /// reflects documentation at https://github.com/dart-lang/test/blob/master/pkgs/test/doc/json_reporter.md Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isMessageEvent = exports.isDoneEvent = exports.isErrorEvent = exports.isTestDoneEvent = exports.isTestStartEvent = exports.isGroupEvent = exports.isSuiteEvent = void 0; +exports.isSuiteEvent = isSuiteEvent; +exports.isGroupEvent = isGroupEvent; +exports.isTestStartEvent = isTestStartEvent; +exports.isTestDoneEvent = isTestDoneEvent; +exports.isErrorEvent = isErrorEvent; +exports.isDoneEvent = isDoneEvent; +exports.isMessageEvent = isMessageEvent; function isSuiteEvent(event) { return event.type === 'suite'; } -exports.isSuiteEvent = isSuiteEvent; function isGroupEvent(event) { return event.type === 'group'; } -exports.isGroupEvent = isGroupEvent; function isTestStartEvent(event) { return event.type === 'testStart'; } -exports.isTestStartEvent = isTestStartEvent; function isTestDoneEvent(event) { return event.type === 'testDone'; } -exports.isTestDoneEvent = isTestDoneEvent; function isErrorEvent(event) { return event.type === 'error'; } -exports.isErrorEvent = isErrorEvent; function isDoneEvent(event) { return event.type === 'done'; } -exports.isDoneEvent = isDoneEvent; function isMessageEvent(event) { return event.type === 'print'; } -exports.isMessageEvent = isMessageEvent; /***/ }), @@ -1247,7 +1246,7 @@ exports.JavaJunitParser = JavaJunitParser; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseStackTraceElement = void 0; +exports.parseStackTraceElement = parseStackTraceElement; // classloader and module name are optional: // at //(:) // https://github.com/eclipse-openj9/openj9/issues/11452#issuecomment-754946992 @@ -1267,7 +1266,6 @@ function parseStackTraceElement(stackTraceLine) { } return undefined; } -exports.parseStackTraceElement = parseStackTraceElement; function parseClassLoaderAndModule(maybeClassLoaderAndModuleNameAndVersion) { if (maybeClassLoaderAndModuleNameAndVersion) { const res = maybeClassLoaderAndModuleNameAndVersion.split('/'); @@ -1628,7 +1626,7 @@ exports.SwiftXunitParser = SwiftXunitParser; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getAnnotations = void 0; +exports.getAnnotations = getAnnotations; const markdown_utils_1 = __nccwpck_require__(6482); const parse_utils_1 = __nccwpck_require__(7811); function getAnnotations(results, maxCount) { @@ -1690,7 +1688,6 @@ function getAnnotations(results, maxCount) { }); return annotations; } -exports.getAnnotations = getAnnotations; function enforceCheckRunLimits(err) { err.title = (0, markdown_utils_1.ellipsis)(err.title || '', 255); err.message = (0, markdown_utils_1.ellipsis)(err.message, 65535); @@ -1738,7 +1735,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getReport = void 0; +exports.getReport = getReport; const core = __importStar(__nccwpck_require__(2186)); const markdown_utils_1 = __nccwpck_require__(6482); const node_utils_1 = __nccwpck_require__(5824); @@ -1775,7 +1772,6 @@ function getReport(results, options = defaultOptions) { core.warning(`Test report summary exceeded limit of ${getMaxReportLength(options)} bytes and will be trimmed`); return trimReport(lines, options); } -exports.getReport = getReport; function getMaxReportLength(options = defaultOptions) { return options.useActionsSummary ? MAX_ACTIONS_SUMMARY_LENGTH : MAX_REPORT_LENGTH; } @@ -2141,7 +2137,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.listFiles = void 0; +exports.listFiles = listFiles; const core = __importStar(__nccwpck_require__(2186)); const exec_1 = __nccwpck_require__(1514); async function listFiles() { @@ -2156,7 +2152,6 @@ async function listFiles() { } return output.split('\u0000').filter(s => s.length > 0); } -exports.listFiles = listFiles; function fixStdOutNullTermination() { // Previous command uses NULL as delimiters and output is printed to stdout. // We have to make sure next thing written to stdout will start on new line. @@ -2199,7 +2194,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.listFiles = exports.downloadArtifact = exports.getCheckRunContext = void 0; +exports.getCheckRunContext = getCheckRunContext; +exports.downloadArtifact = downloadArtifact; +exports.listFiles = listFiles; const fs_1 = __nccwpck_require__(7147); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); @@ -2227,7 +2224,6 @@ function getCheckRunContext() { } return { sha: github.context.sha, runId }; } -exports.getCheckRunContext = getCheckRunContext; async function downloadArtifact(octokit, artifactId, fileName, token) { core.startGroup(`Downloading artifact ${fileName}`); try { @@ -2254,7 +2250,6 @@ async function downloadArtifact(octokit, artifactId, fileName, token) { core.endGroup(); } } -exports.downloadArtifact = downloadArtifact; async function listFiles(octokit, sha) { core.startGroup('Fetching list of tracked files from GitHub'); try { @@ -2269,7 +2264,6 @@ async function listFiles(octokit, sha) { core.endGroup(); } } -exports.listFiles = listFiles; async function listGitTree(octokit, sha, path) { const pathLog = path ? ` at ${path}` : ''; core.info(`Fetching tree ${sha}${pathLog}`); @@ -2309,7 +2303,13 @@ async function listGitTree(octokit, sha, path) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.formatTime = exports.ellipsis = exports.fixEol = exports.tableEscape = exports.table = exports.link = exports.Icon = exports.Align = void 0; +exports.Icon = exports.Align = void 0; +exports.link = link; +exports.table = table; +exports.tableEscape = tableEscape; +exports.fixEol = fixEol; +exports.ellipsis = ellipsis; +exports.formatTime = formatTime; var Align; (function (Align) { Align["Left"] = ":---"; @@ -2325,36 +2325,30 @@ exports.Icon = { function link(title, address) { return `[${title}](${address})`; } -exports.link = link; function table(headers, align, ...rows) { const headerRow = `|${headers.map(tableEscape).join('|')}|`; const alignRow = `|${align.join('|')}|`; const contentRows = rows.map(row => `|${row.map(tableEscape).join('|')}|`).join('\n'); return [headerRow, alignRow, contentRows].join('\n'); } -exports.table = table; function tableEscape(content) { return content.toString().replace('|', '\\|'); } -exports.tableEscape = tableEscape; function fixEol(text) { return text?.replace(/\r/g, '') ?? ''; } -exports.fixEol = fixEol; function ellipsis(text, maxLength) { if (text.length <= maxLength) { return text; } return text.substr(0, maxLength - 3) + '...'; } -exports.ellipsis = ellipsis; function formatTime(ms) { if (ms > 1000) { return `${Math.round(ms / 1000)}s`; } return `${Math.round(ms)}ms`; } -exports.formatTime = formatTime; /***/ }), @@ -2365,7 +2359,8 @@ exports.formatTime = formatTime; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getExceptionSource = exports.DEFAULT_LOCALE = void 0; +exports.DEFAULT_LOCALE = void 0; +exports.getExceptionSource = getExceptionSource; const path_utils_1 = __nccwpck_require__(4070); exports.DEFAULT_LOCALE = 'en-US'; function getExceptionSource(stackTrace, trackedFiles, getRelativePath) { @@ -2390,7 +2385,6 @@ function getExceptionSource(stackTrace, trackedFiles, getRelativePath) { } } } -exports.getExceptionSource = getExceptionSource; /***/ }), @@ -2401,7 +2395,9 @@ exports.getExceptionSource = getExceptionSource; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getFirstNonEmptyLine = exports.parseIsoDate = exports.parseNetDuration = void 0; +exports.parseNetDuration = parseNetDuration; +exports.parseIsoDate = parseIsoDate; +exports.getFirstNonEmptyLine = getFirstNonEmptyLine; function parseNetDuration(str) { const durationRe = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)$/; const durationMatch = str.match(durationRe); @@ -2411,7 +2407,6 @@ function parseNetDuration(str) { const [_, hourStr, minStr, secStr] = durationMatch; return (parseInt(hourStr) * 3600 + parseInt(minStr) * 60 + parseFloat(secStr)) * 1000; } -exports.parseNetDuration = parseNetDuration; function parseIsoDate(str) { const isoDateRe = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)$/; if (str === undefined || !isoDateRe.test(str)) { @@ -2419,12 +2414,10 @@ function parseIsoDate(str) { } return new Date(str); } -exports.parseIsoDate = parseIsoDate; function getFirstNonEmptyLine(stackTrace) { const lines = stackTrace?.split(/\r?\n/g); return lines?.find(str => !/^\s*$/.test(str)); } -exports.getFirstNonEmptyLine = getFirstNonEmptyLine; /***/ }), @@ -2435,7 +2428,9 @@ exports.getFirstNonEmptyLine = getFirstNonEmptyLine; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBasePath = exports.normalizeFilePath = exports.normalizeDirPath = void 0; +exports.normalizeDirPath = normalizeDirPath; +exports.normalizeFilePath = normalizeFilePath; +exports.getBasePath = getBasePath; function normalizeDirPath(path, addTrailingSlash) { if (!path) { return path; @@ -2446,14 +2441,12 @@ function normalizeDirPath(path, addTrailingSlash) { } return path; } -exports.normalizeDirPath = normalizeDirPath; function normalizeFilePath(path) { if (!path) { return path; } return path.trim().replace(/\\/g, '/'); } -exports.normalizeFilePath = normalizeFilePath; function getBasePath(path, trackedFiles) { if (trackedFiles.includes(path)) { return ''; @@ -2470,7 +2463,6 @@ function getBasePath(path, trackedFiles) { const base = path.substr(0, path.length - max.length); return base; } -exports.getBasePath = getBasePath; /***/ }), @@ -2481,7 +2473,7 @@ exports.getBasePath = getBasePath; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.slug = void 0; +exports.slug = slug; // Returns HTML element id and href link usable as manual anchor links // This is needed because Github in check run summary doesn't automatically // create links out of headings as it normally does for other markdown content @@ -2495,7 +2487,6 @@ function slug(name) { const link = `#${slugId}`; return { id, link }; } -exports.slug = slug; /***/ }), @@ -11373,7 +11364,7 @@ module.exports = function (/**String*/ input, /** object */ options) { // prepare new entry if (!update) { entry = new ZipEntry(); - entry.entryName = entryName; + entry.entryName = Utils.canonical(entryName); } entry.comment = comment || ""; @@ -11408,6 +11399,8 @@ module.exports = function (/**String*/ input, /** object */ options) { entry.setData(content); if (!update) _zip.setEntry(entry); + + return entry; }, /** @@ -11415,7 +11408,8 @@ module.exports = function (/**String*/ input, /** object */ options) { * * @return Array */ - getEntries: function () { + getEntries: function (/**String*/ password) { + _zip.password = password; return _zip ? _zip.entries : []; }, @@ -11492,7 +11486,7 @@ module.exports = function (/**String*/ input, /** object */ options) { return true; } - var content = item.getData(); + var content = item.getData(_zip.password); if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE); if (filetools.fs.existsSync(target) && !overwrite) { @@ -11578,13 +11572,20 @@ module.exports = function (/**String*/ input, /** object */ options) { * @param callback The callback will be executed when all entries are extracted successfully or any error is thrown. */ extractAllToAsync: function (/**String*/ targetPath, /**Boolean*/ overwrite, /**Boolean*/ keepOriginalPermission, /**Function*/ callback) { + if (typeof overwrite === "function" && !callback) callback = overwrite; overwrite = get_Bool(overwrite, false); if (typeof keepOriginalPermission === "function" && !callback) callback = keepOriginalPermission; keepOriginalPermission = get_Bool(keepOriginalPermission, false); if (!callback) { - callback = function (err) { - throw new Error(err); - }; + return new Promise((resolve, reject) => { + this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function (err) { + if (err) { + reject(err); + } else { + resolve(this); + } + }); + }); } if (!_zip) { callback(new Error(Utils.Errors.NO_ZIP)); @@ -11598,12 +11599,12 @@ module.exports = function (/**String*/ input, /** object */ options) { // separate directories from files const dirEntries = []; - const fileEntries = new Set(); + const fileEntries = []; _zip.entries.forEach((e) => { if (e.isDirectory) { dirEntries.push(e); } else { - fileEntries.add(e); + fileEntries.push(e); } }); @@ -11623,47 +11624,38 @@ module.exports = function (/**String*/ input, /** object */ options) { } } - // callback wrapper, for some house keeping - const done = () => { - if (fileEntries.size === 0) { - callback(); - } - }; - - // Extract file entries asynchronously - for (const entry of fileEntries.values()) { - const entryName = pth.normalize(canonical(entry.entryName.toString())); - const filePath = sanitize(targetPath, entryName); - entry.getDataAsync(function (content, err_1) { - if (err_1) { - callback(new Error(err_1)); - return; - } - if (!content) { - callback(new Error(Utils.Errors.CANT_EXTRACT_FILE)); + fileEntries.reverse().reduce(function (next, entry) { + return function (err) { + if (err) { + next(err); } else { - // The reverse operation for attr depend on method addFile() - const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined; - filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function (succ) { - if (!succ) { - callback(getError("Unable to write file", filePath)); - return; + const entryName = pth.normalize(canonical(entry.entryName.toString())); + const filePath = sanitize(targetPath, entryName); + entry.getDataAsync(function (content, err_1) { + if (err_1) { + next(new Error(err_1)); + } else if (!content) { + next(new Error(Utils.Errors.CANT_EXTRACT_FILE)); + } else { + // The reverse operation for attr depend on method addFile() + const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined; + filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function (succ) { + if (!succ) { + next(getError("Unable to write file", filePath)); + } + filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function (err_2) { + if (err_2) { + next(getError("Unable to set times", filePath)); + } else { + next(); + } + }); + }); } - filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function (err_2) { - if (err_2) { - callback(getError("Unable to set times", filePath)); - return; - } - fileEntries.delete(entry); - // call the callback if it was last entry - done(); - }); }); } - }); - } - // call the callback if fileEntries was empty - done(); + }; + }, callback)(); }, /** @@ -11762,7 +11754,7 @@ module.exports = function () { // Without it file names may be corrupted for other apps when file names use unicode chars _flags |= Constants.FLG_EFS; - var _dataHeader = {}; + var _localHeader = {}; function setTime(val) { val = new Date(val); @@ -11820,7 +11812,9 @@ module.exports = function () { set time(val) { setTime(val); }, - + get timeHighByte() { + return (_time >>> 8) & 0xff; + }, get crc() { return _crc; }, @@ -11896,29 +11890,29 @@ module.exports = function () { _offset = Math.max(0, val) >>> 0; }, - get encripted() { + get encrypted() { return (_flags & 1) === 1; }, - get entryHeaderSize() { + get centralHeaderSize() { return Constants.CENHDR + _fnameLen + _extraLen + _comLen; }, get realDataOffset() { - return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen; + return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen; }, - get dataHeader() { - return _dataHeader; + get localHeader() { + return _localHeader; }, - loadDataHeaderFromBinary: function (/*Buffer*/ input) { + loadLocalHeaderFromBinary: function (/*Buffer*/ input) { var data = input.slice(_offset, _offset + Constants.LOCHDR); // 30 bytes and should start with "PK\003\004" if (data.readUInt32LE(0) !== Constants.LOCSIG) { throw new Error(Utils.Errors.INVALID_LOC); } - _dataHeader = { + _localHeader = { // version needed to extract version: data.readUInt16LE(Constants.LOCVER), // general purpose bit flag @@ -11977,7 +11971,7 @@ module.exports = function () { _offset = data.readUInt32LE(Constants.CENOFF); }, - dataHeaderToBinary: function () { + localHeaderToBinary: function () { // LOC header size (30 bytes) var data = Buffer.alloc(Constants.LOCHDR); // "PK\003\004" @@ -12003,7 +11997,7 @@ module.exports = function () { return data; }, - entryHeaderToBinary: function () { + centralHeaderToBinary: function () { // CEN header size (46 bytes) var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen); // "PK\001\002" @@ -12064,7 +12058,7 @@ module.exports = function () { inAttr: _inattr, attr: _attr, offset: _offset, - entryHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen) + centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen) }; }, @@ -12218,7 +12212,8 @@ module.exports = function () { } }; }; - // Misspelled +// Misspelled + /***/ }), @@ -12275,16 +12270,19 @@ exports.ZipCrypto = __nccwpck_require__(3228); /***/ 2153: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = function (/*Buffer*/ inbuf) { +const version = +(process.versions ? process.versions.node : "").split(".")[0] || 0; + +module.exports = function (/*Buffer*/ inbuf, /*number*/ expectedLength) { var zlib = __nccwpck_require__(9796); + const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {}; return { inflate: function () { - return zlib.inflateRawSync(inbuf); + return zlib.inflateRawSync(inbuf, option); }, inflateAsync: function (/*Function*/ callback) { - var tmp = zlib.createInflateRaw(), + var tmp = zlib.createInflateRaw(option), parts = [], total = 0; tmp.on("data", function (data) { @@ -12434,8 +12432,12 @@ function decrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd) { // 2. decrypt salt what is always 12 bytes and is a part of file content const salt = decrypter(data.slice(0, 12)); - // 3. does password meet expectations - if (salt[11] !== header.crc >>> 24) { + // if bit 3 (0x08) of the general-purpose flags field is set, check salt[11] with the high byte of the header time + // 2 byte data block (as per Info-Zip spec), otherwise check with the high byte of the header entry + const verifyByte = (header.flags & 0x8) === 0x8 ? header.timeHighByte : header.crc >>> 24; + + //3. does password meet expectations + if (salt[11] !== verifyByte) { throw "ADM-ZIP: Wrong Password"; } @@ -12667,6 +12669,7 @@ module.exports = { /* ADM-ZIP error messages */ CANT_EXTRACT_FILE: "Could not extract the file", CANT_OVERRIDE: "Target file already exists", + DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large", NO_ZIP: "No zip file was loaded", NO_ENTRY: "Entry doesn't exist", DIRECTORY_CONTENT_ERROR: "A directory cannot have content", @@ -13057,7 +13060,7 @@ var Utils = __nccwpck_require__(5182), Methods = __nccwpck_require__(3928); module.exports = function (/*Buffer*/ input) { - var _entryHeader = new Headers.EntryHeader(), + var _centralHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, @@ -13065,17 +13068,18 @@ module.exports = function (/*Buffer*/ input) { _extra = Buffer.alloc(0); function getCompressedDataFromZip() { - if (!input || !Buffer.isBuffer(input)) { + //if (!input || !Buffer.isBuffer(input)) { + if (!input || !(input instanceof Uint8Array)) { return Buffer.alloc(0); } - _entryHeader.loadDataHeaderFromBinary(input); - return input.slice(_entryHeader.realDataOffset, _entryHeader.realDataOffset + _entryHeader.compressedSize); + _centralHeader.loadLocalHeaderFromBinary(input); + return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize); } function crc32OK(data) { // 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 - if ((_entryHeader.flags & 0x8) !== 0x8) { - if (Utils.crc32(data) !== _entryHeader.dataHeader.crc) { + if ((_centralHeader.flags & 0x8) !== 0x8) { + if (Utils.crc32(data) !== _centralHeader.localHeader.crc) { return false; } } else { @@ -13106,16 +13110,16 @@ module.exports = function (/*Buffer*/ input) { return compressedData; } - if (_entryHeader.encripted) { + if (_centralHeader.encrypted) { if ("string" !== typeof pass && !Buffer.isBuffer(pass)) { throw new Error("ADM-ZIP: Incompatible password parameter"); } - compressedData = Methods.ZipCrypto.decrypt(compressedData, _entryHeader, pass); + compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass); } - var data = Buffer.alloc(_entryHeader.size); + var data = Buffer.alloc(_centralHeader.size); - switch (_entryHeader.method) { + switch (_centralHeader.method) { case Utils.Constants.STORED: compressedData.copy(data); if (!crc32OK(data)) { @@ -13127,7 +13131,7 @@ module.exports = function (/*Buffer*/ input) { return data; } case Utils.Constants.DEFLATED: - var inflater = new Methods.Inflater(compressedData); + var inflater = new Methods.Inflater(compressedData, _centralHeader.size); if (!async) { const result = inflater.inflate(data); result.copy(data, 0); @@ -13164,9 +13168,9 @@ module.exports = function (/*Buffer*/ input) { if (uncompressedData.length && !_isDirectory) { var compressedData; // Local file header - switch (_entryHeader.method) { + switch (_centralHeader.method) { case Utils.Constants.STORED: - _entryHeader.compressedSize = _entryHeader.size; + _centralHeader.compressedSize = _centralHeader.size; compressedData = Buffer.alloc(uncompressedData.length); uncompressedData.copy(compressedData); @@ -13178,12 +13182,12 @@ module.exports = function (/*Buffer*/ input) { var deflater = new Methods.Deflater(uncompressedData); if (!async) { var deflated = deflater.deflate(); - _entryHeader.compressedSize = deflated.length; + _centralHeader.compressedSize = deflated.length; return deflated; } else { deflater.deflateAsync(function (data) { compressedData = Buffer.alloc(data.length); - _entryHeader.compressedSize = data.length; + _centralHeader.compressedSize = data.length; data.copy(compressedData); callback && callback(compressedData); }); @@ -13224,26 +13228,26 @@ module.exports = function (/*Buffer*/ input) { if (data.length >= Constants.EF_ZIP64_SCOMP) { size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP); - if (_entryHeader.size === Constants.EF_ZIP64_OR_32) { - _entryHeader.size = size; + if (_centralHeader.size === Constants.EF_ZIP64_OR_32) { + _centralHeader.size = size; } } if (data.length >= Constants.EF_ZIP64_RHO) { compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP); - if (_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) { - _entryHeader.compressedSize = compressedSize; + if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) { + _centralHeader.compressedSize = compressedSize; } } if (data.length >= Constants.EF_ZIP64_DSN) { offset = readUInt64LE(data, Constants.EF_ZIP64_RHO); - if (_entryHeader.offset === Constants.EF_ZIP64_OR_32) { - _entryHeader.offset = offset; + if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) { + _centralHeader.offset = offset; } } if (data.length >= Constants.EF_ZIP64_DSN + 4) { diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN); - if (_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) { - _entryHeader.diskNumStart = diskNumStart; + if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) { + _centralHeader.diskNumStart = diskNumStart; } } } @@ -13259,7 +13263,7 @@ module.exports = function (/*Buffer*/ input) { _entryName = Utils.toBuffer(val); var lastChar = _entryName[_entryName.length - 1]; _isDirectory = lastChar === 47 || lastChar === 92; - _entryHeader.fileNameLength = _entryName.length; + _centralHeader.fileNameLength = _entryName.length; }, get extra() { @@ -13267,7 +13271,7 @@ module.exports = function (/*Buffer*/ input) { }, set extra(val) { _extra = val; - _entryHeader.extraLength = val.length; + _centralHeader.extraLength = val.length; parseExtra(val); }, @@ -13276,7 +13280,7 @@ module.exports = function (/*Buffer*/ input) { }, set comment(val) { _comment = Utils.toBuffer(val); - _entryHeader.commentLength = _comment.length; + _centralHeader.commentLength = _comment.length; }, get name() { @@ -13303,18 +13307,18 @@ module.exports = function (/*Buffer*/ input) { setData: function (value) { uncompressedData = Utils.toBuffer(value); if (!_isDirectory && uncompressedData.length) { - _entryHeader.size = uncompressedData.length; - _entryHeader.method = Utils.Constants.DEFLATED; - _entryHeader.crc = Utils.crc32(value); - _entryHeader.changed = true; + _centralHeader.size = uncompressedData.length; + _centralHeader.method = Utils.Constants.DEFLATED; + _centralHeader.crc = Utils.crc32(value); + _centralHeader.changed = true; } else { // folders and blank files should be stored - _entryHeader.method = Utils.Constants.STORED; + _centralHeader.method = Utils.Constants.STORED; } }, getData: function (pass) { - if (_entryHeader.changed) { + if (_centralHeader.changed) { return uncompressedData; } else { return decompress(false, null, pass); @@ -13322,7 +13326,7 @@ module.exports = function (/*Buffer*/ input) { }, getDataAsync: function (/*Function*/ callback, pass) { - if (_entryHeader.changed) { + if (_centralHeader.changed) { callback(uncompressedData); } else { decompress(true, callback, pass); @@ -13330,39 +13334,59 @@ module.exports = function (/*Buffer*/ input) { }, set attr(attr) { - _entryHeader.attr = attr; + _centralHeader.attr = attr; }, get attr() { - return _entryHeader.attr; + return _centralHeader.attr; }, set header(/*Buffer*/ data) { - _entryHeader.loadFromBinary(data); + _centralHeader.loadFromBinary(data); }, get header() { - return _entryHeader; + return _centralHeader; }, - packHeader: function () { + packCentralHeader: function () { // 1. create header (buffer) - var header = _entryHeader.entryHeaderToBinary(); + var header = _centralHeader.centralHeaderToBinary(); var addpos = Utils.Constants.CENHDR; // 2. add file name _entryName.copy(header, addpos); addpos += _entryName.length; // 3. add extra data - if (_entryHeader.extraLength) { + if (_centralHeader.extraLength) { _extra.copy(header, addpos); - addpos += _entryHeader.extraLength; + addpos += _centralHeader.extraLength; } // 4. add file comment - if (_entryHeader.commentLength) { + if (_centralHeader.commentLength) { _comment.copy(header, addpos); } return header; }, + packLocalHeader: function () { + let addpos = 0; + + // 1. construct local header Buffer + const localHeaderBuf = _centralHeader.localHeaderToBinary(); + // 2. localHeader - crate header buffer + const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _extra.length); + // 2.1 add localheader + localHeaderBuf.copy(localHeader, addpos); + addpos += localHeaderBuf.length; + // 2.2 add file name + _entryName.copy(localHeader, addpos); + addpos += _entryName.length; + // 2.3 add extra field + _extra.copy(localHeader, addpos); + addpos += _extra.length; + + return localHeader; + }, + toJSON: function () { const bytes = function (nr) { return "<" + ((nr && nr.length + " bytes buffer") || "null") + ">"; @@ -13373,7 +13397,7 @@ module.exports = function (/*Buffer*/ input) { name: this.name, comment: this.comment, isDirectory: this.isDirectory, - header: _entryHeader.toJSON(), + header: _centralHeader.toJSON(), compressedData: bytes(input), data: bytes(uncompressedData) }; @@ -13401,6 +13425,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false; + var password = null; // assign options const opts = Object.assign(Object.create(null), options); @@ -13426,7 +13451,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { entry.header = inBuffer.slice(tmp, (tmp += Utils.Constants.CENHDR)); entry.entryName = inBuffer.slice(tmp, (tmp += entry.header.fileNameLength)); - index += entry.header.entryHeaderSize; + index += entry.header.centralHeaderSize; callback(entry); } @@ -13435,6 +13460,9 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { function readEntries() { loadedEntries = true; entryTable = {}; + if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) { + throw new Error(Utils.Errors.DISK_ENTRY_TOO_LARGE); + } entryList = new Array(mainHeader.diskEntries); // total number of entries var index = mainHeader.offset; // offset of first CEN header for (var i = 0; i < entryList.length; i++) { @@ -13450,7 +13478,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength); - index += entry.header.entryHeaderSize; + index += entry.header.centralHeaderSize; entryList[i] = entry; entryTable[entry.entryName] = entry; @@ -13635,7 +13663,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { sortEntries(); const dataBlock = []; - const entryHeaders = []; + const headerBlocks = []; let totalSize = 0; let dindex = 0; @@ -13645,30 +13673,25 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { for (const entry of entryList) { // compress data and set local and entry header accordingly. Reason why is called first const compressedData = entry.getCompressedData(); - // 1. construct data header entry.header.offset = dindex; - const dataHeader = entry.header.dataHeaderToBinary(); - const entryNameLen = entry.rawEntryName.length; - // 1.2. postheader - data after data header - const postHeader = Buffer.alloc(entryNameLen + entry.extra.length); - entry.rawEntryName.copy(postHeader, 0); - postHeader.copy(entry.extra, entryNameLen); + + // 1. construct local header + const localHeader = entry.packLocalHeader(); // 2. offsets - const dataLength = dataHeader.length + postHeader.length + compressedData.length; + const dataLength = localHeader.length + compressedData.length; dindex += dataLength; // 3. store values in sequence - dataBlock.push(dataHeader); - dataBlock.push(postHeader); + dataBlock.push(localHeader); dataBlock.push(compressedData); - // 4. construct entry header - const entryHeader = entry.packHeader(); - entryHeaders.push(entryHeader); + // 4. construct central header + const centralHeader = entry.packCentralHeader(); + headerBlocks.push(centralHeader); // 5. update main header - mainHeader.size += entryHeader.length; - totalSize += dataLength + entryHeader.length; + mainHeader.size += centralHeader.length; + totalSize += dataLength + centralHeader.length; } totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length @@ -13684,7 +13707,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { } // write central directory entries - for (const content of entryHeaders) { + for (const content of headerBlocks) { content.copy(outBuffer, dindex); dindex += content.length; } @@ -13707,7 +13730,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { sortEntries(); const dataBlock = []; - const entryHeaders = []; + const centralHeaders = []; let totalSize = 0; let dindex = 0; @@ -13715,29 +13738,30 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { mainHeader.offset = 0; const compress2Buffer = function (entryLists) { - if (entryLists.length) { - const entry = entryLists.pop(); + if (entryLists.length > 0) { + const entry = entryLists.shift(); const name = entry.entryName + entry.extra.toString(); if (onItemStart) onItemStart(name); entry.getCompressedDataAsync(function (compressedData) { if (onItemEnd) onItemEnd(name); - entry.header.offset = dindex; - // data header - const dataHeader = entry.header.dataHeaderToBinary(); - const postHeader = Buffer.alloc(name.length, name); - const dataLength = dataHeader.length + postHeader.length + compressedData.length; + // 1. construct local header + const localHeader = entry.packLocalHeader(); + + // 2. offsets + const dataLength = localHeader.length + compressedData.length; dindex += dataLength; - dataBlock.push(dataHeader); - dataBlock.push(postHeader); + // 3. store values in sequence + dataBlock.push(localHeader); dataBlock.push(compressedData); - const entryHeader = entry.packHeader(); - entryHeaders.push(entryHeader); - mainHeader.size += entryHeader.length; - totalSize += dataLength + entryHeader.length; + // central header + const centalHeader = entry.packCentralHeader(); + centralHeaders.push(centalHeader); + mainHeader.size += centalHeader.length; + totalSize += dataLength + centalHeader.length; compress2Buffer(entryLists); }); @@ -13752,7 +13776,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { content.copy(outBuffer, dindex); // write data blocks dindex += content.length; }); - entryHeaders.forEach(function (content) { + centralHeaders.forEach(function (content) { content.copy(outBuffer, dindex); // write central directory entries dindex += content.length; }); @@ -13768,7 +13792,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) { } }; - compress2Buffer(entryList); + compress2Buffer(Array.from(entryList)); } catch (e) { onFail(e); } @@ -26833,31 +26857,21 @@ module.exports.CancelError = CancelError; "use strict"; -const os = __nccwpck_require__(2037); const pico = __nccwpck_require__(3322); - -const isWindows = os.platform() === 'win32'; +const utils = __nccwpck_require__(479); function picomatch(glob, options, returnState = false) { // default to os.platform() if (options && (options.windows === null || options.windows === undefined)) { // don't mutate the original options object - options = { ...options, windows: isWindows }; + options = { ...options, windows: utils.isWindows() }; } + return pico(glob, options, returnState); } +Object.assign(picomatch, pico); module.exports = picomatch; -// public api -module.exports.test = pico.test; -module.exports.matchBase = pico.matchBase; -module.exports.isMatch = pico.isMatch; -module.exports.parse = pico.parse; -module.exports.scan = pico.scan; -module.exports.compileRe = pico.compileRe; -module.exports.toRegex = pico.toRegex; -// for tests -module.exports.makeRe = pico.makeRe; /***/ }), @@ -27264,8 +27278,8 @@ const parse = (input, options) => { if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { + prev.output = (prev.output || prev.value) + tok.value; prev.value += tok.value; - prev.output = (prev.output || '') + tok.value; return; } @@ -27753,10 +27767,6 @@ const parse = (input, options) => { const next = peek(); let output = value; - if (next === '<' && !utils.supportsLookbehinds()) { - throw new Error('Node.js v10 or higher is required for regex lookbehinds'); - } - if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) { output = `\\${value}`; } @@ -28898,6 +28908,7 @@ module.exports = scan; /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; +/*global navigator*/ const { @@ -28913,22 +28924,25 @@ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/'); +exports.isWindows = () => { + if (typeof navigator !== 'undefined' && navigator.platform) { + const platform = navigator.platform.toLowerCase(); + return platform === 'win32' || platform === 'windows'; + } + + if (typeof process !== 'undefined' && process.platform) { + return process.platform === 'win32'; + } + + return false; +}; + exports.removeBackslashes = str => { return str.replace(REGEX_REMOVE_BACKSLASH, match => { return match === '\\' ? '' : match; }); }; -exports.supportsLookbehinds = () => { - if (typeof process !== 'undefined') { - const segs = process.version.slice(1).split('.').map(Number); - if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) { - return true; - } - } - return false; -}; - exports.escapeLast = (input, char, lastIdx) => { const idx = input.lastIndexOf(char, lastIdx); if (idx === -1) return input; diff --git a/package-lock.json b/package-lock.json index 6f0c3e8f..e78c8904 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,9 @@ "prettier": "^3.3.2", "ts-jest": "^29.1.5", "typescript": "^5.5.2" + }, + "engines": { + "node": ">=20" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/src/main.ts b/src/main.ts index 97dcd605..31eda0df 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,5 @@ import * as core from '@actions/core' import * as github from '@actions/github' -import * as fs from 'fs' import {GitHub} from '@actions/github/lib/utils' import {ArtifactProvider} from './input-providers/artifact-provider'