fix: reject unsafe AgentRun input disclosure combinations

This commit is contained in:
Codex
2026-07-12 06:23:08 +02:00
parent 2680ef6462
commit 26597700df
5 changed files with 63 additions and 11 deletions
+24 -1
View File
@@ -301,6 +301,25 @@ describe("AgentRun default transport contract", () => {
process.env.AGENTRUN_CLIENT_CONFIG = tempConfigPath;
await Bun.write(tempConfigPath, agentRunMinimalClientYaml.replace("http://agentrun.example.local:8080", server.url.href.replace(/\/$/u, "")));
const invalidCombinations = [
{ args: ["--input", "--full"], contentType: "text/plain" },
{ args: ["--full", "--input", "-o", "json"], contentType: "application/json" },
{ args: ["--input", "--full", "-o", "yaml"], contentType: "application/yaml" },
{ args: ["--input", "--raw"], contentType: "application/json" },
];
for (const invalid of invalidCombinations) {
const rejected = await runAgentRunCommand(null, ["describe", `task/${taskId}`, ...invalid.args]);
const rejectedText = renderedTextOf(rejected);
expect(rejected.ok).toBe(false);
expect(renderedContentTypeOf(rejected)).toBe(invalid.contentType);
expect(rejectedText).toContain("validation-failed");
expect(rejectedText).toContain("Use --input without --full or --raw");
expect(rejectedText).not.toContain(hiddenCredential);
expect(rejectedText).not.toContain("supervisor");
expect(Buffer.byteLength(rejectedText, "utf8")).toBeLessThan(2400);
}
expect(requests).toBe(0);
const summaryText = renderedTextOf(await runAgentRunCommand(null, ["describe", `task/${taskId}`]));
expect(summaryText).toContain(`agentrun describe task/${taskId} --input -o json`);
expect(summaryText).not.toContain(hiddenCredential);
@@ -485,7 +504,7 @@ describe("AgentRun default transport contract", () => {
expect(rootHelpText.split("\n").length).toBeLessThan(40);
});
test("local retry and attempt validation preserves bounded human and machine errors", async () => {
test("local resource validation preserves bounded human and machine errors", async () => {
const cases = [
{
args: ["retry", "task/qt_failed_1", "--reason", "dependency repaired"],
@@ -532,6 +551,8 @@ describe("AgentRun default transport contract", () => {
for (const cliArgs of [
["retry", "run/run_invalid", "--idempotency-key", "retry-key-1", "--reason", "dependency repaired", "-o", "json"],
["get", "attempts", "--raw"],
["describe", "task/qt_sensitive", "--input", "--full", "-o", "json"],
["describe", "task/qt_sensitive", "--input", "--raw"],
]) {
const cli = Bun.spawnSync(["bun", "scripts/cli.ts", "agentrun", ...cliArgs], {
cwd: new URL("../..", import.meta.url).pathname,
@@ -543,6 +564,8 @@ describe("AgentRun default transport contract", () => {
expect(payload.ok).toBe(false);
expect(payload.failureKind).toBe("validation-failed");
expect(cli.stdout.toString().length).toBeLessThan(2400);
expect(cli.stdout.toString()).not.toContain('"resource":');
expect(cli.stdout.toString()).not.toContain('"data":');
}
});