fix(artifacts): diagnose unpacked ASAR integrity failures
This commit is contained in:
@@ -195,7 +195,7 @@ const translateFailure = (
|
||||
cause: unknown,
|
||||
): AnalysisError => {
|
||||
if (cause instanceof ArtifactReaderFailure)
|
||||
return new ArtifactOperationError(operation, cause.reason);
|
||||
return new ArtifactOperationError(operation, cause.reason, cause.details);
|
||||
return new ArtifactOperationError(operation, "io");
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export interface ArtifactEntry {
|
||||
readonly encrypted: boolean;
|
||||
readonly byteOffset: number | null;
|
||||
readonly declaredSha256: string | null;
|
||||
readonly unpacked: boolean;
|
||||
readonly limitations: readonly string[];
|
||||
readonly adapterKey: string;
|
||||
/** Filesystem identity captured during traversal, when supplied by an adapter. */
|
||||
@@ -51,6 +52,12 @@ export class ArtifactReaderFailure extends Error {
|
||||
| "unavailable",
|
||||
message: string,
|
||||
options?: ErrorOptions,
|
||||
readonly details?: Readonly<{
|
||||
logicalPath: string;
|
||||
declaredSha256: string | null;
|
||||
calculatedSha256: string | null;
|
||||
unpacked: boolean;
|
||||
}>,
|
||||
) {
|
||||
super(message, options);
|
||||
this.name = "ArtifactReaderFailure";
|
||||
|
||||
@@ -43,6 +43,7 @@ export class AsarArtifactReader implements ArtifactReader {
|
||||
/^[a-f0-9]{64}$/u.test(metadata.integrity.hash)
|
||||
? metadata.integrity.hash
|
||||
: null,
|
||||
unpacked: "unpacked" in metadata && metadata.unpacked === true,
|
||||
limitations:
|
||||
kind === "symlink"
|
||||
? ["ASAR symlink target was not followed or disclosed."]
|
||||
|
||||
@@ -59,6 +59,7 @@ export class DirectoryArtifactReader implements ArtifactReader {
|
||||
encrypted: false,
|
||||
byteOffset: null,
|
||||
declaredSha256: null,
|
||||
unpacked: false,
|
||||
limitations:
|
||||
kind === "symlink"
|
||||
? ["Symlink target was not followed or disclosed."]
|
||||
|
||||
@@ -62,6 +62,7 @@ export class MachOSliceArtifactReader implements ArtifactReader {
|
||||
encrypted: false,
|
||||
byteOffset: architecture.file_offset,
|
||||
declaredSha256: null,
|
||||
unpacked: false,
|
||||
limitations: [],
|
||||
adapterKey: `${String(architecture.file_offset)}:${String(architecture.size)}`,
|
||||
};
|
||||
|
||||
@@ -69,6 +69,7 @@ export class ZipArtifactReader implements ArtifactReader {
|
||||
encrypted: entry.encrypted,
|
||||
byteOffset: null,
|
||||
declaredSha256: null,
|
||||
unpacked: false,
|
||||
limitations: symlink ? ["Archive symlink target was not read."] : [],
|
||||
adapterKey: entry.filename,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user