Repository navigation
Run tar from its resolved path when extracting zstd bundles #4281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ const MIN_REQUIRED_GNU_TAR_VERSION = "1.31"; | |
| export type TarVersion = { | ||
| type: "gnu" | "bsd"; | ||
| version: string; | ||
| /** Path to the `tar` executable that reported this version. */ | ||
| path: string; | ||
| }; | ||
|
|
||
| async function getTarVersion(): Promise<TarVersion> { | ||
|
|
@@ -39,14 +41,14 @@ async function getTarVersion(): Promise<TarVersion> { | |
| throw new Error("Failed to parse output of tar --version."); | ||
| } | ||
|
|
||
| return { type: "gnu", version: match[1] }; | ||
| return { type: "gnu", version: match[1], path: tar }; | ||
| } else if (stdout.includes("bsdtar")) { | ||
| const match = stdout.match(/bsdtar ([0-9.]+)/); | ||
| if (!match?.[1]) { | ||
| throw new Error("Failed to parse output of tar --version."); | ||
| } | ||
|
|
||
| return { type: "bsd", version: match[1] }; | ||
| return { type: "bsd", version: match[1], path: tar }; | ||
| } else { | ||
| throw new Error("Unknown tar version"); | ||
| } | ||
|
|
@@ -171,10 +173,10 @@ export async function extractTarZst( | |
|
|
||
| args.push("-f", tar instanceof stream.Readable ? "-" : tar, "-C", dest); | ||
|
|
||
| process.stdout.write(`[command]tar ${args.join(" ")}\n`); | ||
| process.stdout.write(`[command]${tarVersion.path} ${args.join(" ")}\n`); | ||
|
|
||
| await new Promise<void>((resolve, reject) => { | ||
| const tarProcess = spawn("tar", args, { stdio: "pipe" }); | ||
| const tarProcess = spawn(tarVersion.path, args, { stdio: "pipe" }); | ||
|
Comment on lines
-174
to
+179
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a change in this PR, but is there a reason here why this doesn't use e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afaict, we can't pipe in a HTTP stream with |
||
|
|
||
| let stdout = ""; | ||
| tarProcess.stdout?.on("data", (data: Buffer) => { | ||
|
|
@@ -210,11 +212,11 @@ export async function extractTarZst( | |
| if (code !== 0) { | ||
| reject( | ||
| new CommandInvocationError( | ||
| "tar", | ||
| tarVersion.path, | ||
| args, | ||
| code ?? undefined, | ||
| stdout, | ||
| stderr, | ||
| stdout, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a follow up improvement to the binary planting custom CodeQL query to cover this.