retire 3.2.1 → 3.2.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,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [3.2.0]
3
+ ## [3.2.2]
4
+
5
+ - Fix bug in CycloneDX JSON output (wrapped components array)
6
+
7
+ ## [3.2.1]
4
8
 
5
9
  - Remove unintended use of arrow functions
6
10
 
@@ -26,8 +26,17 @@ function configureCycloneDXJSONLogger(logger, writer, config, hash) {
26
26
  var seen = {};
27
27
  var components = finalResults.data.filter(d => d.results).map(r => r.results.map(dep => {
28
28
  dep.version = (dep.version.split(".").length >= 3 ? dep.version : dep.version + ".0").replace(/-/g, ".");
29
+ var hashes;
29
30
  var filepath = r.file || dep.file;
30
- var file = fs.readFileSync(filepath);
31
+ if (filepath) {
32
+ var file = fs.readFileSync(filepath);
33
+ hashes = [
34
+ { "alg" : "MD5", "content" : hash.md5(file) },
35
+ { "alg" : "SHA-1", "content" : hash.sha1(file) },
36
+ { "alg" : "SHA-256", "content" : hash.sha256(file) },
37
+ { "alg" : "SHA-512", "content" : hash.sha512(file) },
38
+ ];
39
+ }
31
40
  var purl = `pkg:npm/${dep.component}@${dep.version}`;
32
41
  if (seen[purl]) return '';
33
42
  seen[purl] = true;
@@ -36,14 +45,9 @@ function configureCycloneDXJSONLogger(logger, writer, config, hash) {
36
45
  name: dep.component,
37
46
  version: dep.version,
38
47
  purl: purl,
39
- hashes: [
40
- { "alg" : "MD5", "content" : hash.md5(file) },
41
- { "alg" : "SHA-1", "content" : hash.sha1(file) },
42
- { "alg" : "SHA-256", "content" : hash.sha256(file) },
43
- { "alg" : "SHA-512", "content" : hash.sha512(file) },
44
- ]
48
+ hashes: hashes
45
49
  };
46
- }));
50
+ })).reduce((a,b) => a.concat(b));
47
51
  write(JSON.stringify({
48
52
  bomFormat : "CycloneDX",
49
53
  specVersion : "1.4",
@@ -27,21 +27,25 @@ function configureCycloneDXLogger(logger, writer, config, hash) {
27
27
  var components = finalResults.data.filter(d => d.results).map(r => r.results.map(dep => {
28
28
  dep.version = (dep.version.split(".").length >= 3 ? dep.version : dep.version + ".0").replace(/-/g, ".");
29
29
  var filepath = r.file || dep.file;
30
- var filename = filepath.split("/").slice(-1);
31
- var file = fs.readFileSync(filepath);
30
+ if (filepath) {
31
+ var filename = filepath.split("/").slice(-1);
32
+ var file = fs.readFileSync(filepath);
33
+ hashes = `
34
+ <hashes>
35
+ <hash alg="MD5">${hash.md5(file)}</hash>
36
+ <hash alg="SHA-1">${hash.sha1(file)}</hash>
37
+ <hash alg="SHA-256">${hash.sha256(file)}</hash>
38
+ <hash alg="SHA-512">${hash.sha512(file)}</hash>
39
+ </hashes>`;
40
+ }
32
41
  var purl = `pkg:npm/${dep.component}@${dep.version}`;
42
+ var hashes = "";
33
43
  if (seen[purl]) return '';
34
44
  seen[purl] = true;
35
45
  return `
36
46
  <component type="library">
37
47
  <name>${dep.component}</name>
38
- <version>${dep.version}</version>
39
- <hashes>
40
- <hash alg="MD5">${hash.md5(file)}</hash>
41
- <hash alg="SHA-1">${hash.sha1(file)}</hash>
42
- <hash alg="SHA-256">${hash.sha256(file)}</hash>
43
- <hash alg="SHA-512">${hash.sha512(file)}</hash>
44
- </hashes>
48
+ <version>${dep.version}</version>${hashes}
45
49
  <purl>${purl}</purl>
46
50
  <modified>false</modified>
47
51
  </component>`;
package/lib/retire.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  var exports = exports || {};
7
- exports.version = '3.2.1';
7
+ exports.version = '3.2.2';
8
8
 
9
9
  function isDefined(o) {
10
10
  return typeof o !== 'undefined';
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": "3.2.1",
5
+ "version": "3.2.2",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",