gscan 6.0.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checker.js +2 -1
- package/lib/read-theme.js +3 -0
- package/lib/read-zip.js +15 -2
- package/package.json +6 -6
package/lib/checker.js
CHANGED
|
@@ -32,6 +32,7 @@ function loadChecks() {
|
|
|
32
32
|
* @param {string} [options.themeName] name of the checked theme
|
|
33
33
|
* @param {Object=} [options.labs] object containing boolean flags for enabled labs features
|
|
34
34
|
* @param {boolean} [options.skipChecks] flag to allow reading theme without incurring check costs
|
|
35
|
+
* @param {Object=} [options.limits] zip extraction size limits
|
|
35
36
|
* @returns {Promise<Object>}
|
|
36
37
|
*/
|
|
37
38
|
const check = async function checkAll(themePath, options = {}) {
|
|
@@ -105,7 +106,7 @@ const checkZip = async function checkZip(path, options) {
|
|
|
105
106
|
|
|
106
107
|
try {
|
|
107
108
|
const readZip = require('./read-zip');
|
|
108
|
-
({path: extractedZipPath} = await readZip(zip));
|
|
109
|
+
({path: extractedZipPath} = await readZip(zip, {limits: options.limits}));
|
|
109
110
|
return await check(extractedZipPath, Object.assign({themeName: zip.name}, options));
|
|
110
111
|
} catch (error) {
|
|
111
112
|
if (!errors.utils.isGhostError(error)) {
|
package/lib/read-theme.js
CHANGED
package/lib/read-zip.js
CHANGED
|
@@ -7,6 +7,10 @@ const {extract} = require('@tryghost/zip');
|
|
|
7
7
|
const errors = require('@tryghost/errors');
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
|
|
10
|
+
const isKnownZipError = (err) => {
|
|
11
|
+
return errors.utils.isGhostError(err);
|
|
12
|
+
};
|
|
13
|
+
|
|
10
14
|
const resolveBaseDir = async (zipPath) => {
|
|
11
15
|
let matches = [];
|
|
12
16
|
|
|
@@ -25,12 +29,17 @@ const resolveBaseDir = async (zipPath) => {
|
|
|
25
29
|
return zipPath;
|
|
26
30
|
};
|
|
27
31
|
|
|
28
|
-
const readZip = (zip) => {
|
|
32
|
+
const readZip = (zip, options = {}) => {
|
|
29
33
|
const tempUuid = randomUUID();
|
|
30
34
|
const tempPath = os.tmpdir() + '/' + tempUuid;
|
|
35
|
+
const extractOptions = {};
|
|
36
|
+
|
|
37
|
+
if (options.limits) {
|
|
38
|
+
extractOptions.limits = options.limits;
|
|
39
|
+
}
|
|
31
40
|
|
|
32
41
|
debug('Reading Zip', zip.path, 'into', tempPath);
|
|
33
|
-
return extract(zip.path, tempPath)
|
|
42
|
+
return extract(zip.path, tempPath, extractOptions)
|
|
34
43
|
.then(async () => {
|
|
35
44
|
let resolvedPath = await resolveBaseDir(tempPath);
|
|
36
45
|
zip.origPath = tempPath;
|
|
@@ -41,6 +50,10 @@ const readZip = (zip) => {
|
|
|
41
50
|
}).catch((err) => {
|
|
42
51
|
debug('Zip extraction error', err);
|
|
43
52
|
|
|
53
|
+
if (isKnownZipError(err)) {
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
throw new errors.ValidationError({
|
|
45
58
|
message: 'Failed to read zip file',
|
|
46
59
|
help: 'Your zip file might be corrupted, try unzipping and zipping again.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@sentry/node": "10.52.0",
|
|
47
47
|
"@tryghost/config": "2.2.0",
|
|
48
48
|
"@tryghost/debug": "2.2.0",
|
|
49
|
-
"@tryghost/errors": "3.2.
|
|
50
|
-
"@tryghost/logging": "4.2.
|
|
49
|
+
"@tryghost/errors": "3.2.1",
|
|
50
|
+
"@tryghost/logging": "4.2.1",
|
|
51
51
|
"@tryghost/nql": "0.12.10",
|
|
52
52
|
"@tryghost/pretty-cli": "3.2.0",
|
|
53
|
-
"@tryghost/server": "2.2.
|
|
54
|
-
"@tryghost/zip": "3.
|
|
53
|
+
"@tryghost/server": "2.2.1",
|
|
54
|
+
"@tryghost/zip": "3.3.1",
|
|
55
55
|
"chalk": "5.6.2",
|
|
56
56
|
"express": "5.2.1",
|
|
57
57
|
"express-handlebars": "8.0.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"resolutions": {
|
|
77
77
|
"node-loggly-bulk": "4.0.2",
|
|
78
|
-
"node-loggly-bulk/axios": "1.
|
|
78
|
+
"node-loggly-bulk/axios": "1.16.0",
|
|
79
79
|
"**/handlebars": "4.7.9"
|
|
80
80
|
},
|
|
81
81
|
"files": [
|