retire 1.5.1 → 1.6.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/bin/retire +6 -4
- package/lib/repo.js +14 -6
- package/lib/retire.js +10 -2
- package/package.json +1 -1
- package/.npmignore +0 -2
package/bin/retire
CHANGED
|
@@ -48,6 +48,7 @@ program
|
|
|
48
48
|
.option('--path <path>', 'Folder to scan for both')
|
|
49
49
|
.option('--jsrepo <path|url>', 'Local or internal version of repo')
|
|
50
50
|
.option('--noderepo <path|url>', 'Local or internal version of repo')
|
|
51
|
+
.option('--cachedir <path>', 'Path to use for local cache instead of /tmp/.retire-cache')
|
|
51
52
|
.option('--proxy <url>', 'Proxy url (http://some.sever:8080)')
|
|
52
53
|
.option('--outputformat <format>', 'Valid formats: text, json')
|
|
53
54
|
.option('--outputpath <path>', 'File to which output should be written')
|
|
@@ -61,13 +62,14 @@ program
|
|
|
61
62
|
var config = utils.extend({ path: '.' }, utils.pick(program, [
|
|
62
63
|
'package', 'node', 'js', 'jspath', 'verbose', 'nodepath', 'path', 'jsrepo', 'noderepo',
|
|
63
64
|
'dropexternal', 'nocache', 'proxy', 'ignore', 'ignorefile', 'outputformat', 'outputpath',
|
|
64
|
-
'severity', 'exitwith', 'includemeta'
|
|
65
|
+
'severity', 'exitwith', 'includemeta', 'cachedir'
|
|
65
66
|
]));
|
|
66
67
|
var scanStart = Date.now();
|
|
67
68
|
|
|
68
|
-
if (!config.nocache) {
|
|
69
|
+
if (!config.nocache && !config.cachedir) {
|
|
69
70
|
config.cachedir = path.resolve(os.tmpdir(), '.retire-cache/');
|
|
70
71
|
}
|
|
72
|
+
|
|
71
73
|
config.ignore = config.ignore ? utils.map(config.ignore.split(','), function(e) { return path.resolve(e); }) : [];
|
|
72
74
|
config.ignore = { paths : config.ignore, descriptors: [] };
|
|
73
75
|
|
|
@@ -111,8 +113,8 @@ if(config.ignorefile) {
|
|
|
111
113
|
|
|
112
114
|
scanner.on('vulnerable-dependency-found', function(result) {
|
|
113
115
|
vulnsFound = true;
|
|
114
|
-
var levels = result.results.map(function(r) { return r.vulnerabilities ? r.vulnerabilities.map(function(v) { return severityLevels[v.severity || 'critical'] }) : [] });
|
|
115
|
-
var severity = utils.flatten(levels).reduce(function(x,y) { return x > y ? x : y});
|
|
116
|
+
var levels = result.results.map(function(r) { return r.vulnerabilities ? r.vulnerabilities.map(function(v) { return severityLevels[v.severity || 'critical']; }) : []; });
|
|
117
|
+
var severity = utils.flatten(levels).reduce(function(x,y) { return x > y ? x : y; });
|
|
116
118
|
if(severity >= severityLevels[config.severity]) {
|
|
117
119
|
failProcess = true;
|
|
118
120
|
}
|
package/lib/repo.js
CHANGED
|
@@ -46,14 +46,22 @@ function loadFromCache(url, cachedir, options) {
|
|
|
46
46
|
var cache = fs.existsSync(cacheIndex) ? JSON.parse(fs.readFileSync(cacheIndex)) : {};
|
|
47
47
|
var now = new Date().getTime();
|
|
48
48
|
if (cache[url]) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
if (now - cache[url].date < 60*60*1000) {
|
|
50
|
+
log(options).info("Loading from cache: " + url);
|
|
51
|
+
return loadJsonFromFile(path.resolve(cachedir, cache[url].file), options);
|
|
52
|
+
} else {
|
|
53
|
+
if (fs.existsSync(path.resolve(cachedir, cache[url].date + '.json'))) {
|
|
54
|
+
try {
|
|
55
|
+
fs.unlinkSync(path.resolve(cachedir, cache[url].date + '.json'));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.code !== 'ENOENT') {
|
|
58
|
+
throw error;
|
|
59
|
+
} else {
|
|
60
|
+
console.warn("Could not delete cache. Ignore this error if you are running multiple retire.js in parallel");
|
|
55
61
|
}
|
|
62
|
+
}
|
|
56
63
|
}
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
var events = new emitter();
|
|
59
67
|
loadJson(url, options).on('done', function(data) {
|
package/lib/retire.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var exports = exports || {};
|
|
7
|
-
exports.version = '1.
|
|
7
|
+
exports.version = '1.6.3';
|
|
8
8
|
|
|
9
9
|
function isDefined(o) {
|
|
10
10
|
return typeof o !== 'undefined';
|
|
@@ -28,6 +28,7 @@ function scan(data, extractor, repo, matcher) {
|
|
|
28
28
|
for (var i in extractors) {
|
|
29
29
|
var match = matcher(extractors[i], data);
|
|
30
30
|
if (match) {
|
|
31
|
+
match = match.replace(/(\.|-)min$/, "");
|
|
31
32
|
detected.push({ version: match, component: component, detection: extractor });
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -52,6 +53,13 @@ function replacementMatch(regex, data) {
|
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
function splitAndMatchAll(tokenizer) {
|
|
57
|
+
return function(regex, data) {
|
|
58
|
+
var elm = data.split(tokenizer).pop();
|
|
59
|
+
return simpleMatch('^' + regex + '$', elm);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
|
|
56
64
|
function scanhash(hash, repo) {
|
|
57
65
|
for (var component in repo) {
|
|
@@ -146,7 +154,7 @@ exports.scanUri = function(uri, repo) {
|
|
|
146
154
|
};
|
|
147
155
|
|
|
148
156
|
exports.scanFileName = function(fileName, repo) {
|
|
149
|
-
var result = scan(fileName, 'filename', repo);
|
|
157
|
+
var result = scan(fileName, 'filename', repo, splitAndMatchAll('/'));
|
|
150
158
|
return check(result, repo);
|
|
151
159
|
};
|
|
152
160
|
|
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": "1.
|
|
5
|
+
"version": "1.6.3",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/RetireJS/retire.js.git"
|
package/.npmignore
DELETED