retire 4.4.1 → 4.4.2

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.2]
4
+
5
+ ### Fix
6
+
7
+ - Fix matching to include all matches
8
+
9
+
3
10
  ## [4.4.1]
4
11
 
5
12
  ### Chore
package/lib/retire.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  var exports = exports || {};
7
- exports.version = '4.4.1';
7
+ exports.version = '4.4.2';
8
8
 
9
9
  function isDefined(o) {
10
10
  return typeof o !== 'undefined';
@@ -19,15 +19,14 @@ function uniq(results) {
19
19
  });
20
20
  }
21
21
 
22
- function scan(data, extractor, repo, matcher) {
23
- matcher = matcher || simpleMatch;
22
+ function scan(data, extractor, repo, matcher = simpleMatch) {
24
23
  var detected = [];
25
24
  for (var component in repo) {
26
25
  var extractors = repo[component].extractors[extractor];
27
26
  if (!isDefined(extractors)) continue;
28
27
  for (var i in extractors) {
29
- var match = matcher(extractors[i], data);
30
- if (match) {
28
+ var matches = matcher(extractors[i], data);
29
+ matches.forEach(match => {
31
30
  match = match.replace(/(\.|-)min$/, '');
32
31
  detected.push({
33
32
  version: match,
@@ -36,27 +35,34 @@ function scan(data, extractor, repo, matcher) {
36
35
  basePurl: repo[component].basePurl,
37
36
  detection: extractor,
38
37
  });
39
- }
38
+ });
40
39
  }
41
40
  }
42
41
  return uniq(detected);
43
42
  }
44
43
 
45
44
  function simpleMatch(regex, data) {
46
- var re = new RegExp(regex);
47
- var match = re.exec(data);
48
- return match ? match[1] : null;
45
+ var re = new RegExp(regex, "g");
46
+ const result = [];
47
+ let match;
48
+ while (match = re.exec(data)) {
49
+ result.push(match[1]);
50
+ }
51
+ return result;
49
52
  }
50
53
  function replacementMatch(regex, data) {
51
54
  var ar = /^\/(.*[^\\])\/([^\/]+)\/$/.exec(regex);
52
- var re = new RegExp(ar[1]);
53
- var match = re.exec(data);
54
- var ver = null;
55
- if (match) {
56
- ver = match[0].replace(new RegExp(ar[1]), ar[2]);
57
- return ver;
55
+ var re = new RegExp(ar[1], "g");
56
+ const result = [];
57
+ let match;
58
+ while(match = re.exec(data)) {
59
+ var ver = null;
60
+ if (match) {
61
+ ver = match[0].replace(new RegExp(ar[1]), ar[2]);
62
+ result.push(ver);
63
+ }
58
64
  }
59
- return null;
65
+ return result;
60
66
  }
61
67
 
62
68
  function splitAndMatchAll(tokenizer) {
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.4.1",
5
+ "version": "4.4.2",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",