Skip to content
Open
Changes from 1 commit
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
16 changes: 15 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7486,7 +7486,21 @@ async function downloadJobArtifacts(
await handleGitLabError(response);

const filename = `artifacts_job_${encodeGitLabPathSegment(jobId)}.zip`;
const savePath = localPath ? path.join(localPath, filename) : filename;
let savePath: string;
if (localPath) {
const normalizedLocalPath = path.normalize(localPath);
if (
path.isAbsolute(normalizedLocalPath) ||
normalizedLocalPath === ".." ||
normalizedLocalPath.startsWith(".." + path.sep) ||
normalizedLocalPath.includes(path.sep + ".." + path.sep)
) {
throw new Error("Invalid local_path: directory traversal is not allowed.");
Comment thread
brennanneoh marked this conversation as resolved.
Outdated
}
savePath = path.join(normalizedLocalPath, filename);
Comment thread
brennanneoh marked this conversation as resolved.
Outdated
Comment thread
brennanneoh marked this conversation as resolved.
Outdated
} else {
savePath = filename;
}
fs.mkdirSync(path.dirname(savePath), { recursive: true });

if (!response.body) {
Expand Down