fix(ssh): reject timeouts above the native timer range

This commit is contained in:
Tianyi Cui committed 2026-09-12 15:03:03 +08:00
1 parent 7673f90d18
commit 1c5a201af8
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -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),
@@ -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()