diff --git a/scripts/utils.ts b/scripts/utils.ts index d94a8cb89a..db9055e1d8 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -51,6 +51,10 @@ export function getStoragePath(filepath: string, rootDir: string): string { return relative } + if (path.isAbsolute(filepath) || filepath === '..' || filepath.startsWith(`..${path.sep}`)) { + throw new Error(`Filepath "${filepath}" is outside the storage directory`) + } + return filepath }