mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-10 01:29:17 +00:00
fix(desktop): allow double dots in bundle filenames (#5515)
This commit is contained in:
parent
8b6ac721fa
commit
ca7638e85c
2 changed files with 24 additions and 1 deletions
|
|
@ -72,6 +72,25 @@ describe('bundle-files', () => {
|
|||
expect(validateBundleFile(file)).toContain('Path traversal')
|
||||
})
|
||||
|
||||
it('rejects parent traversal segments below the bundle root', () => {
|
||||
const file: BundleFile = {
|
||||
relativePath: 'docs/../escape.txt',
|
||||
contentBase64: Buffer.from('x').toString('base64'),
|
||||
size: 1,
|
||||
}
|
||||
expect(validateBundleFile(file)).toContain('Path traversal')
|
||||
})
|
||||
|
||||
it('accepts double dots inside a path segment', () => {
|
||||
const content = Buffer.from('hello')
|
||||
const file: BundleFile = {
|
||||
relativePath: 'docs/release..notes.md',
|
||||
contentBase64: content.toString('base64'),
|
||||
size: content.length,
|
||||
}
|
||||
expect(validateBundleFile(file)).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects absolute paths', () => {
|
||||
const file: BundleFile = {
|
||||
relativePath: '/etc/passwd',
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ export function fromPortableRelPath(portablePath: string): string {
|
|||
return portablePath.split('/').join(sep)
|
||||
}
|
||||
|
||||
function hasParentTraversalSegment(portablePath: string): boolean {
|
||||
return portablePath.split('/').includes('..')
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Validation
|
||||
// ============================================================
|
||||
|
|
@ -61,7 +65,7 @@ export function validateBundleFile(file: BundleFile): string | null {
|
|||
}
|
||||
|
||||
// Path traversal checks
|
||||
if (file.relativePath.includes('..')) {
|
||||
if (hasParentTraversalSegment(file.relativePath)) {
|
||||
return `Path traversal detected: ${file.relativePath}`
|
||||
}
|
||||
if (file.relativePath.startsWith('/') || file.relativePath.startsWith('\\')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue