retire 5.2.1 → 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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.2]
4
+
5
+ ### Bugfix
6
+
7
+ - Encode purls correctly in SBOM
8
+
3
9
  ## [5.2.1]
4
10
 
5
11
  ### Bugfix
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.1';
7
+ exports.version = '5.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": "5.2.1",
5
+ "version": "5.2.2",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",