retire 4.1.0 → 4.1.1
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/CHANGELOG.md +4 -0
- package/lib/depsdev.js +20 -5
- package/lib/retire.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/depsdev.js
CHANGED
|
@@ -19,6 +19,11 @@ function loadJson(url, options) {
|
|
|
19
19
|
options.log.debug("Downloading " + url + " ...");
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
const req = https_1.default.request(url, res => {
|
|
22
|
+
if (res.statusCode == 404)
|
|
23
|
+
return resolve(undefined);
|
|
24
|
+
if (res.statusCode != 200) {
|
|
25
|
+
return reject("HTTP " + res.statusCode + " " + res.statusMessage + " for " + url);
|
|
26
|
+
}
|
|
22
27
|
const data = [];
|
|
23
28
|
res.on('data', c => data.push(c));
|
|
24
29
|
res.on('end', () => {
|
|
@@ -46,6 +51,8 @@ function loadAdvisory(packageName, version, id, options) {
|
|
|
46
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
52
|
const osvAdvisory = yield loadJson(`https://api.osv.dev/v1/vulns/${id}`, options);
|
|
48
53
|
const advisory = yield loadJson(`https://api.deps.dev/v3alpha/advisories/${id}`, options);
|
|
54
|
+
if (!advisory || !osvAdvisory)
|
|
55
|
+
return [];
|
|
49
56
|
const simplifiedRepo = {
|
|
50
57
|
[packageName]: {
|
|
51
58
|
vulnerabilities: osvAdvisory.affected.map(({ ranges }) => ranges.map(({ events }) => ({
|
|
@@ -67,12 +74,20 @@ function loadAdvisory(packageName, version, id, options) {
|
|
|
67
74
|
}
|
|
68
75
|
function checkOSV(packageName, version, options) {
|
|
69
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
try {
|
|
78
|
+
const versionInfo = yield getVulnerabilities(packageName, version, options);
|
|
79
|
+
if (!versionInfo)
|
|
80
|
+
return [];
|
|
81
|
+
if (versionInfo.advisoryKeys.length == 0)
|
|
82
|
+
return [];
|
|
83
|
+
const comps = yield Promise.all(versionInfo.advisoryKeys.map(({ id }) => loadAdvisory(packageName, version, id, options)));
|
|
84
|
+
const flattened = comps.reduce((a, b) => a.concat(b), []);
|
|
85
|
+
return flattened.map(x => { var _a; return (_a = x.vulnerabilities) !== null && _a !== void 0 ? _a : []; }).reduce((a, b) => a.concat(b), []);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
options.log.warn("Error checking OSV: " + e);
|
|
72
89
|
return [];
|
|
73
|
-
|
|
74
|
-
const flattened = comps.reduce((a, b) => a.concat(b), []);
|
|
75
|
-
return flattened.map(x => { var _a; return (_a = x.vulnerabilities) !== null && _a !== void 0 ? _a : []; }).reduce((a, b) => a.concat(b), []);
|
|
90
|
+
}
|
|
76
91
|
});
|
|
77
92
|
}
|
|
78
93
|
exports.checkOSV = checkOSV;
|
package/lib/retire.js
CHANGED
package/package.json
CHANGED