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
@@ -33,7 +33,7 @@ describe("native macOS provider discovery and inspection", () => {
|
||||
"preserves the exact signing identifier %j reported by codesign",
|
||||
(identifier) => {
|
||||
const parsed = parseCodeSignature(
|
||||
`Identifier=${identifier}\nTeamIdentifier=not set\nFormat=Mach-O thin (arm64)\n`,
|
||||
`Identifier=${identifier}\nFormat=Mach-O thin (arm64)\nTeamIdentifier=not set\n`,
|
||||
false,
|
||||
);
|
||||
expect(parsed.identifier).toBe(identifier);
|
||||
@@ -42,6 +42,32 @@ describe("native macOS provider discovery and inspection", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("separates echoed path and identifier text from signature fields", () => {
|
||||
const path = "/apps/x\nAuthority=Forged\nIdentifier=forged";
|
||||
const identifier = "x\nFormat=forged\nAuthority=Forged-5555";
|
||||
const parsed = parseCodeSignature(
|
||||
[
|
||||
`Executable=${path}`,
|
||||
`Identifier=${identifier}`,
|
||||
"Format=Mach-O thin (arm64)",
|
||||
"CodeDirectory v=20400 size=342 flags=0x2(adhoc) hashes=2+2",
|
||||
"CDHash=6aee90e6",
|
||||
"Signature=adhoc",
|
||||
"TeamIdentifier=not set",
|
||||
"",
|
||||
].join("\r\n"),
|
||||
false,
|
||||
["/elsewhere", path],
|
||||
);
|
||||
expect(parsed).toMatchObject({
|
||||
identifier,
|
||||
format: "Mach-O thin (arm64)",
|
||||
authorities: [],
|
||||
cdhashes: ["6aee90e6"],
|
||||
team_identifier: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("retries a failed native tool resolution and caches only success", async () => {
|
||||
let resolutions = 0;
|
||||
const runner = new XcrunCommandRunner((tool) => {
|
||||
|
||||
Reference in New Issue
Block a user