fix(native): keep echoed codesign paths out of signature fields (#865)
codesign echoes the executable path and signing identifier verbatim, and an ad hoc identifier derives from the file name. A file name with line breaks added forged Authority lines, a signed file named after codesign's unsigned message was reported unsigned, and path text could supply entitlements. Parse display fields after the exact echoed path and identifier, classify unsigned output by exit status, and read requirements and entitlements from stdout. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4e17be5705
commit
4aa2b60c1d
Vendored
+22
-4
@@ -55,6 +55,27 @@ const outputFor = async (
|
||||
throw new Error(`Unexpected fixture tool ${tool}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* codesign prints display diagnostics to stderr and requirements or
|
||||
* entitlements to stdout.
|
||||
*/
|
||||
const fixtureStreams = (
|
||||
tool: string,
|
||||
arguments_: readonly string[],
|
||||
output: string,
|
||||
) => {
|
||||
const stderr =
|
||||
tool === "codesign" &&
|
||||
!arguments_.includes("-r-") &&
|
||||
!arguments_.includes("--entitlements");
|
||||
return {
|
||||
stdout: stderr ? "" : output,
|
||||
stderr: stderr ? output : "",
|
||||
stdoutBytes: Buffer.byteLength(stderr ? "" : output),
|
||||
stderrBytes: Buffer.byteLength(stderr ? output : ""),
|
||||
};
|
||||
};
|
||||
|
||||
const capture = (
|
||||
tool: string,
|
||||
arguments_: readonly string[],
|
||||
@@ -66,10 +87,7 @@ const capture = (
|
||||
toolVersion: null,
|
||||
versionReason: "fixture",
|
||||
arguments: [...arguments_],
|
||||
stdout: tool === "codesign" ? "" : output,
|
||||
stderr: tool === "codesign" ? output : "",
|
||||
stdoutBytes: Buffer.byteLength(tool === "codesign" ? "" : output),
|
||||
stderrBytes: Buffer.byteLength(tool === "codesign" ? output : ""),
|
||||
...fixtureStreams(tool, arguments_, output),
|
||||
exitCode: 0,
|
||||
signal: null,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user