Skip to content

Commit

Permalink
Fix code scanning alert no. 9: Arbitrary file access during archive e…
Browse files Browse the repository at this point in the history
…xtraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
tomhub and github-advanced-security[bot] authored Nov 3, 2024
1 parent e215f49 commit 43b93de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/main/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ export const loadBackup = async (mainWindow, backupOptions) => {
// Write CT
await Promise.all(files.map(async (file) => {
if (/controlledTerminology\/.+/.test(file)) {
let contents = await zip.file(file).async('nodebuffer');
await writeFile(path.join(pathToCT, file.replace('controlledTerminology/', '')), contents);
if (file.indexOf('..') === -1) {
let contents = await zip.file(file).async('nodebuffer');
await writeFile(path.join(pathToCT, file.replace('controlledTerminology/', '')), contents);
} else {
console.log('skipping bad path', file);
}
}
}));
}
Expand Down

0 comments on commit 43b93de

Please sign in to comment.