retire 4.2.1 → 4.2.3
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 +12 -0
- package/lib/cli.js +1 -0
- package/lib/repo.js +5 -6
- package/lib/reporters/cyclonedx-json.js +3 -2
- package/lib/reporters/cyclonedx.js +2 -1
- package/lib/reporters/utils.d.ts +2 -0
- package/lib/reporters/utils.js +8 -0
- package/lib/retire.js +4 -3
- package/lib/types.d.ts +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/lib/cli.js
CHANGED
|
@@ -108,6 +108,7 @@ const config = {
|
|
|
108
108
|
exitwith: (_j = prg.exitwith) !== null && _j !== void 0 ? _j : 13,
|
|
109
109
|
includeOsv: !!prg.includeOsv,
|
|
110
110
|
verbose: !!prg.verbose,
|
|
111
|
+
proxy: prg.proxy,
|
|
111
112
|
};
|
|
112
113
|
log.info(`retire.js v${retire.version}`);
|
|
113
114
|
function exitWithError(msg) {
|
package/lib/repo.js
CHANGED
|
@@ -31,9 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
35
|
exports.loadrepositoryFromFile = exports.loadrepository = exports.asbowerrepo = void 0;
|
|
39
36
|
const fs = __importStar(require("fs"));
|
|
@@ -42,7 +39,7 @@ const http = __importStar(require("http"));
|
|
|
42
39
|
const https = __importStar(require("https"));
|
|
43
40
|
const retire = __importStar(require("./retire"));
|
|
44
41
|
const URL = __importStar(require("url"));
|
|
45
|
-
const proxy_agent_1 =
|
|
42
|
+
const proxy_agent_1 = require("proxy-agent");
|
|
46
43
|
function loadJson(url, options) {
|
|
47
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
45
|
return new Promise((resolve, reject) => {
|
|
@@ -50,7 +47,9 @@ function loadJson(url, options) {
|
|
|
50
47
|
const reqOptions = Object.assign(Object.assign({}, URL.parse(url)), { method: 'GET' });
|
|
51
48
|
const proxyUri = options.proxy || process.env.http_proxy;
|
|
52
49
|
if (proxyUri) {
|
|
53
|
-
reqOptions.agent = new proxy_agent_1.
|
|
50
|
+
reqOptions.agent = new proxy_agent_1.ProxyAgent({
|
|
51
|
+
getProxyForUrl: () => proxyUri,
|
|
52
|
+
});
|
|
54
53
|
}
|
|
55
54
|
if (options.insecure) {
|
|
56
55
|
reqOptions.rejectUnauthorized = false;
|
|
@@ -126,7 +125,7 @@ function loadFromCache(url, cachedir, options) {
|
|
|
126
125
|
function asbowerrepo(jsRepo) {
|
|
127
126
|
const result = {};
|
|
128
127
|
Object.keys(jsRepo).map((k) => {
|
|
129
|
-
|
|
128
|
+
(jsRepo[k].bowername || [k]).map((b) => {
|
|
130
129
|
result[b] = result[b] || { vulnerabilities: [] };
|
|
131
130
|
result[b].vulnerabilities = result[b].vulnerabilities.concat(jsRepo[k].vulnerabilities);
|
|
132
131
|
});
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const retire = __importStar(require("../retire"));
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const uuid_1 = require("uuid");
|
|
30
|
+
const utils_1 = require("./utils");
|
|
30
31
|
function configureCycloneDXJSONLogger(logger, writer, config, hash) {
|
|
31
32
|
let vulnsFound = false;
|
|
32
33
|
const finalResults = {
|
|
@@ -71,7 +72,7 @@ function configureCycloneDXJSONLogger(logger, writer, config, hash) {
|
|
|
71
72
|
{ alg: 'SHA-512', content: hash.sha512(file) },
|
|
72
73
|
];
|
|
73
74
|
}
|
|
74
|
-
const purl =
|
|
75
|
+
const purl = (0, utils_1.generatePURL)(dep);
|
|
75
76
|
if (seen.has(purl))
|
|
76
77
|
return undefined;
|
|
77
78
|
seen.add(purl);
|
|
@@ -84,7 +85,7 @@ function configureCycloneDXJSONLogger(logger, writer, config, hash) {
|
|
|
84
85
|
};
|
|
85
86
|
})
|
|
86
87
|
.filter((x) => x != undefined))
|
|
87
|
-
.reduce((a, b) => a.concat(b));
|
|
88
|
+
.reduce((a, b) => a.concat(b), []);
|
|
88
89
|
write(JSON.stringify({
|
|
89
90
|
bomFormat: 'CycloneDX',
|
|
90
91
|
specVersion: '1.4',
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const retire = __importStar(require("../retire"));
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const uuid_1 = require("uuid");
|
|
30
|
+
const utils_1 = require("./utils");
|
|
30
31
|
function configureCycloneDXLogger(logger, writer, config, hash) {
|
|
31
32
|
let vulnsFound = false;
|
|
32
33
|
const finalResults = {
|
|
@@ -72,7 +73,7 @@ function configureCycloneDXLogger(logger, writer, config, hash) {
|
|
|
72
73
|
<hash alg="SHA-512">${hash.sha512(file)}</hash>
|
|
73
74
|
</hashes>`;
|
|
74
75
|
}
|
|
75
|
-
const purl =
|
|
76
|
+
const purl = (0, utils_1.generatePURL)(dep);
|
|
76
77
|
if (seen.has(purl))
|
|
77
78
|
return '';
|
|
78
79
|
seen.add(purl);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePURL = void 0;
|
|
4
|
+
function generatePURL(component) {
|
|
5
|
+
const compName = component.npmname || component.component;
|
|
6
|
+
return `pkg:npm/${compName}@${component.version}`;
|
|
7
|
+
}
|
|
8
|
+
exports.generatePURL = generatePURL;
|
package/lib/retire.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var exports = exports || {};
|
|
7
|
-
exports.version = '4.2.
|
|
7
|
+
exports.version = '4.2.3';
|
|
8
8
|
|
|
9
9
|
function isDefined(o) {
|
|
10
10
|
return typeof o !== 'undefined';
|
|
@@ -29,7 +29,7 @@ function scan(data, extractor, repo, matcher) {
|
|
|
29
29
|
var match = matcher(extractors[i], data);
|
|
30
30
|
if (match) {
|
|
31
31
|
match = match.replace(/(\.|-)min$/, '');
|
|
32
|
-
detected.push({ version: match, component: component, detection: extractor });
|
|
32
|
+
detected.push({ version: match, component: component, npmname: repo[component].npmname, detection: extractor });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -65,7 +65,7 @@ function scanhash(hash, repo) {
|
|
|
65
65
|
var hashes = repo[component].extractors.hashes;
|
|
66
66
|
if (!isDefined(hashes)) continue;
|
|
67
67
|
if (hashes.hasOwnProperty(hash)) {
|
|
68
|
-
return [{ version: hashes[hash], component: component, detection: 'hash' }];
|
|
68
|
+
return [{ version: hashes[hash], component: component, npmname: repo[component].npmname, detection: 'hash' }];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return [];
|
|
@@ -76,6 +76,7 @@ function check(results, repo) {
|
|
|
76
76
|
var result = results[r];
|
|
77
77
|
if (!isDefined(repo[result.component])) continue;
|
|
78
78
|
var vulns = repo[result.component].vulnerabilities;
|
|
79
|
+
result.npmname = repo[result.component].npmname;
|
|
79
80
|
for (var i in vulns) {
|
|
80
81
|
if (!isDefined(vulns[i].below) || !isAtOrAbove(result.version, vulns[i].below)) {
|
|
81
82
|
if (isDefined(vulns[i].atOrAbove) && !isAtOrAbove(result.version, vulns[i].atOrAbove)) {
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Logger } from './reporting';
|
|
3
3
|
export type Repository = Record<string, {
|
|
4
|
-
bowername?: string;
|
|
4
|
+
bowername?: string[];
|
|
5
|
+
npmname?: string;
|
|
5
6
|
vulnerabilities: Vulnerability[];
|
|
6
7
|
extractors: {
|
|
7
8
|
func?: string[];
|
|
@@ -28,6 +29,7 @@ export type Vulnerability = {
|
|
|
28
29
|
};
|
|
29
30
|
export type Component = {
|
|
30
31
|
component: string;
|
|
32
|
+
npmname?: string;
|
|
31
33
|
version: string;
|
|
32
34
|
vulnerabilities?: Vulnerability[];
|
|
33
35
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Erlend Oftedal <erlend@oftedal.no>",
|
|
3
3
|
"name": "retire",
|
|
4
4
|
"description": "Retire is a tool for detecting use of vulnerable libraries",
|
|
5
|
-
"version": "4.2.
|
|
5
|
+
"version": "4.2.3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"ansi-colors": "^4.1.1",
|
|
17
17
|
"commander": "^10.0.0",
|
|
18
|
-
"proxy-agent": "^
|
|
18
|
+
"proxy-agent": "^6.2.0",
|
|
19
19
|
"uuid": "^9.0.0",
|
|
20
20
|
"walkdir": "0.4.1",
|
|
21
21
|
"zod": "^3.20.6"
|