fix(gateway): enforce request body size limits

This commit is contained in:
William Valentin
2026-02-15 21:44:36 -08:00
parent 22959ea3aa
commit d93c1c9f8d
13 changed files with 270 additions and 22 deletions
+20
View File
@@ -28,6 +28,26 @@ describe('configSchema — sandbox', () => {
});
});
describe('configSchema — server', () => {
const minimalConfig = {
telegram: { bot_token: 'test', allowed_chat_ids: [1] },
models: { default: { provider: 'anthropic', model: 'claude-3' } },
};
it('defaults max_request_body_bytes', () => {
const result = configSchema.parse(minimalConfig);
expect(result.server.max_request_body_bytes).toBe(1_048_576);
});
it('accepts custom max_request_body_bytes', () => {
const result = configSchema.parse({
...minimalConfig,
server: { max_request_body_bytes: 2048 },
});
expect(result.server.max_request_body_bytes).toBe(2048);
});
});
describe('configSchema — agent_configs', () => {
const minimalConfig = {
telegram: { bot_token: 'test', allowed_chat_ids: [1] },
+2
View File
@@ -36,6 +36,8 @@ const serverSchema = z.object({
auth_http: z.boolean().default(true),
/** Single-client gateway lock. When true, only one WebSocket client can be connected at a time. */
lock: z.boolean().default(false),
/** Maximum size (bytes) for inbound HTTP request bodies (webhooks/Gmail push). */
max_request_body_bytes: z.number().min(1024).max(10 * 1024 * 1024).default(1_048_576),
});
/** All supported model provider identifiers. Used by the config schema and TUI autocompletion. */