retire 5.2.0 → 5.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,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.2]
4
+
5
+ ### Bugfix
6
+
7
+ - Encode purls correctly in SBOM
8
+
9
+ ## [5.2.1]
10
+
11
+ ### Bugfix
12
+
13
+ - Add missing CWEs in response
14
+
3
15
  ## [5.2.0]
4
16
 
5
17
  ### Enhancement
package/lib/repo.js CHANGED
@@ -132,7 +132,7 @@ function validateRepository(repo, replacer) {
132
132
  bowername: z.array(z.string().regex(/^[a-z0-9.-]+$/i)).optional(),
133
133
  basePurl: z
134
134
  .string()
135
- .regex(/^pkg:[a-z0-9/]+$/i)
135
+ .regex(/^pkg:[a-z0-9%.-/]+$/i)
136
136
  .optional(),
137
137
  npmname: z
138
138
  .string()
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generatePURL = generatePURL;
4
+ function encodePURLchars(str) {
5
+ return str.replace(/[^A-Za-z0-9.+/=%-]/g, (match) => '%' + ('0' + match.charCodeAt(0).toString(16).toUpperCase()).slice(-2));
6
+ }
4
7
  function generatePURL(component) {
5
8
  if (component.basePurl) {
6
- return component.basePurl + '@' + component.version;
9
+ const [pType, ...rest] = component.basePurl.split(':');
10
+ const pathElements = rest.join(':').split('/').map(encodePURLchars).join('/');
11
+ return `${pType}:${pathElements}@${encodePURLchars(component.version)}`;
7
12
  }
8
13
  const compName = component.npmname || component.component;
9
- return `pkg:npm/${compName}@${component.version}`;
14
+ return `pkg:npm/${encodePURLchars(compName)}@${encodePURLchars(component.version)}`;
10
15
  }
package/lib/retire.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  var exports = exports || {};
7
- exports.version = '5.2.0';
7
+ exports.version = '5.2.2';
8
8
 
9
9
  function isDefined(o) {
10
10
  return typeof o !== 'undefined';
@@ -110,6 +110,9 @@ function check(results, repo) {
110
110
  if (vulns[i].identifiers) {
111
111
  vulnerability.identifiers = vulns[i].identifiers;
112
112
  }
113
+ if (vulns[i].cwe) {
114
+ vulnerability.cwe = vulns[i].cwe;
115
+ }
113
116
  result.vulnerabilities = result.vulnerabilities || [];
114
117
  result.vulnerabilities.push(vulnerability);
115
118
  }
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": "5.2.0",
5
+ "version": "5.2.2",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -22,6 +22,8 @@
22
22
  "zod": "^3.22.4"
23
23
  },
24
24
  "devDependencies": {
25
+ "@types/chai": "^4.3.17",
26
+ "@types/mocha": "^10.0.7",
25
27
  "@types/node": "^18.13.0",
26
28
  "@types/uuid": "^9.0.0",
27
29
  "@typescript-eslint/eslint-plugin": "^7.1.1",