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,115 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { inspectWebPageInputSchema } from "../domain/browserObservation.js";
|
||||
import { captureDom } from "./CdpCaptureDocuments.js";
|
||||
|
||||
const origin = "https://app.example.test";
|
||||
const documentUrl = `${origin}/screens/app`;
|
||||
const input = inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: [origin],
|
||||
target_id: "page-1",
|
||||
});
|
||||
|
||||
const snapshot = (
|
||||
baseUrl?: string,
|
||||
baseHref = "assets/",
|
||||
pageUrl = documentUrl,
|
||||
linkHref = "guide",
|
||||
) => ({
|
||||
strings: [
|
||||
pageUrl,
|
||||
baseUrl ?? "",
|
||||
"#document",
|
||||
"BASE",
|
||||
"A",
|
||||
"LINK",
|
||||
"FORM",
|
||||
"",
|
||||
"href",
|
||||
baseHref,
|
||||
linkHref,
|
||||
"rel",
|
||||
"mcp",
|
||||
"agent",
|
||||
"action",
|
||||
"submit",
|
||||
],
|
||||
documents: [
|
||||
{
|
||||
documentURL: 0,
|
||||
...(baseUrl === undefined ? {} : { baseURL: 1 }),
|
||||
nodes: {
|
||||
nodeType: [9, 1, 1, 1, 1],
|
||||
nodeName: [2, 3, 4, 5, 6],
|
||||
nodeValue: [7, 7, 7, 7, 7],
|
||||
parentIndex: [-1, 0, 0, 0, 0],
|
||||
attributes: [[], [8, 9], [8, 10], [8, 13, 11, 12], [14, 15]],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const capture = (value: ReturnType<typeof snapshot>) =>
|
||||
captureDom(value, new Set([origin]), input);
|
||||
|
||||
describe("DOM metadata document base URLs", () => {
|
||||
it("resolves links, actions and agent hints against the captured document base", () => {
|
||||
const result = capture(snapshot(`${origin}/screens/assets/`));
|
||||
expect(result.urls.map(({ url }) => url)).toEqual([
|
||||
`${origin}/screens/assets/`,
|
||||
`${origin}/screens/assets/guide`,
|
||||
`${origin}/screens/assets/agent`,
|
||||
`${origin}/screens/assets/submit`,
|
||||
]);
|
||||
expect(result.agentHints[0]?.url).toBe(`${origin}/screens/assets/agent`);
|
||||
});
|
||||
|
||||
it("uses the document URL as fallback when no baseURL was supplied", () => {
|
||||
const result = capture(snapshot());
|
||||
expect(result.urls.map(({ url }) => url)).toEqual([
|
||||
`${origin}/screens/assets/`,
|
||||
`${origin}/screens/guide`,
|
||||
`${origin}/screens/agent`,
|
||||
`${origin}/screens/submit`,
|
||||
]);
|
||||
});
|
||||
|
||||
it("applies destination policy after resolving an ordinary foreign base", () => {
|
||||
const foreign = "https://cdn.example.test/assets/";
|
||||
const result = capture(snapshot(foreign, foreign));
|
||||
expect(result.nodes).toHaveLength(5);
|
||||
expect(result.urls).toHaveLength(4);
|
||||
expect(
|
||||
result.urls.every(
|
||||
({ url, destination_scope }) =>
|
||||
url === null && destination_scope === "outside_policy",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(result.agentHints[0]?.url).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps an absolute approved link independent of a foreign base", () => {
|
||||
const foreign = "https://cdn.example.test/assets/";
|
||||
const result = capture(
|
||||
snapshot(foreign, foreign, documentUrl, `${origin}/guide`),
|
||||
);
|
||||
expect(result.urls[1]).toMatchObject({
|
||||
url: `${origin}/guide`,
|
||||
destination_scope: "approved",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not authorize a foreign document using its approved base URL", () => {
|
||||
const result = capture(
|
||||
snapshot(
|
||||
`${origin}/assets/`,
|
||||
"assets/",
|
||||
"https://outside.example.test/app",
|
||||
),
|
||||
);
|
||||
expect(result.nodes).toEqual([]);
|
||||
expect(result.urls).toEqual([]);
|
||||
expect(result.agentHints).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user