fix: integrate 24 reviewed browser/native/semantics corrections (#815)
* fix(reference): resolve emitted extensions to TypeScript source Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * test(reference): retain legitimate declaration import counterparts Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * fix(mcp): recognize implicit form elicitation capability Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(ghidra): reject contradictory NativeAOT reports * fix(native): preserve thin architectures across echoed filename lines Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): preserve app bundle executable filename whitespace Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(doctor): validate Node-wrapped client policy Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(reference): preserve observed entry failure reasons Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * fix(artifacts): verify opaque bytes before reusing inventory identities Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * fix(browser): resolve DOM destinations against document base URL Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * fix: recover serialized native NIB view hierarchy Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * ci: exercise native compiled NIB hierarchy regressions Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(deps): remediate reachable archive-parsing advisories Two high-severity advisories are reachable from untrusted target content: - @xmldom/xmldom 0.9.10 (via plist) parses XML plist bytes from analyzed app bundles in the keyed-archive reader. Refreshed to 0.9.12. - brace-expansion 5.0.7 (via @electron/asar -> minimatch) is reached while analyzing untrusted ASAR archives. Refreshed to 5.0.12. Both are in-range patch updates (plist declares ^0.9.10, minimatch declares ^5.0.5), so no source or API change is required and no direct dependency declaration moves. Lockfile-only change. The remaining smol-toml advisory is not included: it parses operator-owned client configuration rather than untrusted target content, and its fix moves outside the declared range and changes leading-BOM handling. * fix(semantics): link wrapped arrow Promise returns * fix(reconstruction): preserve unknown graph limitations * fix(native): preserve exact code signing identifiers Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): recognize only whole otool command headers Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): retain nm-proven literal export names Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): project decoded file URL paths Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix: preserve explicit source-relative URL observation spelling Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): project Mach-O evidence into container file offsets Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): normalize referrer policy fallback lists Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> --------- Signed-off-by: Rudy Celekli <rudy@gradiahq.com> Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> Co-authored-by: Rudy Celekli <rudy@gradiahq.com> Co-authored-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> Co-authored-by: Kaoru0822 <aisakamimaki@gmail.com> Co-authored-by: DeryFerd <deryferdikao125@gmail.com>
This commit is contained in:
co-authored by
Rudy Celekli
RudyCelekli
Kaoru0822
DeryFerd
parent
2572e1eb2f
commit
3af3811ab0
@@ -0,0 +1,189 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
mergeNibHierarchies,
|
||||
projectNibViewHierarchy,
|
||||
} from "./NibViewHierarchy.js";
|
||||
|
||||
const object = (id: number, parent?: number) => ({
|
||||
id,
|
||||
class_name: "NSView",
|
||||
values:
|
||||
parent === undefined ? {} : { NSSuperview: { $nib_object_ref: parent } },
|
||||
});
|
||||
|
||||
describe("serialized NIB view hierarchy bounds", () => {
|
||||
it("leaves archives without superview links to the legacy projection", () => {
|
||||
expect(projectNibViewHierarchy([object(0)], new Set([0]))).toEqual({
|
||||
hierarchy: null,
|
||||
omitted: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the serialized parent direction and retains all sibling links", () => {
|
||||
expect(
|
||||
projectNibViewHierarchy(
|
||||
[object(0), object(1, 0), object(2, 0)],
|
||||
new Set([0, 1, 2]),
|
||||
),
|
||||
).toEqual({
|
||||
hierarchy: [
|
||||
{
|
||||
objectID: "0",
|
||||
children: [
|
||||
{ objectID: "1", children: [] },
|
||||
{ objectID: "2", children: [] },
|
||||
],
|
||||
},
|
||||
],
|
||||
omitted: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("reports missing parents without inventing parentage", () => {
|
||||
expect(projectNibViewHierarchy([object(0, 99)], new Set([0]))).toEqual({
|
||||
hierarchy: [],
|
||||
omitted: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("reports a missing encoded window content view as incomplete", () => {
|
||||
expect(
|
||||
projectNibViewHierarchy(
|
||||
[
|
||||
{
|
||||
id: 0,
|
||||
class_name: "NSWindowTemplate",
|
||||
values: { NSWindowView: { $nib_object_ref: 99 } },
|
||||
},
|
||||
],
|
||||
new Set([0]),
|
||||
),
|
||||
).toEqual({ hierarchy: [{ objectID: "0", children: [] }], omitted: 1 });
|
||||
});
|
||||
|
||||
it("marks unsupported serialized parent values as incomplete", () => {
|
||||
expect(
|
||||
projectNibViewHierarchy(
|
||||
[{ id: 0, class_name: "NSView", values: { NSSuperview: "unknown" } }],
|
||||
new Set([0]),
|
||||
),
|
||||
).toEqual({ hierarchy: null, omitted: 1 });
|
||||
});
|
||||
|
||||
it("reports cyclic and self-referential parentage as incomplete", () => {
|
||||
expect(
|
||||
projectNibViewHierarchy(
|
||||
[object(0, 1), object(1, 0), object(2, 2)],
|
||||
new Set([0, 1, 2]),
|
||||
),
|
||||
).toEqual({
|
||||
hierarchy: [],
|
||||
omitted: 3,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not project children whose parent was not retained", () => {
|
||||
expect(
|
||||
projectNibViewHierarchy([object(0), object(1, 0)], new Set([1])),
|
||||
).toEqual({
|
||||
hierarchy: [],
|
||||
omitted: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("reports nodes beyond the depth bound instead of claiming complete coverage", () => {
|
||||
const objects = Array.from({ length: 132 }, (_, id) =>
|
||||
object(id, id === 0 ? undefined : id - 1),
|
||||
);
|
||||
expect(
|
||||
projectNibViewHierarchy(objects, new Set(objects.map(({ id }) => id)))
|
||||
.omitted,
|
||||
).toBe(3);
|
||||
});
|
||||
|
||||
it("reports nodes beyond the record bound", () => {
|
||||
const objects = Array.from({ length: 20_002 }, (_, id) =>
|
||||
object(id, id === 0 ? undefined : 0),
|
||||
);
|
||||
expect(
|
||||
projectNibViewHierarchy(objects, new Set(objects.map(({ id }) => id)))
|
||||
.omitted,
|
||||
).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy NIB hierarchy preservation", () => {
|
||||
it("keeps encoded window parents while merging shared views only once", () => {
|
||||
const legacy = [
|
||||
{
|
||||
objectID: "window",
|
||||
children: [
|
||||
{ objectID: "view", children: [{ objectID: "first", children: [] }] },
|
||||
],
|
||||
},
|
||||
];
|
||||
const recovered = [
|
||||
{
|
||||
objectID: "view",
|
||||
children: [
|
||||
{ objectID: "first", children: [] },
|
||||
{ objectID: "second", children: [] },
|
||||
],
|
||||
},
|
||||
];
|
||||
expect(mergeNibHierarchies(legacy, recovered).hierarchy).toEqual([
|
||||
{
|
||||
objectID: "window",
|
||||
children: [
|
||||
{
|
||||
objectID: "view",
|
||||
children: [
|
||||
{ objectID: "first", children: [] },
|
||||
{ objectID: "second", children: [] },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
it("moves an existing root under its encoded parent without duplicate visits", () => {
|
||||
expect(
|
||||
mergeNibHierarchies(
|
||||
[{ objectID: "child", children: [] }],
|
||||
[
|
||||
{
|
||||
objectID: "parent",
|
||||
children: [{ objectID: "child", children: [] }],
|
||||
},
|
||||
],
|
||||
),
|
||||
).toEqual({
|
||||
hierarchy: [
|
||||
{ objectID: "parent", children: [{ objectID: "child", children: [] }] },
|
||||
],
|
||||
omitted: 0,
|
||||
});
|
||||
});
|
||||
it("reports conflicting encoded parents rather than dropping a link silently", () => {
|
||||
const legacy = [
|
||||
{ objectID: "first", children: [{ objectID: "child", children: [] }] },
|
||||
];
|
||||
const recovered = [
|
||||
{ objectID: "second", children: [{ objectID: "child", children: [] }] },
|
||||
];
|
||||
expect(mergeNibHierarchies(legacy, recovered).omitted).toBe(1);
|
||||
});
|
||||
it("does not introduce a cycle when moving an existing root", () => {
|
||||
const legacy = [
|
||||
{ objectID: "child", children: [{ objectID: "parent", children: [] }] },
|
||||
];
|
||||
const recovered = [
|
||||
{ objectID: "parent", children: [{ objectID: "child", children: [] }] },
|
||||
];
|
||||
expect(mergeNibHierarchies(legacy, recovered)).toEqual({
|
||||
hierarchy: legacy,
|
||||
omitted: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user