mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-22 20:08:46 +00:00
refactor(drop): replace symlink entry check with dangerous node entry validation
- Updated the unzipDrop function to remove the symlink entry check and replace it with a more general validation for dangerous node entries. - Adjusted the associated test to reflect the change in error messaging.
This commit is contained in:
@@ -250,7 +250,7 @@ describe("security: zip symlink entry blocked", () => {
|
|||||||
const file = new File([zipBuffer as any], "exploit.zip");
|
const file = new File([zipBuffer as any], "exploit.zip");
|
||||||
|
|
||||||
await expect(unzipDrop(file, { ...baseApp, appName })).rejects.toThrow(
|
await expect(unzipDrop(file, { ...baseApp, appName })).rejects.toThrow(
|
||||||
/Symlink entries are not allowed/,
|
/Dangerous node entries are not allowed/,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSymlinkEntry(entry)) {
|
|
||||||
throw new Error(`Symlink entries are not allowed: ${entry.entryName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDangerousNode(entry)) {
|
if (isDangerousNode(entry)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Dangerous node entries are not allowed: ${entry.entryName}`,
|
`Dangerous node entries are not allowed: ${entry.entryName}`,
|
||||||
@@ -149,12 +145,6 @@ const uploadFileToServer = (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function isSymlinkEntry(entry: AdmZip.IZipEntry) {
|
|
||||||
// upper 16 bits = unix permissions
|
|
||||||
const unix = (entry.header.attr >> 16) & 0o170000;
|
|
||||||
return unix === 0o120000;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isDangerousNode(entry: AdmZip.IZipEntry) {
|
function isDangerousNode(entry: AdmZip.IZipEntry) {
|
||||||
const type = (entry.header.attr >> 16) & 0o170000;
|
const type = (entry.header.attr >> 16) & 0o170000;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user