From d43f6f110aa89351bf1a1670057c4da8da8fb4de Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Sat, 30 May 2026 07:02:20 -0700 Subject: [PATCH] test: cover sftp upload root sibling rejection Co-authored-by: Orca --- src/main/ssh/sftp-upload.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/ssh/sftp-upload.test.ts b/src/main/ssh/sftp-upload.test.ts index 77d7136aac5..a0572caa361 100644 --- a/src/main/ssh/sftp-upload.test.ts +++ b/src/main/ssh/sftp-upload.test.ts @@ -66,6 +66,23 @@ describe('sftp-upload', () => { }) }) + it('rejects sibling directories outside the upload root', async () => { + const localDir = await mkdtemp(join(tmpdir(), 'orca-sftp-upload-')) + const escapedDir = `${localDir}-sibling` + await mkdir(escapedDir) + await writeFile(join(escapedDir, 'asset.txt'), 'asset') + const sftp = createSftpMock() + + await expect( + uploadDirectory(sftp, escapedDir, '/remote/assets', await realpath(localDir), { + exclusive: true + }) + ).rejects.toThrow('Path escaped upload root') + + expect(sftp.mkdir).not.toHaveBeenCalled() + expect(sftp.createWriteStream).not.toHaveBeenCalled() + }) + it('does not create the remote file when the local source is a symlink', async () => { const localDir = await mkdtemp(join(tmpdir(), 'orca-sftp-upload-')) await writeFile(join(localDir, 'target.txt'), 'secret')