Skip to content

Commit fd8df0d

Browse files
committed
Add support for cycloneDX 1.7
1 parent ff9f087 commit fd8df0d

18 files changed

Lines changed: 8841 additions & 322 deletions

CLAUDE.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,43 @@ This is a monorepo with two main parts:
1515
cd node
1616
npm install
1717
npm run build # compile TypeScript → lib/
18-
npm run test # run jest test suite (node/spec/tests/*.spec.ts)
18+
npm run test # run the test suite (node/spec/tests/*.spec.ts)
1919
npm run check # lint + typecheck
2020
npm run lint # eslint --fix
2121
npm run typecheck # tsc --noEmit
2222
```
2323

24+
### Testing
25+
26+
Tests use the built-in [`node:test`](https://nodejs.org/api/test.html) runner (`describe`/`it` with
27+
`node:assert`), not jest.
28+
29+
**The specs import from `../../lib/`, not `../../src/`, so `npm run build` must be run before
30+
`npm run test`** — otherwise you are testing the previously compiled output and your changes will
31+
appear to have no effect:
32+
33+
```bash
34+
cd node
35+
npm run build && npm run test
36+
```
37+
2438
Run a single test file:
2539
```bash
2640
cd node
27-
npx jest spec/tests/contentscan.spec.ts
41+
TS_NODE_PROJECT=tsconfig.spec.json node --require ts-node/register --test spec/tests/contentscan.spec.ts
42+
```
43+
44+
Run a single test by name (matched as a regex against the `it(...)` description):
45+
```bash
46+
cd node
47+
TS_NODE_PROJECT=tsconfig.spec.json node --require ts-node/register --test \
48+
--test-name-pattern 'should validate report according to schema' spec/tests/cyclonedx.spec.ts
2849
```
2950

51+
Reporters that emit CycloneDX are validated against the JSON schemas bundled in
52+
`node/spec/schema/`. When adding support for a new spec version, add its `bom-<version>.schema.json`
53+
there too.
54+
3055
## Vulnerability repository (repository/)
3156

3257
The source of truth is `jsrepository-master.json`. The other `jsrepository*.json` files are derived outputs and must be kept in sync.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ retire.js can generate SBOMs in the CycloneDX-format:
3131
$ retire --outputformat cyclonedx
3232
```
3333

34+
`cyclonedx` produces CycloneDX 1.4 XML. For JSON, and for newer spec versions, use `cyclonedxJSON` (1.4), `cyclonedxJSON1_6` or
35+
`cyclonedxJSON1_7`. The `cyclonedxJSON1_6_VEX` and `cyclonedxJSON1_7_VEX` variants also include a `vulnerabilities` section.
36+
3437
By default retire.js will exit with code 13 if it finds vulnerabilities. This can be overridden with `--exitwith 0`.
3538

3639

chrome/extension-no-func/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "retire.js-no-func",
44
"description": "Scanning website for vulnerable js libraries. Icon by studiomx",
5-
"version": "5.6.0",
5+
"version": "5.7.0",
66
"icons": {
77
"16": "icons/icon16.png",
88
"48": "icons/icon48.png",

chrome/extension/js/generated/retire-chrome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10871,7 +10871,7 @@ var retirechrome = (() => {
1087110871
"../../node/lib/retire.js"(exports) {
1087210872
"use strict";
1087310873
var exports = exports || {};
10874-
exports.version = "5.6.0";
10874+
exports.version = "5.7.0";
1087510875
function isDefined(o) {
1087610876
return typeof o !== "undefined";
1087710877
}

chrome/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "retire.js",
44
"description": "Scanning website for vulnerable js libraries. Icon by studiomx",
5-
"version": "5.6.0",
5+
"version": "5.7.0",
66
"icons": {
77
"16": "icons/icon16.png",
88
"48": "icons/icon48.png",

node/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## [5.7.0]
4+
5+
### Improvements
6+
7+
- Added CycloneDX 1.7 output: `--outputformat cyclonedxJSON1_7` and `cyclonedxJSON1_7_VEX`.
8+
- CycloneDX 1.7 reports every resolved license, each as its own SPDX expression. Earlier spec versions only allow a single expression per component, so 1.4/1.6 output still reports the first license only.
9+
- The CycloneDX 1.6 and 1.7 reports now include:
10+
- `$schema`, pointing at the schema for the emitted spec version.
11+
- `metadata.tools` in the object form introduced in 1.5, replacing the deprecated legacy array.
12+
- `metadata.component`, describing the scanned path as the subject of the BOM.
13+
- `dependencies`, linking the scan target to every detected component.
14+
- `evidence.identity`, reporting how the version was detected (`filecontent`, `filename`, `hash`, `ast`, ...) as a CycloneDX identity technique and confidence.
15+
- `vulnerabilities[].detail`, when the repository supplies `details` (VEX variants only).
16+
17+
### Bugfixes
18+
19+
- CycloneDX 1.6 output threw when a vulnerability in a custom `--jsrepo` had no `cwe`, and could throw on a vulnerability with no `identifiers`.
20+
321
## [5.6.0]
422

523
### Improvements

node/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Options:
1818
--jsrepo <path|url> Local or internal version of repo. Can be multiple comma separated. Default: 'central')
1919
--cachedir <path> Path to use for local cache instead of /tmp/.retire-cache
2020
--proxy <url> Proxy url (http://some.host:8080)
21-
--outputformat <format> Valid formats: text, json, jsonsimple, depcheck (experimental), cyclonedx and cyclonedxJSON
21+
--outputformat <format> Valid formats: text, json, jsonsimple, depcheck (experimental), cyclonedx, cyclonedxJSON, cyclonedxJSON1_6,
22+
cyclonedxJSON1_6_VEX, cyclonedxJSON1_7 and cyclonedxJSON1_7_VEX
2223
--outputpath <path> File to which output should be written
2324
--ignore <paths> Comma delimited list of paths to ignore
2425
--ignorefile <path> Custom ignore file, defaults to .retireignore / .retireignore.json
@@ -35,7 +36,9 @@ Options:
3536
```
3637

3738
The `depcheck` output format mimics the output of OWASP Dependency Check, but lacks some information compared to OWASP Dependency Check, because that information is not in the repo.
38-
The `cyclonedx` output format is based on based on the https://github.com/CycloneDX spec.
39+
The `cyclonedx` output format is based on the https://github.com/CycloneDX spec. `cyclonedx` and `cyclonedxJSON` emit CycloneDX 1.4
40+
(XML and JSON respectively). `cyclonedxJSON1_6` and `cyclonedxJSON1_7` emit JSON for the corresponding spec versions, and the
41+
`_VEX` variants of those additionally include a `vulnerabilities` section.
3942

4043
## .retireignore
4144

node/lib/retire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
var exports = exports || {};
7-
exports.version = '5.6.0';
7+
exports.version = '5.7.0';
88

99
function isDefined(o) {
1010
return typeof o !== 'undefined';

node/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Erlend Oftedal <erlend@oftedal.no>",
33
"name": "retire",
44
"description": "Retire is a tool for detecting use of vulnerable libraries",
5-
"version": "5.6.0",
5+
"version": "5.7.0",
66
"license": "Apache-2.0",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)