retire 1.1.2 → 1.1.6

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 CHANGED
@@ -21,17 +21,29 @@ Options:
21
21
  -n, --node Run node dependency scan only
22
22
  -j, --js Run scan of JavaScript files only
23
23
  -v, --verbose Show identified files (by default only vulnerable files are shown)
24
+ -x, --dropexternal Don't include project provided vulnerability repository
25
+ -c, --nocache Don't use local cache
24
26
 
25
27
  --jspath <path> Folder to scan for javascript files
26
28
  --nodepath <path> Folder to scan for node files
27
29
  --path <path> Folder to scan for both
28
- --jsrepo <path> Local version of repo
29
- --noderepo <path> Local version of repo
30
+ --jsrepo <path|url> Local or internal version of repo
31
+ --noderepo <path|url> Local or internal version of repo
30
32
  --proxy <url> Proxy url (http://some.sever:8080)
33
+ --outputformat <format> Valid formats: text, json
34
+ --outputpath <path> File to which output should be written
31
35
  --ignore <paths> Comma delimited list of paths to ignore
32
36
  --ignorefile <path> Custom .retireignore file, defaults to .retireignore
37
+ --exitwith <code> Custom exit code (default: 13) when vulnerabilities are found
33
38
  ````
34
39
 
40
+ .retireignore
41
+ -------------
42
+ ````
43
+ @qs # ignore this module regardless of location
44
+ node_modules/connect/node_modules/body-parser/node_modules/qs # ignore specific path
45
+ ````
46
+ Due to a bug in ignore resolving, please upgrade to >= 1.1.3
35
47
 
36
48
  Source code / Reporting an issue
37
49
  --------------------------------
package/bin/retire CHANGED
@@ -41,8 +41,8 @@ program
41
41
  .option('--jspath <path>', 'Folder to scan for javascript files')
42
42
  .option('--nodepath <path>', 'Folder to scan for node files')
43
43
  .option('--path <path>', 'Folder to scan for both')
44
- .option('--jsrepo <path>', 'Local version of repo')
45
- .option('--noderepo <path>', 'Local version of repo')
44
+ .option('--jsrepo <path|url>', 'Local or internal version of repo')
45
+ .option('--noderepo <path|url>', 'Local or internal version of repo')
46
46
  .option('--proxy <url>', 'Proxy url (http://some.sever:8080)')
47
47
  .option('--outputformat <format>', 'Valid formats: text, json')
48
48
  .option('--outputpath <path>', 'File to which output should be written')
@@ -77,7 +77,9 @@ if(config.ignorefile) {
77
77
 
78
78
  events.on('load-js-repo', function() {
79
79
  (config.jsrepo
80
- ? repo.loadrepositoryFromFile(config.jsrepo, config)
80
+ ? (config.jsrepo.match(/^https?:\/\//)
81
+ ? repo.loadrepository(config.jsrepo, config)
82
+ : repo.loadrepositoryFromFile(config.jsrepo, config))
81
83
  : repo.loadrepository('https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository.json', config)
82
84
  ).on('done', function(repo) {
83
85
  jsRepo = repo;
@@ -88,7 +90,9 @@ events.on('load-js-repo', function() {
88
90
 
89
91
  events.on('load-node-repo', function() {
90
92
  (config.noderepo
91
- ? repo.loadrepositoryFromFile(config.noderepo, config)
93
+ ? (config.noderepo.match(/^https?:\/\//)
94
+ ? repo.loadrepository(config.noderepo, config)
95
+ : repo.loadrepositoryFromFile(config.noderepo, config))
92
96
  : repo.loadrepository('https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/npmrepository.json', config)
93
97
  ).on('done', function(repo) {
94
98
  nodeRepo = repo;
package/lib/retire.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
  var exports = exports || {};
8
- exports.version = '1.1.2';
8
+ exports.version = '1.1.6';
9
9
 
10
10
  function isDefined(o) {
11
11
  return typeof o !== 'undefined';
@@ -120,7 +120,7 @@ exports.check = function(component, version, repo) {
120
120
  };
121
121
 
122
122
  exports.replaceVersion = function(jsRepoJsonAsText) {
123
- return jsRepoJsonAsText.replace(/§§version§§/g, '[0-9][0-9.a-z_\\\\-]+');
123
+ return jsRepoJsonAsText.replace(/§§version§§/g, '[0-9][0-9.a-z_\\\\-]+?');
124
124
  };
125
125
 
126
126
  exports.isVulnerable = function(results) {
package/lib/scanner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var retire = require('./retire'),
2
- _ = require('underscore'),
3
2
  fs = require('fs'),
4
3
  crypto = require('crypto'),
5
4
  path = require('path'),
5
+ _ = require('underscore'),
6
6
  log = require('./utils').log,
7
7
  emitter = new require('events').EventEmitter;
8
8
 
@@ -58,13 +58,17 @@ function printVulnerability(component, options) {
58
58
  return string;
59
59
  }
60
60
 
61
- function shouldIgnore(file, ignores) {
62
- return _.detect(ignores, function(i) { return file.indexOf(i) === 0 || file.indexOf(path.resolve(i)) === 0; });
61
+ function shouldIgnore(fileSpecs, ignores) {
62
+ return _.detect(ignores, function(i) {
63
+ return _.detect(fileSpecs, function(j) {
64
+ return j.indexOf(i) === 0 || j.indexOf(path.resolve(i)) === 0 ;
65
+ });
66
+ });
63
67
  }
64
68
 
65
69
 
66
70
  function scanJsFile(file, repo, options) {
67
- if (options.ignore && shouldIgnore(file, options.ignore)) {
71
+ if (options.ignore && shouldIgnore([file], options.ignore)) {
68
72
  return;
69
73
  }
70
74
  var results = retire.scanFileName(file, repo);
@@ -81,7 +85,7 @@ function printParent(comp, options) {
81
85
 
82
86
  function scanDependencies(dependencies, nodeRepo, options) {
83
87
  for (var i in dependencies) {
84
- if (options.ignore && shouldIgnore(dependencies[i].component, options.ignore)) {
88
+ if (options.ignore && shouldIgnore([dependencies[i].component, toModulePath(dependencies[i])], options.ignore)) {
85
89
  continue;
86
90
  }
87
91
  results = retire.scanNodeDependency(dependencies[i], nodeRepo);
@@ -98,9 +102,22 @@ function scanDependencies(dependencies, nodeRepo, options) {
98
102
  }
99
103
  }
100
104
 
105
+ function toModulePath(dep) {
106
+ function f(d) {
107
+ if (d.parent) return f(d.parent) + "/node_modules/" + d.component;
108
+ return "";
109
+ }
110
+ return path.resolve(f(dep).substring(1));
111
+ }
112
+
113
+
114
+
101
115
  function scanBowerFile(file, repo, options) {
116
+ if (options.ignore && shouldIgnore([file], options.ignore)) {
117
+ return;
118
+ }
102
119
  try {
103
- var bower = JSON.parse(fs.readFileSync(file));
120
+ var bower = JSON.parse(fs.readFileSync(file));
104
121
  if (bower.version) {
105
122
  var results = retire.check(bower.name, bower.version, repo);
106
123
  printResults(file, results, options);
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.1.2",
5
+ "version": "1.1.6",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/RetireJS/retire.js.git"
@@ -12,11 +12,11 @@
12
12
  },
13
13
  "main": "./lib/retire.js",
14
14
  "dependencies": {
15
- "underscore" : "1.7.x - 1.8.x",
16
- "commander" : "2.5.x",
17
- "read-installed" : "3.1.x",
18
- "walkdir" : "0.0.7",
19
- "request" : "~2.x.x"
15
+ "commander": "2.5.x",
16
+ "read-installed": "^4.0.3",
17
+ "request": "~2.x.x",
18
+ "underscore": "1.7.x - 1.8.x",
19
+ "walkdir": "0.0.7"
20
20
  },
21
21
  "devDependencies": {
22
22
  "nodeunit": "",