diff --git a/packages/artifact/__tests__/download-artifact.test.ts b/packages/artifact/__tests__/download-artifact.test.ts index 3f0efc9d..7e93d1b4 100644 --- a/packages/artifact/__tests__/download-artifact.test.ts +++ b/packages/artifact/__tests__/download-artifact.test.ts @@ -13,7 +13,7 @@ import { streamExtractExternal } from '../src/internal/download/download-artifact' import {getUserAgentString} from '../src/internal/shared/user-agent' -//import {noopLogs} from './common' +import {noopLogs} from './common' import * as config from '../src/internal/shared/config' import {ArtifactServiceClientJSON} from '../src/generated' import * as util from '../src/internal/shared/util' @@ -88,7 +88,7 @@ const expectExtractedArchive = async (dir: string): Promise => { } const setup = async (): Promise => { - //noopLogs() + noopLogs() await fs.promises.mkdir(testDir, {recursive: true}) await createTestArchive() @@ -200,12 +200,14 @@ describe('download-artifact', () => { } ) - await expect(downloadArtifactPublic( - fixtures.artifactID, - fixtures.repositoryOwner, - fixtures.repositoryName, - fixtures.token - )).rejects.toBeInstanceOf(Error) + await expect( + downloadArtifactPublic( + fixtures.artifactID, + fixtures.repositoryOwner, + fixtures.repositoryName, + fixtures.token + ) + ).rejects.toBeInstanceOf(Error) expect(downloadArtifactMock).toHaveBeenCalledWith({ owner: fixtures.repositoryOwner, diff --git a/packages/artifact/src/internal/download/download-artifact.ts b/packages/artifact/src/internal/download/download-artifact.ts index 1c6c8ec2..3c2c26eb 100644 --- a/packages/artifact/src/internal/download/download-artifact.ts +++ b/packages/artifact/src/internal/download/download-artifact.ts @@ -47,7 +47,9 @@ async function streamExtract(url: string, directory: string): Promise { return } catch (error) { if (error.message.includes('Malformed extraction path')) { - throw new Error(`Artifact download failed with unretryable error: ${error.message}`) + throw new Error( + `Artifact download failed with unretryable error: ${error.message}` + ) } retryCount++ core.debug( @@ -99,7 +101,7 @@ export async function streamExtractExternal( .pipe(unzip.Parse()) .on('entry', (entry: unzip.Entry) => { const fullPath = path.normalize(path.join(directory, entry.path)) - if (fullPath.indexOf(directory) !== 0) { + if (!fullPath.startsWith(directory)) { reject(new Error(`Malformed extraction path: ${fullPath}`)) }