fix: integrate 14 approved fix PRs (668,671,673,675,678-681,685-690) (#705)
* fix(javascript): preserve array index positions Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): respect object property overwrite order Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * test(javascript): cover uncertain spread discriminants Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): keep nonfinite values outside JSON lattice Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): keep non-CIL method implementations unknown Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * test(package): separate CIL reconstruction from native imports Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): invalidate values on nontrivial binding writes Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(artifacts): align native DMG mount and detach lifecycle Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): retain all literal worker import arguments Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): preserve final demangled symbol whitespace Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): preserve C identifier underscores in native matching Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): respect metadata key and overwrite semantics Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): keep optional parameter input unknown Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): report observed method metadata changes Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * docs(dotnet): synchronize generated conformance skill digest Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): reject malformed indexed source-map offsets Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): preserve numeric-looking Mach-O identifiers Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * docs: regenerate catalogs for integrated fix batch * docs: regenerate catalogs after merging main (#702) --------- Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> Co-authored-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
@@ -225,6 +225,47 @@ describe("web source-map fetching and validation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("indexed source-map offsets", () => {
|
||||
it.each([
|
||||
{ line: 0, column: -1 },
|
||||
{ line: -1, column: 0 },
|
||||
{ line: 0, column: "1" },
|
||||
{ line: "0", column: 0 },
|
||||
{ line: 0, column: 0.5 },
|
||||
{ line: 0.5, column: 0 },
|
||||
{ line: 0 },
|
||||
{ line: 0, column: Number.MAX_SAFE_INTEGER + 1 },
|
||||
])("retains an invalid-map item for malformed offset %j", async (offset) => {
|
||||
const result = await fetchWebSourceMaps([request], input(), undefined, {
|
||||
fetch: () =>
|
||||
Promise.resolve(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
sections: [
|
||||
{
|
||||
offset,
|
||||
map: {
|
||||
version: 3,
|
||||
names: [],
|
||||
sources: ["original.js"],
|
||||
sourcesContent: ["export const stable = 1;"],
|
||||
mappings: "AAAA",
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
{ status: 200 },
|
||||
),
|
||||
),
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
status: "unavailable",
|
||||
items: [{ status: "invalid", artifact: null, mappings: [] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("web source-map sourcesContent validation", () => {
|
||||
it.each([
|
||||
["a scalar sourcesContent value", { sourcesContent: "source" }],
|
||||
|
||||
@@ -70,6 +70,25 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
});
|
||||
|
||||
it("keeps additions unknown when spread coverage is incomplete", async () => {
|
||||
const [left, right] = await analyzeSources({
|
||||
left: `
|
||||
const dynamic = getDynamic();
|
||||
export default () => ({ ...dynamic, type: "heading" });
|
||||
`,
|
||||
right: `
|
||||
const dynamic = getDynamic();
|
||||
export default () => ({ depth: 1, ...dynamic, type: "heading" });
|
||||
`,
|
||||
});
|
||||
const result = compare(left, right);
|
||||
|
||||
expect(result.changes).toEqual([
|
||||
expect.objectContaining({ status: "unknown", path: "/depth" }),
|
||||
]);
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
});
|
||||
|
||||
it("does not pair discriminants that an unknown trailing spread can overwrite", async () => {
|
||||
const [left, right] = await analyzeSources({
|
||||
left: `
|
||||
const dynamic = getDynamic();
|
||||
@@ -83,9 +102,29 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
const result = compare(left, right);
|
||||
|
||||
expect(result.changes).toEqual([
|
||||
expect.objectContaining({ status: "unknown", path: "/depth" }),
|
||||
expect.objectContaining({
|
||||
status: "unknown",
|
||||
path: "",
|
||||
discriminant: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
status: "unknown",
|
||||
path: "",
|
||||
discriminant: null,
|
||||
}),
|
||||
]);
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
expect(result.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 2,
|
||||
});
|
||||
expect(result.coverage).toMatchObject({
|
||||
status: "partial",
|
||||
paired_variants: 0,
|
||||
unpaired_left_variants: 1,
|
||||
unpaired_right_variants: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not pair ambiguous variants or invent behavior for no-return exports", async () => {
|
||||
|
||||
@@ -18,6 +18,42 @@ import { inspectManagedMembersBytes } from "../../../../src/dotnet/ManagedMember
|
||||
import { managedPeFixtureTarget } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
import { buildManagedPeFixture } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
|
||||
it.each([
|
||||
["accessibility", 6, 0x0011],
|
||||
["synchronized implementation", 4, 0x0020],
|
||||
])(
|
||||
"reports changed observed method %s despite identical CIL",
|
||||
async (_name, flagOffset, flags) => {
|
||||
const directory = await createTestTempDirectory("rea-managed-flags-");
|
||||
const leftPath = join(directory, "left.dll");
|
||||
const rightPath = join(directory, "right.dll");
|
||||
const left = buildManagedPeFixture();
|
||||
const inspection = inspectManagedMembersBytes(
|
||||
left,
|
||||
managedPeFixtureTarget(left, leftPath),
|
||||
);
|
||||
const method = inspection.methods[0];
|
||||
if (method === undefined) throw new Error("missing method fixture");
|
||||
const right = Buffer.from(left);
|
||||
right.writeUInt16LE(flags, method.row_offset + flagOffset);
|
||||
await writeFile(leftPath, left);
|
||||
await writeFile(rightPath, right);
|
||||
const result = await compareManagedMemberPaths({ leftPath, rightPath });
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
const comparison = managedMemberComparisonResultSchema.parse(
|
||||
result.value.normalized_result,
|
||||
);
|
||||
expect(comparison.methods[0]).toMatchObject({
|
||||
status: "changed",
|
||||
dimensions: ["metadata"],
|
||||
});
|
||||
expect(comparison.methods[0]?.left?.normalized_il_sha256).toBe(
|
||||
comparison.methods[0]?.right?.normalized_il_sha256,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
describe("managed member comparison path workflow", () => {
|
||||
it("preserves undecoded signatures as unknown through content-addressed partial Evidence", () => {
|
||||
const observe = (signature: number, path: string) => {
|
||||
|
||||
@@ -181,3 +181,53 @@ it("retains U+FEFF metadata through the filesystem target and provider", async (
|
||||
fields: [expect.objectContaining({ name: "\uFEFFcounter" })],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps non-CIL implementation bytes unknown through the real file provider", async () => {
|
||||
const directory = await createTestTempDirectory("rea-managed-native-body-");
|
||||
const path = join(directory, "fixture.exe");
|
||||
const bytes = buildManagedPeFixture();
|
||||
await writeFile(path, bytes);
|
||||
const originalTarget = await parseBinaryTarget(path);
|
||||
expect(originalTarget.ok).toBe(true);
|
||||
if (!originalTarget.ok) return;
|
||||
const original = await new ManagedStaticProvider()
|
||||
.createClient(originalTarget.value)
|
||||
.execute("inspect_managed_members", {});
|
||||
expect(original.ok).toBe(true);
|
||||
if (!original.ok) return;
|
||||
const row = asManagedMemberResult(original.value).methods[0]?.row_offset;
|
||||
expect(row).toBeDefined();
|
||||
if (row === undefined) return;
|
||||
bytes.writeUInt16LE(1, row + 4);
|
||||
await writeFile(path, bytes);
|
||||
const nativeTarget = await parseBinaryTarget(path);
|
||||
expect(nativeTarget.ok).toBe(true);
|
||||
if (!nativeTarget.ok) return;
|
||||
const native = await new ManagedStaticProvider()
|
||||
.createClient(nativeTarget.value)
|
||||
.execute("inspect_managed_members", {});
|
||||
expect(native.ok).toBe(true);
|
||||
if (!native.ok) return;
|
||||
const result = asManagedMemberResult(native.value);
|
||||
expect(result.methods[0]?.body).toMatchObject({
|
||||
status: "partial",
|
||||
rva: 0x2800,
|
||||
il_sha256: null,
|
||||
anchors: [],
|
||||
});
|
||||
expect(result.call_edges).toEqual([]);
|
||||
expect(result.field_accesses).toEqual([]);
|
||||
bytes.writeUInt32LE(0, row);
|
||||
await writeFile(path, bytes);
|
||||
const absentTarget = await parseBinaryTarget(path);
|
||||
expect(absentTarget.ok).toBe(true);
|
||||
if (!absentTarget.ok) return;
|
||||
const absent = await new ManagedStaticProvider()
|
||||
.createClient(absentTarget.value)
|
||||
.execute("inspect_managed_members", {});
|
||||
expect(absent.ok).toBe(true);
|
||||
if (!absent.ok) return;
|
||||
expect(asManagedMemberResult(absent.value).methods[0]?.body.status).toBe(
|
||||
"absent",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { mkdir, realpath, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { build } from "plist";
|
||||
@@ -81,3 +81,47 @@ describe("native DMG artifact reader", () => {
|
||||
).rejects.toThrow("cleanup could not detach every device");
|
||||
});
|
||||
});
|
||||
|
||||
it("owns the canonical mount root and detaches each observed whole image once", async () => {
|
||||
const calls: string[][] = [];
|
||||
const host: NativeDmgHost = {
|
||||
async run(arguments_) {
|
||||
calls.push([...arguments_]);
|
||||
if (arguments_[0] !== "attach") return { stdout: "", exitCode: 0 };
|
||||
const mountRoot = arguments_[arguments_.indexOf("-mountroot") + 1];
|
||||
if (mountRoot === undefined) throw new Error("missing mount root");
|
||||
expect(mountRoot).toBe(await realpath(mountRoot));
|
||||
const mountPoint = join(await realpath(mountRoot), "Fixture");
|
||||
await mkdir(mountPoint);
|
||||
await writeFile(join(mountPoint, "hello.txt"), "hello");
|
||||
return {
|
||||
stdout: build({
|
||||
"system-entities": [
|
||||
{ "dev-entry": "/dev/disk41" },
|
||||
{ "dev-entry": "/dev/disk41s1" },
|
||||
{ "dev-entry": "/dev/disk41s2", "mount-point": mountPoint },
|
||||
{ "dev-entry": "/dev/disk42" },
|
||||
{ "dev-entry": "/dev/disk42s1" },
|
||||
],
|
||||
}),
|
||||
exitCode: 0,
|
||||
};
|
||||
},
|
||||
};
|
||||
const reader = await NativeDmgArtifactReader.create(
|
||||
"/tmp/image.dmg",
|
||||
undefined,
|
||||
host,
|
||||
);
|
||||
try {
|
||||
const entries = [];
|
||||
for await (const entry of reader.entries()) entries.push(entry.path);
|
||||
expect(entries).toContain("image.dmg/Fixture/hello.txt");
|
||||
} finally {
|
||||
await reader.close();
|
||||
}
|
||||
expect(calls.filter((call) => call[0] === "detach")).toEqual([
|
||||
["detach", "/dev/disk42"],
|
||||
["detach", "/dev/disk41"],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { NativeMacOSProvider } from "../../../../src/native/NativeMacOSProvider.js";
|
||||
import { parseOtoolLoadCommands } from "../../../../src/native/parsers/otool.js";
|
||||
import { parseDyldSymbols } from "../../../../src/native/parsers/dyldInfo.js";
|
||||
import {
|
||||
NativeFixtureRunner as FixtureRunner,
|
||||
@@ -166,3 +167,36 @@ it("retains symbol names containing spaces in dyld inventory rows", () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("preserves numeric-looking segment and section identifiers from otool", () => {
|
||||
const parsed = parseOtoolLoadCommands(`Load command 1
|
||||
cmd LC_SEGMENT_64
|
||||
cmdsize 152
|
||||
segname 0001
|
||||
vmaddr 0x0000000000004000
|
||||
vmsize 0x0000000000004000
|
||||
fileoff 16384
|
||||
filesize 16384
|
||||
maxprot 0x00000003
|
||||
initprot 0x00000003
|
||||
nsects 1
|
||||
flags 0x4
|
||||
Section
|
||||
sectname 0002
|
||||
segname 0001
|
||||
addr 0x0000000000004000
|
||||
size 0x0000000000000008
|
||||
offset 16384
|
||||
align 2^0 (1)
|
||||
reloff 0
|
||||
nreloc 0
|
||||
flags 0x00000000
|
||||
reserved1 0
|
||||
reserved2 0
|
||||
`);
|
||||
expect(parsed.segments[0]).toMatchObject({
|
||||
name: "0001",
|
||||
file_offset: 16384,
|
||||
sections: [{ segment: "0001", name: "0002", size: 8 }],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
managedNativeVerificationResultSchema,
|
||||
verifyManagedNativeBoundaries,
|
||||
} from "../../../../src/domain/managedNativeVerification.js";
|
||||
import { managedNativeBoundaryInspectionSchema } from "../../../../src/domain/managedArtifact.js";
|
||||
import { inspectMachoSchema } from "../../../../src/domain/nativeInspection.js";
|
||||
|
||||
const exampleInput = () =>
|
||||
@@ -263,3 +264,48 @@ describe("managed/native verification result algebra", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not erase a C identifier underscore beyond the Mach-O ABI prefix", () => {
|
||||
const result = verifyManagedNativeBoundaries({
|
||||
...exampleInput(),
|
||||
native_observations: [nativeEvidenceWithExports(["__open_native"])],
|
||||
});
|
||||
expect(result.summary).toMatchObject({ inferred: 0, unresolved: 1 });
|
||||
expect(result.pinvoke_imports[0]).toMatchObject({
|
||||
status: "unresolved",
|
||||
candidates: [],
|
||||
matched_native: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not treat a raw Mach-O ABI name as an exact underscored C identifier", () => {
|
||||
const input = exampleInput();
|
||||
const managed = input.managed_boundaries;
|
||||
const normalized = managedNativeBoundaryInspectionSchema.parse(
|
||||
managed.normalized_result,
|
||||
);
|
||||
const imports = normalized.pinvoke_imports;
|
||||
const result = verifyManagedNativeBoundaries({
|
||||
...input,
|
||||
managed_boundaries: createEvidence(undefined, managed.provider, {
|
||||
operation: managed.operation,
|
||||
parameters: managed.parameters,
|
||||
result: {
|
||||
...normalized,
|
||||
pinvoke_imports: imports.map((item) => ({
|
||||
...item,
|
||||
import_name: "_open_native",
|
||||
no_mangle: true,
|
||||
})),
|
||||
},
|
||||
rawResult: null,
|
||||
}),
|
||||
native_observations: [nativeEvidenceWithExports(["_open_native"])],
|
||||
});
|
||||
expect(result.summary).toMatchObject({
|
||||
verified: 0,
|
||||
inferred: 0,
|
||||
unresolved: 1,
|
||||
});
|
||||
expect(result.pinvoke_imports[0]?.candidates).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user