@iobroker/repochecker 2.3.1 → 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 +4 -0
- package/doc/issues.json +10 -1
- package/index.js +77 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,10 @@ 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
|
+
|
|
23
27
|
### 2.3.1 (2024-05-07)
|
|
24
28
|
* (mcm1957) Reduce number of missing translation warnings.
|
|
25
29
|
* (mcm1957) Seperate between required and recommended translations.
|
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
|
},
|
|
@@ -530,8 +536,11 @@
|
|
|
530
536
|
"W172": {
|
|
531
537
|
"title": "`common.localLink` in io-package.json is deprecated. Please define object `common.localLinks`: { `_default`: `...` }"
|
|
532
538
|
},
|
|
539
|
+
"W173": {
|
|
540
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `protectedNative` in io-package.json"
|
|
541
|
+
},
|
|
533
542
|
"W174": {
|
|
534
|
-
"title": "
|
|
543
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `encryptedNative` in io-package.json"
|
|
535
544
|
},
|
|
536
545
|
"W177": {
|
|
537
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';
|
|
@@ -988,6 +998,45 @@ function checkIOPackageJson(context) {
|
|
|
988
998
|
context.errors.push('[E101] io-package.json must have at least empty "native" attribute');
|
|
989
999
|
} else {
|
|
990
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
|
+
}
|
|
991
1040
|
}
|
|
992
1041
|
|
|
993
1042
|
if (!context.ioPackageJson.common) {
|
|
@@ -1361,31 +1410,38 @@ function checkIOPackageJson(context) {
|
|
|
1361
1410
|
let currentJsControllerVersion = undefined;
|
|
1362
1411
|
|
|
1363
1412
|
if (context.ioPackageJson.common.dependencies) {
|
|
1364
|
-
|
|
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);
|
|
1365
1417
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
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
|
+
}
|
|
1370
1422
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
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']}"`);
|
|
1374
1426
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
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
|
+
}
|
|
1379
1432
|
}
|
|
1380
1433
|
}
|
|
1381
1434
|
}
|
|
1382
1435
|
|
|
1383
1436
|
if (context.ioPackageJson.common.globalDependencies) {
|
|
1384
1437
|
const dependencyArray = getDependencyArray(context.ioPackageJson.common.globalDependencies);
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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
|
+
}
|
|
1389
1445
|
}
|
|
1390
1446
|
}
|
|
1391
1447
|
|
|
@@ -1545,8 +1601,8 @@ function checkIOPackageJson(context) {
|
|
|
1545
1601
|
}
|
|
1546
1602
|
// do not put any code behind this line
|
|
1547
1603
|
|
|
1548
|
-
// max number is
|
|
1549
|
-
// free 144
|
|
1604
|
+
// max number is E186
|
|
1605
|
+
// free 144
|
|
1550
1606
|
// duplicates to check 145
|
|
1551
1607
|
}
|
|
1552
1608
|
});
|
|
@@ -2138,6 +2194,9 @@ function checkReadme(context) {
|
|
|
2138
2194
|
context.checks.push('Valid copyright year found in README.md');
|
|
2139
2195
|
}
|
|
2140
2196
|
}
|
|
2197
|
+
|
|
2198
|
+
// languages = languagedetect.detect(data, 3);
|
|
2199
|
+
//console.log(JSON.stringify(languages));
|
|
2141
2200
|
}
|
|
2142
2201
|
|
|
2143
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": {
|