fix: accept runtime archive root entry
This commit is contained in:
@@ -29,7 +29,7 @@ describe('Aurora Native runtime manifest', () => {
|
|||||||
})
|
})
|
||||||
).toThrow(/checksum/))
|
).toThrow(/checksum/))
|
||||||
it('rejects archive entries that escape the installation directory', () => {
|
it('rejects archive entries that escape the installation directory', () => {
|
||||||
expect(() => validateArchiveEntries('./runtime.json\n./bin/php\n')).not.toThrow()
|
expect(() => validateArchiveEntries('./\n./runtime.json\n./bin/php\n')).not.toThrow()
|
||||||
expect(() => validateArchiveEntries('./runtime.json\n../outside\n')).toThrow(
|
expect(() => validateArchiveEntries('./runtime.json\n../outside\n')).toThrow(
|
||||||
/Unsafe runtime archive entry/
|
/Unsafe runtime archive entry/
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -117,8 +117,9 @@ export function validateArchiveEntries(output: string): void {
|
|||||||
if (!entries.length || entries.length > 50000)
|
if (!entries.length || entries.length > 50000)
|
||||||
throw new Error('Runtime archive has an invalid file count.')
|
throw new Error('Runtime archive has an invalid file count.')
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
if (entry === '.' || entry === './') continue
|
||||||
const normalized = entry.replace(/^\.\//, '')
|
const normalized = entry.replace(/^\.\//, '')
|
||||||
if (!normalized || isAbsolute(normalized) || normalized.split('/').includes('..'))
|
if (!normalized || isAbsolute(normalized) || normalized.split(/[\\/]/).includes('..'))
|
||||||
throw new Error(`Unsafe runtime archive entry: ${entry}`)
|
throw new Error(`Unsafe runtime archive entry: ${entry}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user