From bb4c482f33ad30daa78861daafbd38fcefea9fe2 Mon Sep 17 00:00:00 2001 From: Daniel Kennedy Date: Mon, 26 Jan 2026 15:07:34 -0500 Subject: [PATCH] Fix some linting issues --- .../__tests__/download-artifact.test.ts | 21 ++++++++++++----- .../internal/download/download-artifact.ts | 23 +++++++++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/packages/artifact/__tests__/download-artifact.test.ts b/packages/artifact/__tests__/download-artifact.test.ts index 496cfd14..3865e20b 100644 --- a/packages/artifact/__tests__/download-artifact.test.ts +++ b/packages/artifact/__tests__/download-artifact.test.ts @@ -687,7 +687,8 @@ describe('download-artifact', () => { const message = new http.IncomingMessage(new net.Socket()) message.statusCode = 200 message.headers['content-type'] = 'text/plain' - message.headers['content-disposition'] = `attachment; filename="${rawFileName}"` + message.headers['content-disposition'] = + `attachment; filename="${rawFileName}"` message.push(Buffer.from(rawFileContent)) message.push(null) return { @@ -753,13 +754,16 @@ describe('download-artifact', () => { it('should not attempt to unzip when content-type is image/png', async () => { const pngFileName = 'screenshot.png' // Simple PNG header bytes for testing - const pngContent = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) + const pngContent = Buffer.from([ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a + ]) const mockGetPngFile = jest.fn(() => { const message = new http.IncomingMessage(new net.Socket()) message.statusCode = 200 message.headers['content-type'] = 'image/png' - message.headers['content-disposition'] = `attachment; filename="${pngFileName}"` + message.headers['content-disposition'] = + `attachment; filename="${pngFileName}"` message.push(pngContent) message.push(null) return { @@ -851,7 +855,8 @@ describe('download-artifact', () => { const message = new http.IncomingMessage(new net.Socket()) message.statusCode = 200 message.headers['content-type'] = 'text/plain' - message.headers['content-disposition'] = `attachment; filename="${maliciousFileName}"` + message.headers['content-disposition'] = + `attachment; filename="${maliciousFileName}"` message.push(Buffer.from(rawFileContent)) message.push(null) return { @@ -880,7 +885,10 @@ describe('download-artifact', () => { expect(fs.readFileSync(savedFilePath, 'utf8')).toBe(rawFileContent) // Verify the file was NOT written outside the workspace directory - const maliciousPath = path.resolve(fixtures.workspaceDir, maliciousFileName) + const maliciousPath = path.resolve( + fixtures.workspaceDir, + maliciousFileName + ) expect(fs.existsSync(maliciousPath)).toBe(false) }) @@ -893,7 +901,8 @@ describe('download-artifact', () => { const message = new http.IncomingMessage(new net.Socket()) message.statusCode = 200 message.headers['content-type'] = 'application/octet-stream' - message.headers['content-disposition'] = `attachment; filename="${encodedMaliciousFileName}"` + message.headers['content-disposition'] = + `attachment; filename="${encodedMaliciousFileName}"` message.push(Buffer.from(rawFileContent)) message.push(null) return { diff --git a/packages/artifact/src/internal/download/download-artifact.ts b/packages/artifact/src/internal/download/download-artifact.ts index 4a144974..bed06385 100644 --- a/packages/artifact/src/internal/download/download-artifact.ts +++ b/packages/artifact/src/internal/download/download-artifact.ts @@ -99,8 +99,12 @@ export async function streamExtractExternal( fileName = path.basename(decodeURIComponent(filenameMatch[1].trim())) } - core.debug(`Content-Type: ${contentType}, isZip: ${isZip}, skipDecompress: ${skipDecompress}`) - core.debug(`Content-Disposition: ${contentDisposition}, fileName: ${fileName}`) + core.debug( + `Content-Type: ${contentType}, isZip: ${isZip}, skipDecompress: ${skipDecompress}` + ) + core.debug( + `Content-Disposition: ${contentDisposition}, fileName: ${fileName}` + ) let sha256Digest: string | undefined = undefined @@ -115,18 +119,16 @@ export async function streamExtractExternal( const timer = setTimeout(timerFn, timeout) const onError = (error: Error): void => { - core.debug( - `response.message: Artifact download failed: ${error.message}` - ) + core.debug(`response.message: Artifact download failed: ${error.message}`) clearTimeout(timer) reject(error) } const hashStream = crypto.createHash('sha256').setEncoding('hex') - const passThrough = new stream.PassThrough() + const passThrough = new stream.PassThrough() .on('data', () => { - timer.refresh() - }) + timer.refresh() + }) .on('error', onError) response.message.pipe(passThrough) @@ -144,7 +146,10 @@ export async function streamExtractExternal( if (isZip && !skipDecompress) { // Extract zip file - passThrough.pipe(unzip.Extract({path: directory})).on('close', onClose).on('error', onError) + passThrough + .pipe(unzip.Extract({path: directory})) + .on('close', onClose) + .on('error', onError) } else { // Save raw file without extracting const filePath = path.join(directory, fileName)