From 1c5a201af8288cc8a25139da13ee947e2eecfec9 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sat, 12 Sep 2026 04:53:05 +0800 Subject: [PATCH] fix(ssh): reject timeouts above the native timer range --- packages/ssh/ssh/src/index.ts | 2 +- packages/ssh/ssh/tests/startup-behavior.spec.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/ssh/ssh/src/index.ts b/packages/ssh/ssh/src/index.ts index 1bba77c079..2736a052ba 100644 --- a/packages/ssh/ssh/src/index.ts +++ b/packages/ssh/ssh/src/index.ts @@ -76,7 +76,7 @@ export class SshConnection extends Service { this.config = z.object({ host: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.@-]*$/), node: z.string().startsWith('/'), helper: z.string().startsWith('/'), helperHash: z.string().regex(/^[0-9a-f]{64}$/), - workspace: z.string().startsWith('/'), requestTimeoutMs: z.number().int().positive(), + workspace: z.string().startsWith('/'), requestTimeoutMs: z.number().int().positive().max(2_147_483_647), bootstrapPath: z.string().startsWith('/').optional(), bootstrapHash: z.string().regex(/^[0-9a-f]{64}$/).optional(), maxFrameBytes: z.number().int().positive().max(64 * 1024 * 1024), maxPending: z.number().int().positive().max(128), leaseMs: z.number().int().min(3000).max(600_000), diff --git a/packages/ssh/ssh/tests/startup-behavior.spec.ts b/packages/ssh/ssh/tests/startup-behavior.spec.ts index e0272535e9..1c69f39748 100644 --- a/packages/ssh/ssh/tests/startup-behavior.spec.ts +++ b/packages/ssh/ssh/tests/startup-behavior.spec.ts @@ -135,7 +135,8 @@ describe.skipIf(process.platform === 'win32')('SSH connection startup', () => { it.each([ { host: '-option' }, { host: 'alias; command' }, { node: 'relative' }, { helperHash: 'bad' }, { bootstrapPath: '/remote/bootstrap.js' }, { bootstrapHash: 'b'.repeat(64) }, - { requestTimeoutMs: 0 }, { maxFrameBytes: 64 * 1024 * 1024 + 1 }, { maxPending: 129 }, { leaseMs: 2999 }, + { requestTimeoutMs: 0 }, { requestTimeoutMs: 2_147_483_648 }, + { maxFrameBytes: 64 * 1024 * 1024 + 1 }, { maxPending: 129 }, { leaseMs: 2999 }, ])('rejects invalid deployment configuration before SSH starts: %j', (invalid) => { expect(() => setup({ config: invalid })).toThrow() expect(transport.spawn).not.toHaveBeenCalled()