Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion lib/read-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const resolveBaseDir = async (zipPath) => {
const readZip = (zip, options = {}) => {
const tempUuid = randomUUID();
const tempPath = os.tmpdir() + '/' + tempUuid;
const extractOptions = {};
const extractOptions = {
ensureOwnerPermissions: true
};

if (options.limits) {
extractOptions.limits = options.limits;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@tryghost/nql": "0.13.1",
"@tryghost/pretty-cli": "3.3.1",
"@tryghost/server": "3.1.1",
"@tryghost/zip": "3.4.1",
"@tryghost/zip": "3.5.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align zip and app error dependencies

With this bump the lockfile now installs @tryghost/zip with its own @tryghost/errors@3.3.1, while GScan itself still imports @tryghost/errors@3.3.0. In a normal install, zip extraction failures such as symlink or size-limit UnsupportedMediaTypeErrors are created by the nested 3.3.1 copy, so the errors.utils.isGhostError checks in lib/read-zip.js/lib/checker.js no longer recognize them as Ghost errors and wrap them as generic ValidationErrors, dropping the code/errorDetails callers rely on. Please bump the direct @tryghost/errors dependency to the same version as the zip package, or otherwise ensure both modules share the same error classes.

Useful? React with 👍 / 👎.

"chalk": "5.6.2",
"express": "5.2.1",
"express-handlebars": "8.0.1",
Expand Down
9 changes: 7 additions & 2 deletions test/read-zip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ describe('Zip file handler can read zip files', function () {
const zip = await mocked.readZip({path: '/tmp/theme.zip', name: 'theme.zip'}, {limits});
tempDirs.push(zip.origPath);

expect(extract).toHaveBeenCalledWith('/tmp/theme.zip', expect.any(String), {limits});
expect(extract).toHaveBeenCalledWith('/tmp/theme.zip', expect.any(String), {
ensureOwnerPermissions: true,
limits
});
} finally {
mocked.restore();
}
Expand All @@ -162,7 +165,9 @@ describe('Zip file handler can read zip files', function () {
errorDetails: extractError.message
});

expect(extract).toHaveBeenCalledWith('/tmp/theme.zip', expect.any(String), {});
expect(extract).toHaveBeenCalledWith('/tmp/theme.zip', expect.any(String), {
ensureOwnerPermissions: true
});
} finally {
mocked.restore();
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,10 @@
"@tryghost/root-utils" "2.3.1"
semver "7.8.5"

"@tryghost/zip@3.4.1":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@tryghost/zip/-/zip-3.4.1.tgz#34dd0fb14c6af56396bf7d42dbaaf0d316b9edfc"
integrity sha512-z45W9JNJSjo8t6JOaf0NUeePOo20yZqALajp9T+xV0gik4V9xLy0r9lR4qDnEMFIgNCy67okh+vDzOsp7MCayw==
"@tryghost/zip@3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@tryghost/zip/-/zip-3.5.0.tgz#e65c35b4fe6ec4b326ede5267cab6bc18e39990a"
integrity sha512-igHHPyBasmo+MWM+l8qtWWX/cdHlAQps5HbCfESi4zGPlkTzuScHfmFAnuXsCx+MZKP5LozgnQHOVIf6jkaU8A==
dependencies:
"@tryghost/errors" "3.3.1"
archiver "8.0.0"
Expand Down