Merge pull request #32471 from backstage/freben/tar
upgrade to `tar` v7
This commit is contained in:
@@ -187,7 +187,7 @@
|
||||
"rate-limit-redis": "^4.2.0",
|
||||
"raw-body": "^2.4.1",
|
||||
"selfsigned": "^2.0.0",
|
||||
"tar": "^6.1.12",
|
||||
"tar": "^7.5.6",
|
||||
"triple-beam": "^1.4.1",
|
||||
"uuid": "^11.0.0",
|
||||
"winston": "^3.2.1",
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import platformPath, { dirname } from 'path';
|
||||
import getRawBody from 'raw-body';
|
||||
import fs from 'fs-extra';
|
||||
import { promisify } from 'util';
|
||||
import tar from 'tar';
|
||||
import * as tar from 'tar';
|
||||
import { pipeline as pipelineCb, Readable } from 'stream';
|
||||
import { FromReadableArrayOptions } from '../types';
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import fs from 'fs-extra';
|
||||
import { resolve as resolvePath, join as joinPath } from 'path';
|
||||
import { TarArchiveResponse } from './TarArchiveResponse';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import tar from 'tar';
|
||||
import * as tar from 'tar';
|
||||
|
||||
const archiveData = fs.readFileSync(
|
||||
resolvePath(__filename, '../../__fixtures__/mock-main.tar.gz'),
|
||||
|
||||
@@ -24,13 +24,11 @@ import concatStream from 'concat-stream';
|
||||
import fs from 'fs-extra';
|
||||
import platformPath from 'path';
|
||||
import { pipeline as pipelineCb, Readable } from 'stream';
|
||||
import tar, { FileStat, Parse, ParseStream, ReadEntry } from 'tar';
|
||||
import * as tar from 'tar';
|
||||
import type { ReadEntry } from 'tar';
|
||||
import { promisify } from 'util';
|
||||
import { stripFirstDirectoryFromPath } from './util';
|
||||
|
||||
// Tar types for `Parse` is not a proper constructor, but it should be
|
||||
const TarParseStream = Parse as unknown as { new (): ParseStream };
|
||||
|
||||
const pipeline = promisify(pipelineCb);
|
||||
|
||||
/**
|
||||
@@ -85,7 +83,7 @@ export class TarArchiveResponse implements UrlReaderServiceReadTreeResponse {
|
||||
this.onlyOnce();
|
||||
|
||||
const files = Array<UrlReaderServiceReadTreeResponseFile>();
|
||||
const parser = new TarParseStream();
|
||||
const parser = new tar.Parser();
|
||||
|
||||
parser.on('entry', (entry: ReadEntry & Readable) => {
|
||||
if (entry.type === 'Directory') {
|
||||
@@ -184,7 +182,7 @@ export class TarArchiveResponse implements UrlReaderServiceReadTreeResponse {
|
||||
}
|
||||
|
||||
// Block symlinks/hardlinks that escape the extraction directory
|
||||
const entry = stat as FileStat & { type?: string; linkpath?: string };
|
||||
const entry = stat as ReadEntry;
|
||||
if (
|
||||
(entry.type === 'SymbolicLink' || entry.type === 'Link') &&
|
||||
entry.linkpath
|
||||
|
||||
Reference in New Issue
Block a user