refactor(tools): return complete analysis results inline

This commit is contained in:
morluto
2026-09-29 14:53:50 +08:00
parent c34efca4cd
commit 2a6eb41147
156 changed files with 2529 additions and 1891 deletions
@@ -27,7 +27,7 @@ it("reads local source maps as part of static artifact analysis", async () => {
);
});
it("does not follow symlinks or exceed the internal text-file safety boundary", async () => {
it("does not follow symlinks and analyzes text beyond the former file-size cap", async () => {
const root = await fixtureDirectory();
const outside = await createTestTempDirectory("rea-javascript-outside-");
const outsideFile = join(outside, "secret.js");
@@ -36,22 +36,23 @@ it("does not follow symlinks or exceed the internal text-file safety boundary",
'fetch("https://outside-secret.invalid/credential");',
);
await symlink(outsideFile, join(root, "escape.js"));
await writeFile(
join(root, "oversized.js"),
`const oversizedSecret = "${"private-marker-".repeat(600_000)}";`,
);
const baseline = await reconstructJavaScriptArtifact({ input_path: root });
const oversizedSource = `// ${"private-marker-".repeat(600_000)}\nfetch("https://inside.invalid");\n`;
await writeFile(join(root, "oversized.js"), oversizedSource);
const result = await reconstructJavaScriptArtifact({ input_path: root });
const encoded = JSON.stringify(result);
expect(result.statistics.limit_omitted_text_files).toBeGreaterThan(0);
expect(result.statistics.text_bytes_read).toBeGreaterThan(8 * 1024 * 1024);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
status: "complete",
truncated: false,
});
expect(encoded).not.toContain(outsideFile);
expect(encoded).not.toContain("outside-secret.invalid");
expect(encoded).not.toContain("private-marker-private-marker");
expect(result.statistics.visited_ast_nodes).toBeGreaterThan(
baseline.statistics.visited_ast_nodes,
);
});
it("keeps malformed JavaScript, package metadata, and source maps as explicit unknowns", async () => {