fix(github): bound guard response bodies

This commit is contained in:
Vincent Koc
2026-06-19 05:45:19 +02:00
parent def4c995ac
commit 36bfe77db1
4 changed files with 97 additions and 6 deletions
@@ -1,11 +1,13 @@
// Security Sensitive Guard Script tests cover sensitive file guard behavior.
import { describe, expect, it } from "vitest";
import {
GITHUB_RESPONSE_BODY_MAX_BYTES,
allowSecuritySensitiveCommand,
collectSecuritySensitiveChanges,
findSecuritySensitiveOverrideCommand,
findSecuritySensitiveOverrideCommandAsync,
findTrustedSecuritySensitiveGuardActor,
githubApi,
isSecuritySensitiveFile,
isSecuritySensitiveGuardAuthorizedForHead,
isSecuritySensitiveGuardMarkerComment,
@@ -245,4 +247,19 @@ describe("security-sensitive guard script", () => {
new Set(["vincentkoc", "steipete", "joshavant"]),
);
});
it("bounds successful GitHub API response bodies", async () => {
const request = githubApi("token", {
responseMaxBodyBytes: 64,
fetchImpl: (() =>
Promise.resolve(
new Response("x".repeat(65), {
headers: { "content-length": "65" },
}),
)) as typeof fetch,
}).request("/repos/openclaw/openclaw");
await expect(request).rejects.toThrow("GitHub response body exceeded 64 bytes");
expect(GITHUB_RESPONSE_BODY_MAX_BYTES).toBeGreaterThan(64);
});
});