fix(artifacts): name only host-available workflows for non-archive plists
inspect_keyed_archive runs on every host, but its remediation for an ordinary property list pointed to inspect_plist, which only macOS supports. On Linux that sent callers to a workflow the capability layer rejects. The domain error now names what the file is. The artifact reader picks the remediation from the provider's host: inspect_plist on macOS, and elsewhere the selection of an NSKeyedArchiver archive, with a note that inspect_plist requires macOS. decode_interface_builder, which is portable, stays the NIBArchive remediation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fef38e4d22
commit
22958558ea
@@ -43,9 +43,11 @@ import { resolveArtifactIntegrityPolicy } from "./inventory/policy.js";
|
||||
/** Read-only inventory and exclusively owned extraction provider. */
|
||||
export class ArtifactProvider implements AnalysisProvider {
|
||||
readonly #capabilities: readonly CapabilityDescriptor[];
|
||||
readonly #platform: NodeJS.Platform;
|
||||
|
||||
constructor(platform: NodeJS.Platform = process.platform) {
|
||||
this.#capabilities = artifactCapabilities(platform);
|
||||
this.#platform = platform;
|
||||
}
|
||||
|
||||
identity(): ProviderIdentity {
|
||||
@@ -57,12 +59,15 @@ export class ArtifactProvider implements AnalysisProvider {
|
||||
}
|
||||
|
||||
createClient(target: BinaryTarget): AnalysisClient {
|
||||
return new ArtifactClient(target);
|
||||
return new ArtifactClient(target, this.#platform);
|
||||
}
|
||||
}
|
||||
|
||||
class ArtifactClient implements AnalysisClient {
|
||||
constructor(private readonly target: BinaryTarget) {}
|
||||
constructor(
|
||||
private readonly target: BinaryTarget,
|
||||
private readonly platform: NodeJS.Platform,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
operation: AnalysisOperation,
|
||||
@@ -146,6 +151,7 @@ class ArtifactClient implements AnalysisClient {
|
||||
parameters: standalone
|
||||
? { ...parameters, path: basename(this.target.path) }
|
||||
: parameters,
|
||||
platform: this.platform,
|
||||
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
||||
});
|
||||
if (standalone && result.archive_sha256 !== this.target.sha256)
|
||||
|
||||
@@ -40,7 +40,7 @@ export const decodeKeyedArchiveBytes = (
|
||||
if (bytes.subarray(0, 10).toString("ascii") === "NIBArchive")
|
||||
throw new KeyedArchiveKindError(
|
||||
"Selected file is a compiled NIBArchive, not a Foundation plist archive; decode it with decode_interface_builder",
|
||||
"Decode compiled NIBArchive files with decode_interface_builder on the app bundle.",
|
||||
"nib-archive",
|
||||
);
|
||||
const binary = bytes.subarray(0, 8).toString("ascii") === "bplist00";
|
||||
const xmlText = binary ? undefined : decodeXmlPlistText(bytes);
|
||||
@@ -87,12 +87,29 @@ const normalizePlist = (value: unknown): JsonValue => {
|
||||
return projected.value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Point to the workflow that reads the selected kind of file on this host.
|
||||
* decode_interface_builder is portable; inspect_plist requires macOS.
|
||||
*/
|
||||
const keyedArchiveKindRemediation = (
|
||||
kind: KeyedArchiveKindError["kind"],
|
||||
platform: NodeJS.Platform,
|
||||
): string => {
|
||||
if (kind === "nib-archive")
|
||||
return "Decode compiled NIBArchive files with decode_interface_builder on the app bundle.";
|
||||
return platform === "darwin"
|
||||
? "Inspect an ordinary property list with inspect_plist; inspect_keyed_archive decodes NSKeyedArchiver archives only."
|
||||
: "Select an NSKeyedArchiver archive; inspect_keyed_archive decodes only those. inspect_plist, which reads ordinary property lists, requires a macOS host.";
|
||||
};
|
||||
|
||||
/** Read exactly one regular, contained bundle entry without following symlinks. */
|
||||
export const inspectBundleKeyedArchive = async (input: {
|
||||
bundlePath: string;
|
||||
targetSha256: string;
|
||||
parameters: unknown;
|
||||
signal?: AbortSignal;
|
||||
/** Host whose available workflows the remediation names. */
|
||||
platform?: NodeJS.Platform;
|
||||
}) => {
|
||||
const selected = keyedArchiveInputSchema.parse(input.parameters);
|
||||
if (
|
||||
@@ -159,7 +176,13 @@ export const inspectBundleKeyedArchive = async (input: {
|
||||
"inspect_keyed_archive",
|
||||
join(input.bundlePath, entry.path),
|
||||
cause.message,
|
||||
{ cause, remediationAction: cause.remediationAction },
|
||||
{
|
||||
cause,
|
||||
remediationAction: keyedArchiveKindRemediation(
|
||||
cause.kind,
|
||||
input.platform ?? process.platform,
|
||||
),
|
||||
},
|
||||
);
|
||||
throw new ArtifactReaderFailure(
|
||||
cause instanceof RangeError ? "limit" : "format",
|
||||
|
||||
Reference in New Issue
Block a user