fix(native): flag nested-code paths that codesign split on newlines
codesign prints one nested path per line, so a nested component whose name contains a newline is split into fragments. inspect_signature now checks that every --validated: path it reports exists, and names any that does not in a limitation instead of trusting it as a complete path. The result stays deterministic: codesign's progress lines arrive in no fixed order, so the raw output is not echoed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4f46836178
commit
949ab427fb
@@ -141,3 +141,28 @@ export const SIGNATURE_POSTURE_LIMITATIONS = [
|
||||
"Signature verification is local `codesign --verify --deep --strict`; certificate revocation, Gatekeeper policy, and Apple's notarization records are not checked.",
|
||||
"Security facets are derived from CodeDirectory flags and entitlements; runtime policy such as System Integrity Protection, AMFI, and setuid bits can further restrict a process.",
|
||||
];
|
||||
|
||||
/**
|
||||
* codesign prints one nested path per line, so a path that contains a newline
|
||||
* is split into fragments. A reported path that does not exist on disk is
|
||||
* named in a limitation instead of being trusted as complete.
|
||||
*/
|
||||
export const unconfirmedNestedCode = async (
|
||||
verification: NonNullable<InspectSignature["verification"]>,
|
||||
): Promise<string[]> => {
|
||||
const missing: string[] = [];
|
||||
for (const path of verification.validated_nested_code)
|
||||
try {
|
||||
await lstat(path);
|
||||
} catch (cause: unknown) {
|
||||
const code = errorCode(cause);
|
||||
// A denied lookup cannot confirm the path, but is no sign of a split one.
|
||||
if (code === "EACCES" || code === "EPERM") continue;
|
||||
if (code !== "ENOENT" && code !== "ENOTDIR") throw cause;
|
||||
missing.push(path);
|
||||
}
|
||||
return missing.map(
|
||||
(path) =>
|
||||
`codesign reported validated nested code at ${JSON.stringify(path)}, which does not exist; a nested path probably contains a newline, so validated_nested_code and diagnostics hold fragments of it.`,
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user