Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lab/events/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FORBIDDEN_EXACT_KEYS = new Set([
]);

const RAW_POSIX_PATH_RE =
/(?:^|[^A-Za-z0-9._~/])\/(?:(?=$|[^A-Za-z0-9._~/])|(?!\/)(?![ \t\r\n])(?:\/|[^/\0\r\n]+)+\/?(?=$|[^A-Za-z0-9._~/]))/u;
/(?:^|[^A-Za-z0-9._~/])\/(?:(?=$|[^A-Za-z0-9._~/])|(?!\/)(?![ \t\r\n])[^/\0\r\n]+(?:\/+[^/\0\r\n]+)*\/*(?=$|[^A-Za-z0-9._~/]))/u;
const ASCII_URL_WHITESPACE_RE = /[\t\r\n]/g;
const FILE_URI_RE = /(?:^|[^A-Za-z0-9+.-])file:/i;

Expand Down
24 changes: 24 additions & 0 deletions tests/lab/lab-post-merge-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,30 @@ test("event privacy admission rejects raw filesystem path bypass forms", () => {
}
});

test("event privacy admission stays linear on pathological path strings", () => {
// RAW_POSIX_PATH_RE once alternated `\/` with `[^/]+` under a shared `+`; long segment runs
// were repartitioned combinatorially. Keep these just under the 4 KiB field cap so a
// backtracking regression surfaces as a timeout rather than a wrong verdict.
const deep = `cwd=/${"a/".repeat(2000)}`;
try {
enforceEventStructureLimits({ detail: deep });
throw new Error("expected raw_path rejection for a long segment chain");
} catch (err) {
expect((err as { code?: string }).code).toBe("raw_path");
}

const dense = `cwd=/${"a//".repeat(1300)}`;
try {
enforceEventStructureLimits({ detail: dense });
throw new Error("expected raw_path rejection for a slash-dense chain");
} catch (err) {
expect((err as { code?: string }).code).toBe("raw_path");
}
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

const notAPath = `https://example.com/${"a/".repeat(2000)}`;
expect(() => enforceEventStructureLimits({ detail: notAPath })).not.toThrow();
});

test("invalid JSON contract artifacts classify as artifact_mismatch", () => {
const home = tempHome();
const artifactsDir = join(home, "artifacts");
Expand Down
Loading