mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
Validate analyze-javascript-application paths with the shared localPathStringSchema before anchoring or provider execution. Empty paths now return CLI field errors; NUL bytes are rejected at the same boundary. Preserve selected-path Evidence for valid inputs and update the CLI regressions. Closes #9747.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Cli } from "incur";
|
|
import { expect, it } from "vitest";
|
|
import { registerElectronCommands } from "../../../src/cli/electronCommands.js";
|
|
import { silentLogger } from "../../../src/logger.js";
|
|
|
|
const serve = async (argv: readonly string[]): Promise<unknown> => {
|
|
const cli = Cli.create("javascript-application-path-admission", {
|
|
sync: false,
|
|
});
|
|
registerElectronCommands(cli, silentLogger, {});
|
|
let stdout = "";
|
|
await cli.serve([...argv, "--json"], {
|
|
env: {},
|
|
stdout: (text) => {
|
|
stdout += text;
|
|
},
|
|
exit: () => undefined,
|
|
});
|
|
return JSON.parse(stdout);
|
|
};
|
|
|
|
it("rejects an empty or NUL analyze-javascript-application path before analysis", async () => {
|
|
expect(await serve(["analyze-javascript-application", ""])).toMatchObject({
|
|
code: "VALIDATION_ERROR",
|
|
fieldErrors: [expect.objectContaining({ path: "path", code: "too_small" })],
|
|
});
|
|
expect(
|
|
await serve(["analyze-javascript-application", "target\x00name"]),
|
|
).toMatchObject({
|
|
code: "VALIDATION_ERROR",
|
|
fieldErrors: [
|
|
expect.objectContaining({ path: "path", code: "invalid_format" }),
|
|
],
|
|
});
|
|
});
|