fix(native): bind signature observations to registered target versions (#1099)
* fix(native): bind signature observations to registered target versions * fix(native): preserve target drift and cancellation across signature captures * fix(native): inspect signatures from a verified byte snapshot
This commit is contained in:
Vendored
+16
-1
@@ -1,3 +1,4 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import type { BinaryTarget } from "../../src/domain/binaryTarget.js";
|
||||
import { ok } from "../../src/domain/result.js";
|
||||
@@ -96,7 +97,10 @@ const capture = (
|
||||
export const nativeMachoTarget = (
|
||||
path: string,
|
||||
sourcePath?: string,
|
||||
): BinaryTarget => ({
|
||||
): BinaryTarget & {
|
||||
readonly kind: "executable";
|
||||
readonly format: "mach-o";
|
||||
} => ({
|
||||
path,
|
||||
...(sourcePath === undefined ? {} : { sourcePath }),
|
||||
sha256: "0".repeat(64),
|
||||
@@ -106,6 +110,17 @@ export const nativeMachoTarget = (
|
||||
availableArchitectures: ["x86_64", "arm64"],
|
||||
});
|
||||
|
||||
/** Register the actual bytes of a filesystem-backed native test target. */
|
||||
export const nativeMachoTargetForFile = async (
|
||||
path: string,
|
||||
sourcePath?: string,
|
||||
): Promise<ReturnType<typeof nativeMachoTarget>> => ({
|
||||
...nativeMachoTarget(path, sourcePath),
|
||||
sha256: createHash("sha256")
|
||||
.update(await readFile(path))
|
||||
.digest("hex"),
|
||||
});
|
||||
|
||||
/** Load one captured native tool output. */
|
||||
export const nativeFixture = (name: string): Promise<string> =>
|
||||
readFile(new URL(`./native-macos/${name}`, import.meta.url), "utf8");
|
||||
|
||||
Reference in New Issue
Block a user