Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

chore: reconcile current main fixes and client support

morluto3ea5fdd7cf76
diff --cc src/domain/referenceSourceGraph.test.ts
index 272c2f62c,8fe868832..5458b984a
--- a/src/domain/referenceSourceGraph.test.ts
+++ b/src/domain/referenceSourceGraph.test.ts
@@@ -434,56 -458,6 +458,66 @@@ describe("historical source graph valid
});
});
+describe("historical source graph excluded symlink targets", () => {
+ it("retains internal symlinks into excluded trees without accepting sibling prefixes", () => {
+ const input = { ...graphInput(), inventory_state: "partial" as const };
+ input.exclusions = [
+ {
+ path: "dist",
+ entry_kind: "directory",
+ reason: "caller-excluded",
+ pattern: "dist/",
+ },
+ ];
+ input.entries[2] = symlinkEntry({ target: "../dist/generated.js" });
+ const graph = createHistoricalSourceGraph(input);
+ expect(graph.entries[2]).toMatchObject({
+ target: "../dist/generated.js",
+ target_state: "internal",
+ });
+
+ input.entries[2] = symlinkEntry({ target: "../dist-old/generated.js" });
+ expect(() => createHistoricalSourceGraph(input)).toThrow(
+ /recorded exclusion/u,
+ );
+ });
+
+ it("does not treat an excluded file or unknown-kind ancestor as a directory", () => {
+ const input = { ...graphInput(), inventory_state: "partial" as const };
+ input.exclusions = [
+ {
+ path: "secret.txt",
+ entry_kind: "file",
+ reason: "configured-secret",
+ pattern: "secret.txt",
+ },
+ ];
+ input.entries[2] = symlinkEntry({ target: "../secret.txt/child" });
+ expect(() => createHistoricalSourceGraph(input)).toThrow(
+ /recorded exclusion/u,
+ );
+
++ input.exclusions[0] = {
++ path: "secret.txt",
++ entry_kind: "unknown",
++ reason: "configured-secret",
++ pattern: "secret.txt",
++ };
++ expect(() => createHistoricalSourceGraph(input)).toThrow(
++ /recorded exclusion/u,
++ );
++
+ input.exclusions[0] = {
+ path: "secret.txt",
+ reason: "configured-secret",
+ pattern: "secret.txt",
+ };
+ expect(() => createHistoricalSourceGraph(input)).toThrow(
+ /recorded exclusion/u,
+ );
+ });
+});
+
describe("historical source graph symlink path identity", () => {
it("joins internal symlink targets with the inventory NFC normalizer", () => {
// "café" spelled NFC, as the inventory produces it, and the same
diff --cc src/domain/referenceSourceGraph.ts
index 0c1c7caaf,a830e0aa0..a10213e87
--- a/src/domain/referenceSourceGraph.ts
+++ b/src/domain/referenceSourceGraph.ts
@@@ -129,9 -134,6 +133,9 @@@ const parseFailureSchema = z.strictObje
const exclusionSchema = z.discriminatedUnion("reason", [
z.strictObject({
path: relativePathSchema,
+ entry_kind: z
- .enum(["file", "directory", "symlink", "other"])
++ .enum(["file", "directory", "symlink", "other", "unknown"])
+ .exactOptional(),
reason: z.enum([
"configured-secret",
"project-ignored",
@@@ -142,9 -144,6 +146,9 @@@
}),
z.strictObject({
path: relativePathSchema,
+ entry_kind: z
- .enum(["file", "directory", "symlink", "other"])
++ .enum(["file", "directory", "symlink", "other", "unknown"])
+ .exactOptional(),
reason: z.enum(["symlink-escape", "unreadable"]),
}),
]);
@@@ -325,18 -324,6 +329,18 @@@ const checkSymlinks =
context: z.RefinementCtx,
): void => {
const lookupPath = createReferenceSourcePathLookup(paths);
+ const excludedPaths = createReferenceSourcePathLookup(
+ graph.exclusions.map(({ path }) => path),
+ );
+ const excludedKinds = new Map<
+ string,
- Set<"file" | "directory" | "symlink" | "other" | undefined>
++ Set<"file" | "directory" | "symlink" | "other" | "unknown" | undefined>
+ >();
+ for (const { path, entry_kind } of graph.exclusions) {
+ const kinds = excludedKinds.get(path) ?? new Set();
+ kinds.add(entry_kind);
+ excludedKinds.set(path, kinds);
+ }
for (const [index, entry] of graph.entries.entries()) {
if (entry.kind !== "symlink") continue;
if (entry.target === null) continue;
diff --cc tests/boundary/filesystem/referenceSourceFailureDetails.test.ts
index d379f01c6,82476d6db..56b66f16a
--- a/tests/boundary/filesystem/referenceSourceFailureDetails.test.ts
+++ b/tests/boundary/filesystem/referenceSourceFailureDetails.test.ts
@@@ -187,6 -196,22 +197,23 @@@ describe("reference import paths beyon
expect(deep?.limitations.join(" ")).toContain(
failed?.status === "failed" ? failed.message : "missing failure",
);
+ // A directory-only secret rule still applies when the kind is unknown.
+ const secretPattern = `${failed?.path ?? "missing"}/`;
+ const secret = await importReferenceSource({
+ root,
+ caller: "native-entry-failure-detail-test",
+ policy: { secretPatterns: [secretPattern] },
+ });
+ if (!secret.ok) throw new Error(secret.error.message);
+ expect(
+ secret.value.entries.some(({ path }) => path === failed?.path),
+ ).toBe(false);
+ expect(secret.value.exclusions).toContainEqual({
+ path: failed?.path,
++ entry_kind: "unknown",
+ reason: "configured-secret",
+ pattern: secretPattern,
+ });
} finally {
await deepTree("remove");
}