@iobroker/repochecker 2.3.1 → 2.5.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 +7 -0
- package/doc/issues.json +28 -1
- package/index.js +225 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,13 @@ Branch (`master/main/dev`) is optional.
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
## Changelog
|
|
23
|
+
### 2.5.0 (2024-05-30)
|
|
24
|
+
* (mcm1957) Add check ensure that dependency revisions are available at repository. [#180]
|
|
25
|
+
|
|
26
|
+
### 2.4.0 (2024-05-30)
|
|
27
|
+
* (mcm1957) Add check to protect sensitive data. [#195]
|
|
28
|
+
* (mcm1957) Add check to verify that dependencies and globalDepencies are of type array. [#90]
|
|
29
|
+
|
|
23
30
|
### 2.3.1 (2024-05-07)
|
|
24
31
|
* (mcm1957) Reduce number of missing translation warnings.
|
|
25
32
|
* (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
|
},
|
|
@@ -395,6 +401,15 @@
|
|
|
395
401
|
"E429": {
|
|
396
402
|
"title": "Adapter name should use `-` instead of `_`"
|
|
397
403
|
},
|
|
404
|
+
"E430": {
|
|
405
|
+
"title": "Cannot download http://repo.iobroker.live/sources-dist.json"
|
|
406
|
+
},
|
|
407
|
+
"E431": {
|
|
408
|
+
"title": "Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository"
|
|
409
|
+
},
|
|
410
|
+
"E433": {
|
|
411
|
+
"title": "Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository"
|
|
412
|
+
},
|
|
398
413
|
"E500": {
|
|
399
414
|
"title": "node_modules found in repo. Please delete it"
|
|
400
415
|
},
|
|
@@ -530,8 +545,11 @@
|
|
|
530
545
|
"W172": {
|
|
531
546
|
"title": "`common.localLink` in io-package.json is deprecated. Please define object `common.localLinks`: { `_default`: `...` }"
|
|
532
547
|
},
|
|
548
|
+
"W173": {
|
|
549
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `protectedNative` in io-package.json"
|
|
550
|
+
},
|
|
533
551
|
"W174": {
|
|
534
|
-
"title": "
|
|
552
|
+
"title": "Potential sensitive data `${missingProtected.join()}` not listed at `encryptedNative` in io-package.json"
|
|
535
553
|
},
|
|
536
554
|
"W177": {
|
|
537
555
|
"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."
|
|
@@ -557,6 +575,15 @@
|
|
|
557
575
|
"W400": {
|
|
558
576
|
"title": "Cannot find adapter in latest repository"
|
|
559
577
|
},
|
|
578
|
+
"W432": {
|
|
579
|
+
"title": "Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='"
|
|
580
|
+
},
|
|
581
|
+
"W433": {
|
|
582
|
+
"title": "Dependency ${dependency} not available at stable repository"
|
|
583
|
+
},
|
|
584
|
+
"W434": {
|
|
585
|
+
"title": "Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='"
|
|
586
|
+
},
|
|
560
587
|
"W504": {
|
|
561
588
|
"title": "setInterval found in main, but no clearInterval detected"
|
|
562
589
|
},
|
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';
|
|
@@ -133,6 +143,43 @@ function getDependencyArray(deps) {
|
|
|
133
143
|
.reduce((acc, dep) => acc.concat(dep), []);
|
|
134
144
|
}
|
|
135
145
|
|
|
146
|
+
// dependencies might be:
|
|
147
|
+
// [
|
|
148
|
+
// {"js-controller":">=1.2.3"}
|
|
149
|
+
// ]
|
|
150
|
+
// or
|
|
151
|
+
// [
|
|
152
|
+
// {"js-controller":">=1.2.3"},
|
|
153
|
+
// {"vis":">=1.2.3"}
|
|
154
|
+
// ]
|
|
155
|
+
// or
|
|
156
|
+
// [
|
|
157
|
+
// {
|
|
158
|
+
// "js-controller":">=1.2.3",
|
|
159
|
+
// "vis":">=1.2.3"
|
|
160
|
+
// }
|
|
161
|
+
// ]
|
|
162
|
+
// or
|
|
163
|
+
// [
|
|
164
|
+
// {"js-controller":">=1.2.3"},
|
|
165
|
+
// "vis"
|
|
166
|
+
// ]
|
|
167
|
+
function getDependencies(deps) {
|
|
168
|
+
const ret = {};
|
|
169
|
+
console.log(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`)
|
|
170
|
+
for (let dep of deps ) {
|
|
171
|
+
if (typeof dep === 'object') {
|
|
172
|
+
for (let key in dep ) {
|
|
173
|
+
ret[key] = dep[key];
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
ret[ dep ] = '>=0';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
console.log(`ret: ${JSON.stringify(ret)}`)
|
|
180
|
+
return ret;
|
|
181
|
+
}
|
|
182
|
+
|
|
136
183
|
/*
|
|
137
184
|
function checkLanguages(langObj) {
|
|
138
185
|
if (Object.keys(langObj).length !== allowedLanguages.length) return false;
|
|
@@ -988,6 +1035,45 @@ function checkIOPackageJson(context) {
|
|
|
988
1035
|
context.errors.push('[E101] io-package.json must have at least empty "native" attribute');
|
|
989
1036
|
} else {
|
|
990
1037
|
context.checks.push('"native" found in io-package.json');
|
|
1038
|
+
|
|
1039
|
+
// Generic check for potential credentials that should have a counterpart in encryptedNative/protectedNative
|
|
1040
|
+
const suspiciousPhrases = [
|
|
1041
|
+
'apikey',
|
|
1042
|
+
'api_key',
|
|
1043
|
+
'credential',
|
|
1044
|
+
'pass',
|
|
1045
|
+
'passwd',
|
|
1046
|
+
'password',
|
|
1047
|
+
'passwort',
|
|
1048
|
+
'pin',
|
|
1049
|
+
'psk',
|
|
1050
|
+
'pwd',
|
|
1051
|
+
'secret',
|
|
1052
|
+
'token',
|
|
1053
|
+
];
|
|
1054
|
+
//const regex = new RegExp(suspiciousPhrases.join('|'), 'i');
|
|
1055
|
+
|
|
1056
|
+
let suspiciousKeys = Object.keys(context.ioPackageJson.native) || [];
|
|
1057
|
+
// console.log(`native keys: ${suspiciousKeys.join()}`);
|
|
1058
|
+
//suspiciousKeys = suspiciousKeys.filter( key => regex.test(key));
|
|
1059
|
+
suspiciousKeys = suspiciousKeys.filter( key => suspiciousPhrases.includes(key.toLowerCase()));
|
|
1060
|
+
// console.log(`suspecious keys: ${suspiciousKeys.join()}`);
|
|
1061
|
+
|
|
1062
|
+
if ( suspiciousKeys.length) {
|
|
1063
|
+
if (context.ioPackageJson.protectedNative) {
|
|
1064
|
+
const missingProtected = suspiciousKeys.filter( key => !context.ioPackageJson.protectedNative.includes(key));
|
|
1065
|
+
if (missingProtected.length) context.warnings.push( `[W173] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`);
|
|
1066
|
+
} else {
|
|
1067
|
+
context.warnings.push( `[W173] Potential sensitive data "${suspiciousKeys.join()}" not listed at "protectedNative" in io-package.json`);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
if (context.ioPackageJson.encryptedNative) {
|
|
1071
|
+
const missingProtected = suspiciousKeys.filter( key => !context.ioPackageJson.encryptedNative.includes(key));
|
|
1072
|
+
if (missingProtected.length) context.warnings.push( `[W174] Potential sensitive data "${missingProtected.join()}" not listed at "encryptedNative" in io-package.json`);
|
|
1073
|
+
} else {
|
|
1074
|
+
context.warnings.push( `[W174] Potential sensitive data "${suspiciousKeys.join()}" not listed at "encryptedNative" in io-package.json`);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
991
1077
|
}
|
|
992
1078
|
|
|
993
1079
|
if (!context.ioPackageJson.common) {
|
|
@@ -1361,34 +1447,45 @@ function checkIOPackageJson(context) {
|
|
|
1361
1447
|
let currentJsControllerVersion = undefined;
|
|
1362
1448
|
|
|
1363
1449
|
if (context.ioPackageJson.common.dependencies) {
|
|
1364
|
-
|
|
1450
|
+
if (!(context.ioPackageJson.common.dependencies instanceof Array)){
|
|
1451
|
+
context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
|
|
1452
|
+
} else {
|
|
1453
|
+
const dependencyArray = getDependencyArray(context.ioPackageJson.common.dependencies);
|
|
1365
1454
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1455
|
+
// Admin is not allowed in dependencies (globalDependencies only)
|
|
1456
|
+
if (dependencyArray.includes('admin')) {
|
|
1457
|
+
context.errors.push(`[E160] "admin" is not allowed in common.dependencies`);
|
|
1458
|
+
}
|
|
1370
1459
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1460
|
+
const jsControllerDependency = context.ioPackageJson.common.dependencies.find(dep => Object.keys(dep).find(attr => attr === 'js-controller'));
|
|
1461
|
+
if (jsControllerDependency) {
|
|
1462
|
+
console.log(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
|
|
1374
1463
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1464
|
+
if (!jsControllerDependency['js-controller'].startsWith('>=')) {
|
|
1465
|
+
context.errors.push(`[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
|
|
1466
|
+
} else {
|
|
1467
|
+
currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
|
|
1468
|
+
}
|
|
1379
1469
|
}
|
|
1470
|
+
|
|
1380
1471
|
}
|
|
1381
1472
|
}
|
|
1382
1473
|
|
|
1383
1474
|
if (context.ioPackageJson.common.globalDependencies) {
|
|
1384
1475
|
const dependencyArray = getDependencyArray(context.ioPackageJson.common.globalDependencies);
|
|
1385
1476
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1477
|
+
if (!(context.ioPackageJson.common.globalDependencies instanceof Array)){
|
|
1478
|
+
context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
|
|
1479
|
+
} else {
|
|
1480
|
+
// js-controller is not allowed in global dependencies (dependencies only)
|
|
1481
|
+
if (dependencyArray.includes('js-controller')) {
|
|
1482
|
+
context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
|
|
1483
|
+
}
|
|
1389
1484
|
}
|
|
1485
|
+
|
|
1390
1486
|
}
|
|
1391
1487
|
|
|
1488
|
+
|
|
1392
1489
|
if (context.packageJson.dependencies && context.packageJson.dependencies['@iobroker/adapter-core']) {
|
|
1393
1490
|
/*
|
|
1394
1491
|
- adapter-core <2.3 has no special dep requirements
|
|
@@ -1545,8 +1642,8 @@ function checkIOPackageJson(context) {
|
|
|
1545
1642
|
}
|
|
1546
1643
|
// do not put any code behind this line
|
|
1547
1644
|
|
|
1548
|
-
// max number is
|
|
1549
|
-
// free 144
|
|
1645
|
+
// max number is E186
|
|
1646
|
+
// free 144
|
|
1550
1647
|
// duplicates to check 145
|
|
1551
1648
|
}
|
|
1552
1649
|
});
|
|
@@ -1722,7 +1819,7 @@ function checkRepo(context) {
|
|
|
1722
1819
|
}
|
|
1723
1820
|
|
|
1724
1821
|
// download stable repo
|
|
1725
|
-
|
|
1822
|
+
let _response = await axios('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json');
|
|
1726
1823
|
body = _response.data;
|
|
1727
1824
|
if (!body) {
|
|
1728
1825
|
context.errors.push('[E420] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json');
|
|
@@ -1774,6 +1871,113 @@ function checkRepo(context) {
|
|
|
1774
1871
|
}
|
|
1775
1872
|
}
|
|
1776
1873
|
}
|
|
1874
|
+
|
|
1875
|
+
_response = await axios('http://repo.iobroker.live/sources-dist-latest.json');
|
|
1876
|
+
body = _response.data;
|
|
1877
|
+
if (!body) {
|
|
1878
|
+
context.errors.push('[E429] Cannot download http://repo.iobroker.live/sources-dist-latest.json');
|
|
1879
|
+
} else {
|
|
1880
|
+
context.latestRepoLive = body;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
_response = await axios('http://repo.iobroker.live/sources-dist.json');
|
|
1884
|
+
body = _response.data;
|
|
1885
|
+
if (!body) {
|
|
1886
|
+
context.errors.push('[E430] Cannot download http://repo.iobroker.live/sources-dist.json');
|
|
1887
|
+
} else {
|
|
1888
|
+
context.stableRepoLive = body;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
if (context.latestRepo && context.latestRepoLive && context.stableRepo && context.stableRepoLive) {
|
|
1892
|
+
if (context.ioPackageJson.common.dependencies) {
|
|
1893
|
+
const dependencies = getDependencies(context.ioPackageJson.common.dependencies);
|
|
1894
|
+
for ( const dependency in dependencies ) {
|
|
1895
|
+
|
|
1896
|
+
if ( !context.latestRepoLive[dependency] ) {
|
|
1897
|
+
context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
|
|
1898
|
+
} else {
|
|
1899
|
+
const versDependency = dependencies[dependency];
|
|
1900
|
+
const versRepository = context.latestRepoLive[dependency].version;
|
|
1901
|
+
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
1902
|
+
if (!versDependency.startsWith('>=')) {
|
|
1903
|
+
context.warnings.push(`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
|
|
1904
|
+
} else {
|
|
1905
|
+
if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
|
|
1906
|
+
context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
|
|
1907
|
+
} else {
|
|
1908
|
+
context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
if ( !context.stableRepoLive[dependency] ) {
|
|
1914
|
+
context.warnings.push(`[W433] Dependency ${dependency} not available at stable repository`);
|
|
1915
|
+
} else {
|
|
1916
|
+
const versDependency = dependencies[dependency];
|
|
1917
|
+
const versRepository = context.stableRepoLive[dependency].version;
|
|
1918
|
+
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
1919
|
+
if (!versDependency.startsWith('>=')) {
|
|
1920
|
+
context.warnings.push(`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
|
|
1921
|
+
} else {
|
|
1922
|
+
if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
|
|
1923
|
+
context.errors.push(`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
|
|
1924
|
+
} else {
|
|
1925
|
+
context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
}
|
|
1931
|
+
} else {
|
|
1932
|
+
context.checks.push('common.dependency check skipped');
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
if (context.ioPackageJson.common.globalDependencies) {
|
|
1936
|
+
const dependencies = getDependencies(context.ioPackageJson.common.globalDependencies);
|
|
1937
|
+
for ( const dependency in dependencies ) {
|
|
1938
|
+
|
|
1939
|
+
if ( !context.latestRepoLive[dependency] ) {
|
|
1940
|
+
context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
|
|
1941
|
+
} else {
|
|
1942
|
+
const versDependency = dependencies[dependency];
|
|
1943
|
+
const versRepository = context.latestRepoLive[dependency].version;
|
|
1944
|
+
console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
1945
|
+
if (!versDependency.startsWith('>=')) {
|
|
1946
|
+
context.warnings.push(`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
|
|
1947
|
+
} else {
|
|
1948
|
+
if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
|
|
1949
|
+
context.errors.push(`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`);
|
|
1950
|
+
} else {
|
|
1951
|
+
context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
if ( !context.stableRepoLive[dependency] ) {
|
|
1957
|
+
context.warnings.push(`[W433] Dependency ${dependency} not available at stable repository`);
|
|
1958
|
+
} else {
|
|
1959
|
+
const versDependency = dependencies[dependency];
|
|
1960
|
+
const versRepository = context.stableRepoLive[dependency].version;
|
|
1961
|
+
console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
1962
|
+
if (!versDependency.startsWith('>=')) {
|
|
1963
|
+
context.warnings.push(`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`);
|
|
1964
|
+
} else {
|
|
1965
|
+
if ( !compareVersions.compare( versRepository, versDependency.replace('>=',''), '>=')) {
|
|
1966
|
+
context.errors.push(`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`);
|
|
1967
|
+
} else {
|
|
1968
|
+
context.checks.push(`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
}
|
|
1974
|
+
} else {
|
|
1975
|
+
context.checks.push('common.globalDependency check skipped');
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
} else {
|
|
1979
|
+
context.checks.push(`Dependency checks skipped due to repository access errors`);
|
|
1980
|
+
}
|
|
1777
1981
|
return context;
|
|
1778
1982
|
});
|
|
1779
1983
|
} else {
|
|
@@ -2138,6 +2342,9 @@ function checkReadme(context) {
|
|
|
2138
2342
|
context.checks.push('Valid copyright year found in README.md');
|
|
2139
2343
|
}
|
|
2140
2344
|
}
|
|
2345
|
+
|
|
2346
|
+
// languages = languagedetect.detect(data, 3);
|
|
2347
|
+
//console.log(JSON.stringify(languages));
|
|
2141
2348
|
}
|
|
2142
2349
|
|
|
2143
2350
|
// max E606
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.5.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": {
|