retire 5.2.1 → 5.2.3

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.3]
4
+
5
+ ### Bugfix
6
+
7
+ - Fix license handling for complex licenses
8
+
9
+ ## [5.2.2]
10
+
11
+ ### Bugfix
12
+
13
+ - Encode purls correctly in SBOM
14
+
3
15
  ## [5.2.1]
4
16
 
5
17
  ### Bugfix
package/lib/license.js CHANGED
@@ -15,10 +15,11 @@ function evaluateLicense(licenses, version) {
15
15
  .slice(splitIndex + 1)
16
16
  .trim()
17
17
  .split(';')
18
+ .map((x) => x.trim())
18
19
  .map((range) => {
19
20
  const [from, to] = range.split(' ').map((v) => v.trim());
20
21
  if (!from.startsWith('>='))
21
- throw new Error("Invalid license range: 'from' must start with '>=': " + range);
22
+ throw new Error("Invalid license range: 'from' must start with '>=': " + range + '[' + from + ']' + '[' + to + ']');
22
23
  if (to && !to.startsWith('<'))
23
24
  throw new Error("Invalid license range: 'to' must start with '<': " + range);
24
25
  if (to && to.startsWith('<='))
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.3';
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.3",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",