fix: reject formatter paths outside storage

This commit is contained in:
chen zhihao
2026-08-31 20:52:37 +08:00
parent 1b6b7db25a
commit e7e21e166c
+4
View File
@@ -51,6 +51,10 @@ export function getStoragePath(filepath: string, rootDir: string): string {
return relative return relative
} }
if (path.isAbsolute(filepath) || filepath === '..' || filepath.startsWith(`..${path.sep}`)) {
throw new Error(`Filepath "${filepath}" is outside the storage directory`)
}
return filepath return filepath
} }