Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cli/command/cleanup-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export class CleanupPathCommand extends Command {
const start = Date.now();
let error = false;
const paths = this.cleanupPaths.flatMap((p) => p.split(':'));

// reject path traversal sequences to avoid deleting files outside of the requested paths
const invalid = paths.filter((p) => /(^|[/\\])\.\.([/\\]|$)/.test(p));
if (invalid.length) {
logger.error({ paths: invalid }, 'Invalid cleanup path(s) detected');
return 1;
}

logger.info({ paths }, `Cleanup paths ...`);
try {
const deleted = await deleteAsync(paths, { dot: true });
Expand Down
Loading