fix: correct native inventories and bridge error classification (#503)
* fix(hopper): preserve normalized inventory addresses * test(hopper): isolate real inventory verification * fix(native): preserve otool addresses and section alignment * fix: preserve address spaces in call path evidence * fix(hopper): distinguish request validation from provider faults * fix(native): retain tool inventory facts and reject failed signatures
This commit is contained in:
@@ -147,6 +147,26 @@ describe("call path reconstruction", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves address spaces and encoded names when normalizing offsets", () => {
|
||||
const result = run(
|
||||
[
|
||||
observe("0x1000", ["EXTERNAL:0x001000"]),
|
||||
observe("EXTERNAL:0x1000", ["overlay%3Atext:0x00004000"]),
|
||||
],
|
||||
{
|
||||
goal: { address: "overlay%3Atext:0X004000" },
|
||||
},
|
||||
);
|
||||
expect(
|
||||
result.paths.map((path) => path.nodes.map(({ address }) => address)),
|
||||
).toEqual([["0x1000", "EXTERNAL:0x1000", "overlay%3Atext:0x4000"]]);
|
||||
expect(() =>
|
||||
run([observe("0x1000", [])], {
|
||||
goal: { address: "overlay%ZZ:0x4000" },
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("requires an observed start function", () => {
|
||||
expect(() => run([observe("0x2000", [])])).toThrow(
|
||||
/supplied for start 0x1000/u,
|
||||
|
||||
@@ -2,14 +2,22 @@ import { z } from "zod";
|
||||
|
||||
import { evidenceSchema } from "./evidence.js";
|
||||
|
||||
const addressSchema = z.string().regex(/^0x(?:0|[1-9a-f][0-9a-f]*)$/u);
|
||||
const addressSchema = z
|
||||
.string()
|
||||
.regex(/^(?:(?:[A-Za-z0-9._~-]|%[0-9A-F]{2})+:)?0x(?:0|[1-9a-f][0-9a-f]*)$/u);
|
||||
const inputAddressSchema = z
|
||||
.string()
|
||||
.regex(/^0[xX][0-9a-fA-F]+$/u)
|
||||
.transform((address) => `0x${BigInt(address).toString(16)}`);
|
||||
.regex(/^(?:(?:[A-Za-z0-9._~-]|%[0-9a-fA-F]{2})+:)?0[xX][0-9a-fA-F]+$/u)
|
||||
.transform((address) => {
|
||||
const separator = address.lastIndexOf(":") + 1;
|
||||
const space = address
|
||||
.slice(0, separator)
|
||||
.replace(/%[0-9a-fA-F]{2}/gu, (escape) => escape.toUpperCase());
|
||||
return `${space}0x${BigInt(address.slice(separator)).toString(16)}`;
|
||||
});
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
|
||||
/** Parse a caller-supplied hexadecimal address into canonical form. */
|
||||
/** Normalize a hexadecimal offset while preserving its optional address space. */
|
||||
export const parseCallPathAddress = (input: unknown): string =>
|
||||
inputAddressSchema.parse(input);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user