@iobroker/repochecker 2.3.0 → 2.4.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/README.md +8 -3
- package/doc/issues.json +8 -2
- package/index.js +153 -58
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,10 +20,15 @@ Branch (`master/main/dev`) is optional.
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
## Changelog
|
|
23
|
+
### 2.4.0 (2024-05-30)
|
|
24
|
+
* (mcm1957) Add check to protect sensitive data. [#195]
|
|
25
|
+
* (mcm1957) Add check to verify that dependencies and globalDepencies are of type array. [#90]
|
|
26
|
+
|
|
27
|
+
### 2.3.1 (2024-05-07)
|
|
28
|
+
* (mcm1957) Reduce number of missing translation warnings.
|
|
29
|
+
* (mcm1957) Seperate between required and recommended translations.
|
|
30
|
+
* (mcm1957) Log missing translations in detail.
|
|
23
31
|
|
|
24
|
-
<!--
|
|
25
|
-
* (mcm1957) Added deprecate warnings for "main', 'materialize", "materializeTab" and "noConfig"
|
|
26
|
-
-->
|
|
27
32
|
### 2.3.0 (2024-05-07)
|
|
28
33
|
* (mcm1957) Elements marked as deprectaed added to blacklist.
|
|
29
34
|
* (mcm1957) Blacklist added to block elements at package.json and io-package.json.
|
package/doc/issues.json
CHANGED
|
@@ -335,6 +335,12 @@
|
|
|
335
335
|
"E184": {
|
|
336
336
|
"title": "${blacklistIOPackageJson[blacklist].msg}"
|
|
337
337
|
},
|
|
338
|
+
"E185": {
|
|
339
|
+
"title": "`common.dependencies` must be an array at io-package.json"
|
|
340
|
+
},
|
|
341
|
+
"E186": {
|
|
342
|
+
"title": "`common.globalDependencies` must be an array at io-package.json"
|
|
343
|
+
},
|
|
338
344
|
"E200": {
|
|
339
345
|
"title": "Not found on npm. Please publish"
|
|
340
346
|
},
|
|
@@ -531,10 +537,10 @@
|
|
|
531
537
|
"title": "`common.localLink` in io-package.json is deprecated. Please define object `common.localLinks`: { `_default`: `...` }"
|
|
532
538
|
},
|
|
533
539
|
"W173": {
|
|
534
|
-
"title": "
|
|
540
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `protectedNative` in io-package.json"
|
|
535
541
|
},
|
|
536
542
|
"W174": {
|
|
537
|
-
"title": "
|
|
543
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `encryptedNative` in io-package.json"
|
|
538
544
|
},
|
|
539
545
|
"W177": {
|
|
540
546
|
"title": "`common.main` is deprecated in io-package.json. For js-controller >= 3.3 please use package.json main and remove `common.main` from io-package.json."
|
package/index.js
CHANGED
|
@@ -19,10 +19,20 @@ const sizeOf = require('image-size');
|
|
|
19
19
|
const axios = require('axios');
|
|
20
20
|
const JSON5 = require('json5');
|
|
21
21
|
const compareVersions = require('compare-versions');
|
|
22
|
+
//const Languagedetect = require('languagedetect');
|
|
23
|
+
//const languagedetect = new Languagedetect;
|
|
24
|
+
|
|
22
25
|
const issues = require('./doc/issues');
|
|
23
26
|
|
|
24
27
|
const version = require('./package.json').version;
|
|
25
28
|
|
|
29
|
+
// diable axios caching
|
|
30
|
+
axios.defaults.headers = {
|
|
31
|
+
'Cache-Control': 'no-cache',
|
|
32
|
+
'Pragma': 'no-cache',
|
|
33
|
+
'Expires': '0',
|
|
34
|
+
};
|
|
35
|
+
|
|
26
36
|
// adapt recommended version here
|
|
27
37
|
const recommendedAdapterCoreVersion = '3.0.6';
|
|
28
38
|
const recommendedJsControllerVersion = '5.0.11';
|
|
@@ -57,7 +67,7 @@ const blacklistIOPackageJson = {
|
|
|
57
67
|
"err": true
|
|
58
68
|
},
|
|
59
69
|
"common.title": {
|
|
60
|
-
"msg": "\"common.title\" is deprecated
|
|
70
|
+
"msg": "\"common.title\" is deprecated and replaced by \"common.titleLang\". Please remove from io-package.json.",
|
|
61
71
|
"err": false
|
|
62
72
|
},
|
|
63
73
|
"common.main": {
|
|
@@ -133,11 +143,17 @@ function getDependencyArray(deps) {
|
|
|
133
143
|
.reduce((acc, dep) => acc.concat(dep), []);
|
|
134
144
|
}
|
|
135
145
|
|
|
146
|
+
/*
|
|
136
147
|
function checkLanguages(langObj) {
|
|
137
148
|
if (Object.keys(langObj).length !== allowedLanguages.length) return false;
|
|
138
149
|
|
|
139
150
|
return Object.keys(langObj).filter(lang => allowedLanguages.includes(lang)).length === allowedLanguages.length;
|
|
140
151
|
}
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
function checkLanguages(langObj, languages) {
|
|
155
|
+
return languages.filter( lang => !langObj[lang]);
|
|
156
|
+
}
|
|
141
157
|
|
|
142
158
|
function getGithubApiData(context) {
|
|
143
159
|
return new Promise((resolve, reject) => {
|
|
@@ -540,6 +556,12 @@ const allowedLanguages = [
|
|
|
540
556
|
'zh-cn'
|
|
541
557
|
];
|
|
542
558
|
|
|
559
|
+
const requiredLanguages = [
|
|
560
|
+
'en',
|
|
561
|
+
'de',
|
|
562
|
+
// 'xx' // TESTING ONLY
|
|
563
|
+
];
|
|
564
|
+
|
|
543
565
|
const allowedModes = {
|
|
544
566
|
'none': 'this adapter will not be started',
|
|
545
567
|
'daemon': 'always running process (will be restarted if process exits)',
|
|
@@ -976,6 +998,45 @@ function checkIOPackageJson(context) {
|
|
|
976
998
|
context.errors.push('[E101] io-package.json must have at least empty "native" attribute');
|
|
977
999
|
} else {
|
|
978
1000
|
context.checks.push('"native" found in io-package.json');
|
|
1001
|
+
|
|
1002
|
+
// Generic check for potential credentials that should have a counterpart in encryptedNative/protectedNative
|
|
1003
|
+
const suspiciousPhrases = [
|
|
1004
|
+
'apikey',
|
|
1005
|
+
'api_key',
|
|
1006
|
+
'credential',
|
|
1007
|
+
'pass',
|
|
1008
|
+
'passwd',
|
|
1009
|
+
'password',
|
|
1010
|
+
'passwort',
|
|
1011
|
+
'pin',
|
|
1012
|
+
'psk',
|
|
1013
|
+
'pwd',
|
|
1014
|
+
'secret',
|
|
1015
|
+
'token',
|
|
1016
|
+
];
|
|
1017
|
+
//const regex = new RegExp(suspiciousPhrases.join('|'), 'i');
|
|
1018
|
+
|
|
1019
|
+
let suspiciousKeys = Object.keys(context.ioPackageJson.native) || [];
|
|
1020
|
+
// console.log(`native keys: ${suspiciousKeys.join()}`);
|
|
1021
|
+
//suspiciousKeys = suspiciousKeys.filter( key => regex.test(key));
|
|
1022
|
+
suspiciousKeys = suspiciousKeys.filter( key => suspiciousPhrases.includes(key.toLowerCase()));
|
|
1023
|
+
// console.log(`suspecious keys: ${suspiciousKeys.join()}`);
|
|
1024
|
+
|
|
1025
|
+
if ( suspiciousKeys.length) {
|
|
1026
|
+
if (context.ioPackageJson.protectedNative) {
|
|
1027
|
+
const missingProtected = suspiciousKeys.filter( key => !context.ioPackageJson.protectedNative.includes(key));
|
|
1028
|
+
if (missingProtected.length) context.warnings.push( `[W173] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`);
|
|
1029
|
+
} else {
|
|
1030
|
+
context.warnings.push( `[W173] Potential sensitive data "${suspiciousKeys.join()}" not listed at "protectedNative" in io-package.json`);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (context.ioPackageJson.encryptedNative) {
|
|
1034
|
+
const missingProtected = suspiciousKeys.filter( key => !context.ioPackageJson.encryptedNative.includes(key));
|
|
1035
|
+
if (missingProtected.length) context.warnings.push( `[W174] Potential sensitive data "${missingProtected.join()}" not listed at "encryptedNative" in io-package.json`);
|
|
1036
|
+
} else {
|
|
1037
|
+
context.warnings.push( `[W174] Potential sensitive data "${suspiciousKeys.join()}" not listed at "encryptedNative" in io-package.json`);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
979
1040
|
}
|
|
980
1041
|
|
|
981
1042
|
if (!context.ioPackageJson.common) {
|
|
@@ -989,10 +1050,11 @@ function checkIOPackageJson(context) {
|
|
|
989
1050
|
context.checks.push('"common.name" is valid in io-package.json');
|
|
990
1051
|
}
|
|
991
1052
|
|
|
1053
|
+
/*
|
|
992
1054
|
if (context.ioPackageJson.common.title) {
|
|
993
1055
|
context.warnings.push('[W171] "common.title" is deprecated in io-package.json. Please remove from io-package.json.');
|
|
994
1056
|
}
|
|
995
|
-
|
|
1057
|
+
|
|
996
1058
|
if (context.ioPackageJson.common.main) {
|
|
997
1059
|
context.warnings.push('[W177] "common.main" is deprecated in io-package.json. For js-controller >= 3.3 please use package.json main and remove "common.main" from io-package.json.');
|
|
998
1060
|
}
|
|
@@ -1016,24 +1078,34 @@ function checkIOPackageJson(context) {
|
|
|
1016
1078
|
|
|
1017
1079
|
if (typeof context.ioPackageJson.common.titleLang !== 'object') {
|
|
1018
1080
|
context.errors.push(`[E105] "common.titleLang" must be an object. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1019
|
-
} else
|
|
1020
|
-
context.
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
context.errors.push(`[E106] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1032
|
-
} else {
|
|
1033
|
-
context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1081
|
+
} else {
|
|
1082
|
+
let missingLang = checkLanguages(context.ioPackageJson.common.titleLang, requiredLanguages);
|
|
1083
|
+
if (missingLang.length) {
|
|
1084
|
+
context.warnings.push(`[E105] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
missingLang = checkLanguages(context.ioPackageJson.common.titleLang, allowedLanguages);
|
|
1088
|
+
missingLang = missingLang.filter( lang => !requiredLanguages.includes(lang));
|
|
1089
|
+
if (missingLang.length) {
|
|
1090
|
+
missingLang = [... new Set(missingLang)]; // make unique
|
|
1091
|
+
context.warnings.push(`[W105] Missing suggested translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
|
|
1092
|
+
}
|
|
1036
1093
|
}
|
|
1094
|
+
|
|
1095
|
+
Object.keys(context.ioPackageJson.common.titleLang).forEach(lang => {
|
|
1096
|
+
const text = context.ioPackageJson.common.titleLang[lang];
|
|
1097
|
+
if (text.match(/iobroker/i)) {
|
|
1098
|
+
context.errors.push(`[W105] "common.titleLang" should not have ioBroker in the name. It is clear, for what this adapter was created. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1099
|
+
} else {
|
|
1100
|
+
context.checks.push('"common.titleLang" has no ioBroker in it in io-package.json');
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (text.match(/\sadapter|adapter\s/i)) {
|
|
1104
|
+
context.errors.push(`[E106] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1105
|
+
} else {
|
|
1106
|
+
context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1037
1109
|
}
|
|
1038
1110
|
|
|
1039
1111
|
if (!context.ioPackageJson.common.version) {
|
|
@@ -1055,13 +1127,22 @@ function checkIOPackageJson(context) {
|
|
|
1055
1127
|
|
|
1056
1128
|
if (typeof context.ioPackageJson.common.desc !== 'object') {
|
|
1057
1129
|
context.errors.push(`[E109] "common.desc" in io-package.json should be an object for many languages. Found only "${context.ioPackageJson.common.desc}"`);
|
|
1058
|
-
} else if (!checkLanguages(context.ioPackageJson.common.desc)) {
|
|
1059
|
-
context.warnings.push(`[W109] "common.desc" should be translated into all supported languages (${allowedLanguages.join(', ')})`);
|
|
1060
1130
|
} else {
|
|
1061
|
-
|
|
1131
|
+
|
|
1132
|
+
let missingLang = checkLanguages(context.ioPackageJson.common.desc, requiredLanguages);
|
|
1133
|
+
if (missingLang.length) {
|
|
1134
|
+
context.warnings.push(`[E109] Missing mandatory translation into ${missingLang.join()} of "common.desc" in io-package.json.`);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
missingLang = checkLanguages(context.ioPackageJson.common.desc, allowedLanguages);
|
|
1138
|
+
missingLang = missingLang.filter( lang => !requiredLanguages.includes(lang));
|
|
1139
|
+
if (missingLang.length) {
|
|
1140
|
+
missingLang = [... new Set(missingLang)]; // make unique
|
|
1141
|
+
context.warnings.push(`[W109] Missing suggested translation into ${missingLang.join()} of "common.desc" in io-package.json.`);
|
|
1142
|
+
}
|
|
1062
1143
|
}
|
|
1063
1144
|
}
|
|
1064
|
-
|
|
1145
|
+
|
|
1065
1146
|
if (context.ioPackageJson.common.keywords) {
|
|
1066
1147
|
const forbiddenKeywords = ['iobroker', 'adapter', 'smart home'];
|
|
1067
1148
|
if (!Array.isArray(context.ioPackageJson.common.keywords)) {
|
|
@@ -1247,14 +1328,28 @@ function checkIOPackageJson(context) {
|
|
|
1247
1328
|
});
|
|
1248
1329
|
|
|
1249
1330
|
if (!context.ioPackageJson.common.news[context.ioPackageJson.common.version]) {
|
|
1250
|
-
context.errors.push(`[E145] No "common.news" found for actual version ${context.ioPackageJson.common.version}`);
|
|
1331
|
+
context.errors.push(`[E145] No "common.news" found for actual version ${context.ioPackageJson.common.version} in io-package.json`);
|
|
1251
1332
|
}
|
|
1252
1333
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1334
|
+
let missingLang =[];
|
|
1335
|
+
Object.keys(context.ioPackageJson.common.news).forEach(version => {
|
|
1336
|
+
missingLang = missingLang.concat( checkLanguages(context.ioPackageJson.common.news[version], requiredLanguages) );
|
|
1337
|
+
});
|
|
1338
|
+
if (missingLang.length) {
|
|
1339
|
+
missingLang = [... new Set(missingLang)]; // make unique
|
|
1340
|
+
context.warnings.push(`[E145] Missing mandatory translation into ${missingLang.join()} of some "common.news" in io-package.json.`);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
missingLang =[];
|
|
1344
|
+
Object.keys(context.ioPackageJson.common.news).forEach(version => {
|
|
1345
|
+
missingLang = missingLang.concat(checkLanguages(context.ioPackageJson.common.news[version], allowedLanguages));
|
|
1257
1346
|
});
|
|
1347
|
+
missingLang = missingLang.filter( lang => !requiredLanguages.includes(lang));
|
|
1348
|
+
if (missingLang.length) {
|
|
1349
|
+
missingLang = [... new Set(missingLang)]; // make unique
|
|
1350
|
+
context.warnings.push(`[W145] Missing suggested translation into ${missingLang.join()} of some "common.news" in io-package.json.`);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1258
1353
|
}
|
|
1259
1354
|
|
|
1260
1355
|
// now check the package.json again, because it is valid only for onlyWWW
|
|
@@ -1315,31 +1410,38 @@ function checkIOPackageJson(context) {
|
|
|
1315
1410
|
let currentJsControllerVersion = undefined;
|
|
1316
1411
|
|
|
1317
1412
|
if (context.ioPackageJson.common.dependencies) {
|
|
1318
|
-
|
|
1413
|
+
if (!(context.ioPackageJson.common.dependencies instanceof Array)){
|
|
1414
|
+
context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
|
|
1415
|
+
} else {
|
|
1416
|
+
const dependencyArray = getDependencyArray(context.ioPackageJson.common.dependencies);
|
|
1319
1417
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1418
|
+
// Admin is not allowed in dependencies (globalDependencies only)
|
|
1419
|
+
if (dependencyArray.includes('admin')) {
|
|
1420
|
+
context.errors.push(`[E160] "admin" is not allowed in common.dependencies`);
|
|
1421
|
+
}
|
|
1324
1422
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1423
|
+
const jsControllerDependency = context.ioPackageJson.common.dependencies.find(dep => Object.keys(dep).find(attr => attr === 'js-controller'));
|
|
1424
|
+
if (jsControllerDependency) {
|
|
1425
|
+
console.log(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
|
|
1328
1426
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1427
|
+
if (!jsControllerDependency['js-controller'].startsWith('>=')) {
|
|
1428
|
+
context.errors.push(`[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
|
|
1429
|
+
} else {
|
|
1430
|
+
currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
|
|
1431
|
+
}
|
|
1333
1432
|
}
|
|
1334
1433
|
}
|
|
1335
1434
|
}
|
|
1336
1435
|
|
|
1337
1436
|
if (context.ioPackageJson.common.globalDependencies) {
|
|
1338
1437
|
const dependencyArray = getDependencyArray(context.ioPackageJson.common.globalDependencies);
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1438
|
+
if (!(context.ioPackageJson.common.globalDependencies instanceof Array)){
|
|
1439
|
+
context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
|
|
1440
|
+
} else {
|
|
1441
|
+
// js-controller is not allowed in global dependencies (dependencies only)
|
|
1442
|
+
if (dependencyArray.includes('js-controller')) {
|
|
1443
|
+
context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
|
|
1444
|
+
}
|
|
1343
1445
|
}
|
|
1344
1446
|
}
|
|
1345
1447
|
|
|
@@ -1378,19 +1480,8 @@ function checkIOPackageJson(context) {
|
|
|
1378
1480
|
}
|
|
1379
1481
|
}
|
|
1380
1482
|
}
|
|
1381
|
-
|
|
1382
|
-
/*
|
|
1383
|
-
- adapter-core 3.0.0+ requires node 16+ - solved as node 16 is global minimum
|
|
1384
|
-
- adapter-core 3.0.6 is recommended as minimum
|
|
1385
|
-
*/
|
|
1386
|
-
|
|
1387
|
-
if (!compareVersions.compare(context.packageJson.dependencies['@iobroker/adapter-core'], `${recommendedAdapterCoreVersion}`, '>=')) {
|
|
1388
|
-
context.warnings.push(`[W173] "@iobroker/adapter-core" (${context.packageJson.dependencies['@iobroker/adapter-core']}) should be ${recommendedAdapterCoreVersion} or newer - please update`);
|
|
1389
|
-
} else {
|
|
1390
|
-
context.checks.push(`adapter-core ${context.packageJson.dependencies['@iobroker/adapter-core']} matches recommendation`);
|
|
1391
|
-
}
|
|
1392
1483
|
}
|
|
1393
|
-
|
|
1484
|
+
|
|
1394
1485
|
if (context.ioPackageJson.common.protectedNative) {
|
|
1395
1486
|
if (!currentJsControllerVersion) {
|
|
1396
1487
|
context.errors.push(`[E157] common.protectedNative requires dependency {"js-controller": ">=2.0.2"} or later - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
|
|
@@ -1510,8 +1601,9 @@ function checkIOPackageJson(context) {
|
|
|
1510
1601
|
}
|
|
1511
1602
|
// do not put any code behind this line
|
|
1512
1603
|
|
|
1513
|
-
// max number is
|
|
1514
|
-
// free 144
|
|
1604
|
+
// max number is E186
|
|
1605
|
+
// free 144
|
|
1606
|
+
// duplicates to check 145
|
|
1515
1607
|
}
|
|
1516
1608
|
});
|
|
1517
1609
|
});
|
|
@@ -2102,6 +2194,9 @@ function checkReadme(context) {
|
|
|
2102
2194
|
context.checks.push('Valid copyright year found in README.md');
|
|
2103
2195
|
}
|
|
2104
2196
|
}
|
|
2197
|
+
|
|
2198
|
+
// languages = languagedetect.detect(data, 3);
|
|
2199
|
+
//console.log(JSON.stringify(languages));
|
|
2105
2200
|
}
|
|
2106
2201
|
|
|
2107
2202
|
// max E606
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.4.0",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"axios": "^1.6.8",
|
|
6
6
|
"compare-versions": "^6.1.0",
|
|
7
7
|
"image-size": "^1.1.1",
|
|
8
|
-
"unzipper": "^0.
|
|
8
|
+
"unzipper": "^0.11.4",
|
|
9
9
|
"json5": "^2.2.3"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|