@cyclonedx/cyclonedx-library 6.7.2 → 6.8.0
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/README.md +1 -1
- package/dist.d/builders/fromNodePackageJson.node.d.ts +5 -4
- package/dist.d/builders/fromNodePackageJson.node.d.ts.map +1 -1
- package/dist.d/factories/fromNodePackageJson.node.d.ts +7 -6
- package/dist.d/factories/fromNodePackageJson.node.d.ts.map +1 -1
- package/dist.d/factories/license.d.ts +2 -2
- package/dist.d/factories/license.d.ts.map +1 -1
- package/dist.d/factories/packageUrl.d.ts +1 -1
- package/dist.d/factories/packageUrl.d.ts.map +1 -1
- package/dist.d/index.node.d.ts.map +1 -1
- package/dist.d/models/attachment.d.ts +1 -1
- package/dist.d/models/attachment.d.ts.map +1 -1
- package/dist.d/models/bom.d.ts +2 -2
- package/dist.d/models/bom.d.ts.map +1 -1
- package/dist.d/models/component.d.ts +1 -1
- package/dist.d/models/component.d.ts.map +1 -1
- package/dist.d/models/externalReference.d.ts +1 -1
- package/dist.d/models/externalReference.d.ts.map +1 -1
- package/dist.d/models/hash.d.ts +1 -1
- package/dist.d/models/hash.d.ts.map +1 -1
- package/dist.d/models/license.d.ts +1 -1
- package/dist.d/models/license.d.ts.map +1 -1
- package/dist.d/models/lifecycle.d.ts +1 -1
- package/dist.d/models/lifecycle.d.ts.map +1 -1
- package/dist.d/models/swid.d.ts +1 -1
- package/dist.d/models/swid.d.ts.map +1 -1
- package/dist.d/models/vulnerability/analysis.d.ts +1 -1
- package/dist.d/models/vulnerability/analysis.d.ts.map +1 -1
- package/dist.d/models/vulnerability/vulnerability.d.ts +1 -1
- package/dist.d/models/vulnerability/vulnerability.d.ts.map +1 -1
- package/dist.d/serialize/json/normalize.d.ts +1 -1
- package/dist.d/serialize/json/normalize.d.ts.map +1 -1
- package/dist.d/serialize/jsonSerializer.d.ts +1 -1
- package/dist.d/serialize/jsonSerializer.d.ts.map +1 -1
- package/dist.d/serialize/xml/normalize.d.ts +1 -1
- package/dist.d/serialize/xml/normalize.d.ts.map +1 -1
- package/dist.d/serialize/xmlBaseSerializer.d.ts.map +1 -1
- package/dist.d/spec/consts.d.ts.map +1 -1
- package/dist.d/spec/errors.d.ts +21 -0
- package/dist.d/spec/errors.d.ts.map +1 -0
- package/dist.d/spec/index.d.ts +1 -2
- package/dist.d/spec/index.d.ts.map +1 -1
- package/dist.node/builders/fromNodePackageJson.node.js +11 -8
- package/dist.node/builders/fromNodePackageJson.node.js.map +1 -1
- package/dist.node/factories/fromNodePackageJson.node.js +5 -5
- package/dist.node/factories/fromNodePackageJson.node.js.map +1 -1
- package/dist.node/factories/license.js +4 -4
- package/dist.node/factories/license.js.map +1 -1
- package/dist.node/factories/packageUrl.js +3 -3
- package/dist.node/factories/packageUrl.js.map +1 -1
- package/dist.node/index.node.js.map +1 -1
- package/dist.node/models/bom.js +3 -3
- package/dist.node/models/bom.js.map +1 -1
- package/dist.node/models/component.js +2 -2
- package/dist.node/models/component.js.map +1 -1
- package/dist.node/models/swid.js +2 -2
- package/dist.node/models/swid.js.map +1 -1
- package/dist.node/models/vulnerability/analysis.js +2 -2
- package/dist.node/models/vulnerability/analysis.js.map +1 -1
- package/dist.node/models/vulnerability/vulnerability.js +2 -2
- package/dist.node/models/vulnerability/vulnerability.js.map +1 -1
- package/dist.node/resources.node.js +28 -28
- package/dist.node/resources.node.js.map +1 -1
- package/dist.node/serialize/json/normalize.js +17 -15
- package/dist.node/serialize/json/normalize.js.map +1 -1
- package/dist.node/serialize/jsonSerializer.js +4 -3
- package/dist.node/serialize/jsonSerializer.js.map +1 -1
- package/dist.node/serialize/xml/normalize.js +19 -17
- package/dist.node/serialize/xml/normalize.js.map +1 -1
- package/dist.node/serialize/xmlBaseSerializer.js +4 -3
- package/dist.node/serialize/xmlBaseSerializer.js.map +1 -1
- package/dist.node/spec/consts.js +281 -278
- package/dist.node/spec/consts.js.map +1 -1
- package/dist.node/spec/errors.js +25 -0
- package/dist.node/spec/errors.js.map +1 -0
- package/dist.node/spec/index.js +1 -4
- package/dist.node/spec/index.js.map +1 -1
- package/dist.web/lib.dev.js +378 -338
- package/dist.web/lib.dev.js.map +1 -1
- package/dist.web/lib.js +1 -1
- package/dist.web/lib.js.map +1 -1
- package/package.json +72 -10
- package/src/builders/fromNodePackageJson.node.ts +12 -9
- package/src/factories/fromNodePackageJson.node.ts +13 -12
- package/src/factories/license.ts +2 -2
- package/src/factories/packageUrl.ts +2 -2
- package/src/index.node.ts +4 -0
- package/src/models/attachment.ts +1 -1
- package/src/models/bom.ts +3 -3
- package/src/models/component.ts +2 -2
- package/src/models/externalReference.ts +1 -1
- package/src/models/hash.ts +1 -1
- package/src/models/license.ts +1 -1
- package/src/models/lifecycle.ts +1 -1
- package/src/models/swid.ts +2 -2
- package/src/models/vulnerability/analysis.ts +1 -1
- package/src/models/vulnerability/vulnerability.ts +1 -1
- package/src/resources.node.ts +24 -24
- package/src/serialize/json/normalize.ts +13 -10
- package/src/serialize/jsonSerializer.ts +3 -2
- package/src/serialize/xml/normalize.ts +13 -10
- package/src/serialize/xmlBaseSerializer.ts +2 -1
- package/src/spec/consts.ts +23 -20
- package/src/spec/errors.ts +21 -0
- package/src/spec/index.ts +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclonedx/cyclonedx-library",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "Core functionality of CycloneDX for JavaScript (Node.js or WebBrowser).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -43,6 +43,12 @@
|
|
|
43
43
|
"name": "Jan Kowalleck",
|
|
44
44
|
"url": "https://github.com/jkowalleck"
|
|
45
45
|
},
|
|
46
|
+
"maintainers": [
|
|
47
|
+
{
|
|
48
|
+
"name": "Jan Kowalleck",
|
|
49
|
+
"url": "https://github.com/jkowalleck"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
46
52
|
"contributors": [
|
|
47
53
|
{
|
|
48
54
|
"name": "Jan Kowalleck",
|
|
@@ -55,6 +61,18 @@
|
|
|
55
61
|
{
|
|
56
62
|
"name": "Peter Wagner",
|
|
57
63
|
"url": "https://github.com/thepwagner"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "Xavier Maso",
|
|
67
|
+
"url": "https://github.com/xmasoracle"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "mLuca",
|
|
71
|
+
"url": "https://github.com/mLuca"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": " Augustus Kling ",
|
|
75
|
+
"url": "https://github.com/AugustusKling"
|
|
58
76
|
}
|
|
59
77
|
],
|
|
60
78
|
"type": "commonjs",
|
|
@@ -86,14 +104,15 @@
|
|
|
86
104
|
"eslint-plugin-editorconfig": "4.0.3",
|
|
87
105
|
"eslint-plugin-header": "3.1.1",
|
|
88
106
|
"eslint-plugin-import": "2.29.1",
|
|
89
|
-
"eslint-plugin-jsdoc": "48.2.
|
|
107
|
+
"eslint-plugin-jsdoc": "48.2.4",
|
|
90
108
|
"eslint-plugin-n": "16.6.2",
|
|
91
109
|
"eslint-plugin-promise": "6.1.1",
|
|
92
|
-
"eslint-plugin-simple-import-sort": "12.
|
|
110
|
+
"eslint-plugin-simple-import-sort": "12.1.0",
|
|
93
111
|
"eslint-plugin-tsdoc": "0.2.17",
|
|
94
112
|
"fast-glob": "^3.3.1",
|
|
95
113
|
"mocha": "10.4.0",
|
|
96
|
-
"npm-run-
|
|
114
|
+
"npm-run-all2": "^5.0.2",
|
|
115
|
+
"rimraf": "^5.0.7",
|
|
97
116
|
"ts-loader": "9.5.1",
|
|
98
117
|
"typedoc": "^0.25.0",
|
|
99
118
|
"typedoc-plugin-missing-exports": "^2.0.1",
|
|
@@ -106,9 +125,52 @@
|
|
|
106
125
|
"types": "./dist.d/index.node.d.ts",
|
|
107
126
|
"main": "./dist.node/index.node.js",
|
|
108
127
|
"exports": {
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
128
|
+
".": {
|
|
129
|
+
"types": "./dist.d/index.node.d.ts",
|
|
130
|
+
"browser": "./dist.web/lib.js",
|
|
131
|
+
"default": "./dist.node/index.node.js"
|
|
132
|
+
},
|
|
133
|
+
"./package.json": "./package.json",
|
|
134
|
+
"./Builders": {
|
|
135
|
+
"types": "./dist.d/builders/index.node.d.ts",
|
|
136
|
+
"default": "./dist.node/builders/index.node.js"
|
|
137
|
+
},
|
|
138
|
+
"./Enums": {
|
|
139
|
+
"types": "./dist.d/enums/index.d.ts",
|
|
140
|
+
"default": "./dist.node/enums/index.js"
|
|
141
|
+
},
|
|
142
|
+
"./Factories": {
|
|
143
|
+
"types": "./dist.d/factories/index.node.d.ts",
|
|
144
|
+
"default": "./dist.node/factories/index.node.js"
|
|
145
|
+
},
|
|
146
|
+
"./Models": {
|
|
147
|
+
"types": "./dist.d/models/index.d.ts",
|
|
148
|
+
"default": "./dist.node/models/index.js"
|
|
149
|
+
},
|
|
150
|
+
"./Serialize": {
|
|
151
|
+
"types": "./dist.d/serialize/index.node.d.ts",
|
|
152
|
+
"default": "./dist.node/serialize/index.node.js"
|
|
153
|
+
},
|
|
154
|
+
"./SPDX": {
|
|
155
|
+
"types": "./dist.d/spdx.d.ts",
|
|
156
|
+
"default": "./dist.node/spdx.js"
|
|
157
|
+
},
|
|
158
|
+
"./Spec": {
|
|
159
|
+
"types": "./dist.d/spec/index.d.ts",
|
|
160
|
+
"default": "./dist.node/spec/index.js"
|
|
161
|
+
},
|
|
162
|
+
"./Types": {
|
|
163
|
+
"types": "./dist.d/types/index.d.ts",
|
|
164
|
+
"default": "./dist.node/types/index.js"
|
|
165
|
+
},
|
|
166
|
+
"./Utils": {
|
|
167
|
+
"types": "./dist.d/utils/index.d.ts",
|
|
168
|
+
"default": "./dist.node/utils/index.js"
|
|
169
|
+
},
|
|
170
|
+
"./Validation": {
|
|
171
|
+
"types": "./dist.d/validation/index.node.d.ts",
|
|
172
|
+
"default": "./dist.node/validation/index.node.js"
|
|
173
|
+
}
|
|
112
174
|
},
|
|
113
175
|
"directories": {
|
|
114
176
|
"doc": "./docs",
|
|
@@ -122,11 +184,11 @@
|
|
|
122
184
|
"prepublishOnly": "run-s -lc build test",
|
|
123
185
|
"lint": "tsc --noEmit",
|
|
124
186
|
"build": "run-p --aggregate-output -l build:*",
|
|
125
|
-
"prebuild:node": "
|
|
187
|
+
"prebuild:node": "rimraf dist.node",
|
|
126
188
|
"build:node": "tsc -b ./tsconfig.node.json",
|
|
127
|
-
"prebuild:web": "
|
|
189
|
+
"prebuild:web": "rimraf dist.web",
|
|
128
190
|
"build:web": "webpack build",
|
|
129
|
-
"prebuild:d": "
|
|
191
|
+
"prebuild:d": "rimraf dist.d",
|
|
130
192
|
"build:d": "tsc -b ./tsconfig.d.json",
|
|
131
193
|
"cs-fix": "eslint --fix .",
|
|
132
194
|
"test": "run-p --aggregate-output -lc test:*",
|
|
@@ -28,9 +28,12 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
28
28
|
|
|
29
29
|
import type { PackageJson } from '../_helpers/packageJson'
|
|
30
30
|
import { splitNameGroup } from '../_helpers/packageJson'
|
|
31
|
-
import
|
|
31
|
+
import { ComponentType } from '../enums/componentType'
|
|
32
32
|
import type * as Factories from '../factories/index.node'
|
|
33
|
-
import
|
|
33
|
+
import { Component } from '../models/component'
|
|
34
|
+
import { ExternalReferenceRepository } from '../models/externalReference'
|
|
35
|
+
import { LicenseRepository } from '../models/license'
|
|
36
|
+
import { Tool } from '../models/tool'
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
39
|
* Node-specific ToolBuilder.
|
|
@@ -48,18 +51,18 @@ export class ToolBuilder {
|
|
|
48
51
|
|
|
49
52
|
// Current implementation does not return `undefined` yet, but it is an option for future implementation.
|
|
50
53
|
// To prevent future breaking changes, it is declared to return `undefined`.
|
|
51
|
-
makeTool (data: PackageJson):
|
|
54
|
+
makeTool (data: PackageJson): Tool | undefined {
|
|
52
55
|
const [name, vendor] = typeof data.name === 'string'
|
|
53
56
|
? splitNameGroup(data.name)
|
|
54
57
|
: []
|
|
55
58
|
|
|
56
|
-
return new
|
|
59
|
+
return new Tool({
|
|
57
60
|
vendor,
|
|
58
61
|
name,
|
|
59
62
|
version: (typeof data.version === 'string')
|
|
60
63
|
? data.version
|
|
61
64
|
: undefined,
|
|
62
|
-
externalReferences: new
|
|
65
|
+
externalReferences: new ExternalReferenceRepository(this.#extRefFactory.makeExternalReferences(data))
|
|
63
66
|
})
|
|
64
67
|
}
|
|
65
68
|
}
|
|
@@ -87,7 +90,7 @@ export class ComponentBuilder {
|
|
|
87
90
|
return this.#licenseFactory
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
makeComponent (data: PackageJson, type:
|
|
93
|
+
makeComponent (data: PackageJson, type: ComponentType = ComponentType.Library): Component | undefined {
|
|
91
94
|
if (typeof data.name !== 'string') {
|
|
92
95
|
return undefined
|
|
93
96
|
}
|
|
@@ -116,7 +119,7 @@ export class ComponentBuilder {
|
|
|
116
119
|
|
|
117
120
|
const externalReferences = this.#extRefFactory.makeExternalReferences(data)
|
|
118
121
|
|
|
119
|
-
const licenses = new
|
|
122
|
+
const licenses = new LicenseRepository()
|
|
120
123
|
if (typeof data.license === 'string') {
|
|
121
124
|
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#license */
|
|
122
125
|
licenses.add(this.#licenseFactory.makeFromString(data.license))
|
|
@@ -134,10 +137,10 @@ export class ComponentBuilder {
|
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
return new
|
|
140
|
+
return new Component(type, name, {
|
|
138
141
|
author,
|
|
139
142
|
description,
|
|
140
|
-
externalReferences: new
|
|
143
|
+
externalReferences: new ExternalReferenceRepository(externalReferences),
|
|
141
144
|
group,
|
|
142
145
|
licenses,
|
|
143
146
|
version
|
|
@@ -31,16 +31,17 @@ import type { PackageURL } from 'packageurl-js'
|
|
|
31
31
|
import { isNotUndefined } from '../_helpers/notUndefined'
|
|
32
32
|
import type { PackageJson } from '../_helpers/packageJson'
|
|
33
33
|
import { PackageUrlQualifierNames } from '../_helpers/packageUrl'
|
|
34
|
-
import
|
|
35
|
-
import
|
|
34
|
+
import { ExternalReferenceType } from '../enums/externalReferenceType'
|
|
35
|
+
import type { Component } from '../models/component'
|
|
36
|
+
import { ExternalReference } from '../models/externalReference'
|
|
36
37
|
import { PackageUrlFactory as PlainPackageUrlFactory } from './packageUrl'
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Node-specific ExternalReferenceFactory.
|
|
40
41
|
*/
|
|
41
42
|
export class ExternalReferenceFactory {
|
|
42
|
-
makeExternalReferences (data: PackageJson):
|
|
43
|
-
const refs: Array<
|
|
43
|
+
makeExternalReferences (data: PackageJson): ExternalReference[] {
|
|
44
|
+
const refs: Array<ExternalReference | undefined> = []
|
|
44
45
|
|
|
45
46
|
try { refs.push(this.makeVcs(data)) } catch { /* pass */ }
|
|
46
47
|
try { refs.push(this.makeHomepage(data)) } catch { /* pass */ }
|
|
@@ -49,7 +50,7 @@ export class ExternalReferenceFactory {
|
|
|
49
50
|
return refs.filter(isNotUndefined)
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
makeVcs (data: PackageJson):
|
|
53
|
+
makeVcs (data: PackageJson): ExternalReference | undefined {
|
|
53
54
|
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repositoryc */
|
|
54
55
|
const repository = data.repository
|
|
55
56
|
let url
|
|
@@ -67,21 +68,21 @@ export class ExternalReferenceFactory {
|
|
|
67
68
|
comment = 'as detected from PackageJson property "repository"'
|
|
68
69
|
}
|
|
69
70
|
return typeof url === 'string' && url.length > 0
|
|
70
|
-
? new
|
|
71
|
+
? new ExternalReference(url, ExternalReferenceType.VCS, { comment })
|
|
71
72
|
: undefined
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
makeHomepage (data: PackageJson):
|
|
75
|
+
makeHomepage (data: PackageJson): ExternalReference | undefined {
|
|
75
76
|
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#homepage */
|
|
76
77
|
const url = data.homepage
|
|
77
78
|
return typeof url === 'string' && url.length > 0
|
|
78
|
-
? new
|
|
79
|
-
url,
|
|
79
|
+
? new ExternalReference(
|
|
80
|
+
url, ExternalReferenceType.Website,
|
|
80
81
|
{ comment: 'as detected from PackageJson property "homepage"' })
|
|
81
82
|
: undefined
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
makeIssueTracker (data: PackageJson):
|
|
85
|
+
makeIssueTracker (data: PackageJson): ExternalReference | undefined {
|
|
85
86
|
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bugs */
|
|
86
87
|
const bugs = data.bugs
|
|
87
88
|
let url
|
|
@@ -94,7 +95,7 @@ export class ExternalReferenceFactory {
|
|
|
94
95
|
comment = 'as detected from PackageJson property "bugs"'
|
|
95
96
|
}
|
|
96
97
|
return typeof url === 'string' && url.length > 0
|
|
97
|
-
? new
|
|
98
|
+
? new ExternalReference(url, ExternalReferenceType.IssueTracker, { comment })
|
|
98
99
|
: undefined
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -105,7 +106,7 @@ const npmDefaultRegistryMatcher = /^https?:\/\/registry\.npmjs\.org/
|
|
|
105
106
|
* Node-specific PackageUrlFactory.
|
|
106
107
|
*/
|
|
107
108
|
export class PackageUrlFactory extends PlainPackageUrlFactory {
|
|
108
|
-
override makeFromComponent (component:
|
|
109
|
+
override makeFromComponent (component: Component, sort: boolean = false): PackageURL | undefined {
|
|
109
110
|
const purl = super.makeFromComponent(component, sort)
|
|
110
111
|
return purl === undefined
|
|
111
112
|
? undefined
|
package/src/factories/license.ts
CHANGED
|
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import type { DisjunctiveLicense, License } from '../models'
|
|
21
|
-
import { LicenseExpression, NamedLicense, SpdxLicense } from '../models'
|
|
20
|
+
import type { DisjunctiveLicense, License } from '../models/license'
|
|
21
|
+
import { LicenseExpression, NamedLicense, SpdxLicense } from '../models/license'
|
|
22
22
|
import { fixupSpdxId, isValidSpdxLicenseExpression } from '../spdx'
|
|
23
23
|
|
|
24
24
|
export class LicenseFactory {
|
|
@@ -20,8 +20,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
20
20
|
import { PackageURL } from 'packageurl-js'
|
|
21
21
|
|
|
22
22
|
import { PackageUrlQualifierNames } from '../_helpers/packageUrl'
|
|
23
|
-
import { ExternalReferenceType } from '../enums'
|
|
24
|
-
import type { Component } from '../models'
|
|
23
|
+
import { ExternalReferenceType } from '../enums/externalReferenceType'
|
|
24
|
+
import type { Component } from '../models/component'
|
|
25
25
|
|
|
26
26
|
export class PackageUrlFactory {
|
|
27
27
|
readonly #type: PackageURL['type']
|
package/src/index.node.ts
CHANGED
|
@@ -17,6 +17,10 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/* REMEMBER:
|
|
21
|
+
ALL non-internal exports in here have to be set as `exports` in `package.json`
|
|
22
|
+
*/
|
|
23
|
+
|
|
20
24
|
export * from './index.common'
|
|
21
25
|
|
|
22
26
|
// region node-specifics
|
package/src/models/attachment.ts
CHANGED
|
@@ -18,7 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Stringable } from '../_helpers/stringable'
|
|
21
|
-
import type { AttachmentEncoding } from '../enums'
|
|
21
|
+
import type { AttachmentEncoding } from '../enums/attachmentEncoding'
|
|
22
22
|
|
|
23
23
|
export interface OptionalAttachmentProperties {
|
|
24
24
|
contentType?: Attachment['contentType']
|
package/src/models/bom.ts
CHANGED
|
@@ -17,11 +17,11 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import type { PositiveInteger } from '../types'
|
|
21
|
-
import { isPositiveInteger } from '../types'
|
|
20
|
+
import type { PositiveInteger } from '../types/integer'
|
|
21
|
+
import { isPositiveInteger } from '../types/integer'
|
|
22
22
|
import { ComponentRepository } from './component'
|
|
23
23
|
import { Metadata } from './metadata'
|
|
24
|
-
import { VulnerabilityRepository } from './vulnerability'
|
|
24
|
+
import { VulnerabilityRepository } from './vulnerability/vulnerability'
|
|
25
25
|
|
|
26
26
|
export interface OptionalBomProperties {
|
|
27
27
|
metadata?: Bom['metadata']
|
package/src/models/component.ts
CHANGED
|
@@ -24,8 +24,8 @@ import { SortableComparables, SortableStringables } from '../_helpers/sortable'
|
|
|
24
24
|
import type { Stringable } from '../_helpers/stringable'
|
|
25
25
|
import { treeIteratorSymbol } from '../_helpers/tree'
|
|
26
26
|
import type { ComponentScope, ComponentType } from '../enums'
|
|
27
|
-
import type { CPE } from '../types'
|
|
28
|
-
import { isCPE } from '../types'
|
|
27
|
+
import type { CPE } from '../types/cpe'
|
|
28
|
+
import { isCPE } from '../types/cpe'
|
|
29
29
|
import { BomRef, BomRefRepository } from './bomRef'
|
|
30
30
|
import { ExternalReferenceRepository } from './externalReference'
|
|
31
31
|
import { HashDictionary } from './hash'
|
|
@@ -19,7 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import type { Comparable } from '../_helpers/sortable'
|
|
21
21
|
import { SortableComparables } from '../_helpers/sortable'
|
|
22
|
-
import type { ExternalReferenceType } from '../enums'
|
|
22
|
+
import type { ExternalReferenceType } from '../enums/externalReferenceType'
|
|
23
23
|
import type { BomLink } from './bomLink'
|
|
24
24
|
import { HashDictionary } from './hash'
|
|
25
25
|
|
package/src/models/hash.ts
CHANGED
|
@@ -18,7 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Sortable } from '../_helpers/sortable'
|
|
21
|
-
import type { HashAlgorithm } from '../enums'
|
|
21
|
+
import type { HashAlgorithm } from '../enums/hashAlogorithm'
|
|
22
22
|
|
|
23
23
|
// no regex for the HashContent in here. It applies at runtime of a normalization/serialization process.
|
|
24
24
|
export type HashContent = string
|
package/src/models/license.ts
CHANGED
|
@@ -18,7 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Sortable } from '../_helpers/sortable'
|
|
21
|
-
import type { LicenseAcknowledgement } from '../enums'
|
|
21
|
+
import type { LicenseAcknowledgement } from '../enums/licenseAcknowledgement'
|
|
22
22
|
import type { SpdxId } from '../spdx'
|
|
23
23
|
import type { Attachment } from './attachment'
|
|
24
24
|
|
package/src/models/lifecycle.ts
CHANGED
|
@@ -18,7 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Comparable, Sortable } from '../_helpers/sortable'
|
|
21
|
-
import type { LifecyclePhase } from '../enums'
|
|
21
|
+
import type { LifecyclePhase } from '../enums/lifecyclePhase'
|
|
22
22
|
|
|
23
23
|
export interface OptionalNamedLifecycleProperties {
|
|
24
24
|
description?: NamedLifecycle['description']
|
package/src/models/swid.ts
CHANGED
|
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import type { NonNegativeInteger } from '../types'
|
|
21
|
-
import { isNonNegativeInteger } from '../types'
|
|
20
|
+
import type { NonNegativeInteger } from '../types/integer'
|
|
21
|
+
import { isNonNegativeInteger } from '../types/integer'
|
|
22
22
|
import type { Attachment } from './attachment'
|
|
23
23
|
|
|
24
24
|
export interface OptionalSWIDProperties {
|
|
@@ -18,7 +18,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { AnalysisJustification, AnalysisState } from '../../enums/vulnerability'
|
|
21
|
-
import { AnalysisResponseRepository } from '../../enums/vulnerability'
|
|
21
|
+
import { AnalysisResponseRepository } from '../../enums/vulnerability/analysisResponse'
|
|
22
22
|
|
|
23
23
|
export interface OptionalAnalysisProperties {
|
|
24
24
|
state?: Analysis['state']
|
|
@@ -19,7 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import type { Comparable } from '../../_helpers/sortable'
|
|
21
21
|
import { SortableComparables } from '../../_helpers/sortable'
|
|
22
|
-
import { CweRepository } from '../../types'
|
|
22
|
+
import { CweRepository } from '../../types/cwe'
|
|
23
23
|
import { BomRef } from '../bomRef'
|
|
24
24
|
import { PropertyRepository } from '../property'
|
|
25
25
|
import { ToolRepository } from '../tool'
|
package/src/resources.node.ts
CHANGED
|
@@ -17,56 +17,56 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import
|
|
20
|
+
import { resolve } from 'path'
|
|
21
21
|
|
|
22
|
-
import { Version } from './spec'
|
|
22
|
+
import { Version } from './spec/enums'
|
|
23
23
|
|
|
24
24
|
/** @internal */
|
|
25
|
-
export const ROOT =
|
|
25
|
+
export const ROOT = resolve(__dirname, '..', 'res')
|
|
26
26
|
|
|
27
27
|
/** @internal */
|
|
28
|
-
export const SCHEMA_ROOT =
|
|
28
|
+
export const SCHEMA_ROOT = resolve(ROOT, 'schema')
|
|
29
29
|
|
|
30
30
|
/** @internal */
|
|
31
31
|
export const FILES = Object.freeze({
|
|
32
32
|
CDX: Object.freeze({
|
|
33
33
|
XML_SCHEMA: Object.freeze({
|
|
34
|
-
[Version.v1dot6]:
|
|
35
|
-
[Version.v1dot5]:
|
|
36
|
-
[Version.v1dot4]:
|
|
37
|
-
[Version.v1dot3]:
|
|
38
|
-
[Version.v1dot2]:
|
|
39
|
-
[Version.v1dot1]:
|
|
40
|
-
[Version.v1dot0]:
|
|
34
|
+
[Version.v1dot6]: resolve(SCHEMA_ROOT, 'bom-1.6.SNAPSHOT.xsd'),
|
|
35
|
+
[Version.v1dot5]: resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.xsd'),
|
|
36
|
+
[Version.v1dot4]: resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.xsd'),
|
|
37
|
+
[Version.v1dot3]: resolve(SCHEMA_ROOT, 'bom-1.3.SNAPSHOT.xsd'),
|
|
38
|
+
[Version.v1dot2]: resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.xsd'),
|
|
39
|
+
[Version.v1dot1]: resolve(SCHEMA_ROOT, 'bom-1.1.SNAPSHOT.xsd'),
|
|
40
|
+
[Version.v1dot0]: resolve(SCHEMA_ROOT, 'bom-1.0.SNAPSHOT.xsd')
|
|
41
41
|
|
|
42
42
|
}),
|
|
43
43
|
JSON_SCHEMA: Object.freeze({
|
|
44
|
-
[Version.v1dot6]:
|
|
45
|
-
[Version.v1dot5]:
|
|
46
|
-
[Version.v1dot4]:
|
|
47
|
-
[Version.v1dot3]:
|
|
48
|
-
[Version.v1dot2]:
|
|
44
|
+
[Version.v1dot6]: resolve(SCHEMA_ROOT, 'bom-1.6.SNAPSHOT.schema.json'),
|
|
45
|
+
[Version.v1dot5]: resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.schema.json'),
|
|
46
|
+
[Version.v1dot4]: resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json'),
|
|
47
|
+
[Version.v1dot3]: resolve(SCHEMA_ROOT, 'bom-1.3.SNAPSHOT.schema.json'),
|
|
48
|
+
[Version.v1dot2]: resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.schema.json'),
|
|
49
49
|
// <= v1.1 is not defined in JSON
|
|
50
50
|
[Version.v1dot1]: undefined,
|
|
51
51
|
[Version.v1dot0]: undefined
|
|
52
52
|
}),
|
|
53
53
|
JSON_STRICT_SCHEMA: Object.freeze({
|
|
54
|
-
[Version.v1dot6]:
|
|
55
|
-
[Version.v1dot5]:
|
|
56
|
-
[Version.v1dot4]:
|
|
54
|
+
[Version.v1dot6]: resolve(SCHEMA_ROOT, 'bom-1.6.SNAPSHOT.schema.json'),
|
|
55
|
+
[Version.v1dot5]: resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.schema.json'),
|
|
56
|
+
[Version.v1dot4]: resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json'),
|
|
57
57
|
// <= 1.3 need special files
|
|
58
|
-
[Version.v1dot3]:
|
|
59
|
-
[Version.v1dot2]:
|
|
58
|
+
[Version.v1dot3]: resolve(SCHEMA_ROOT, 'bom-1.3-strict.SNAPSHOT.schema.json'),
|
|
59
|
+
[Version.v1dot2]: resolve(SCHEMA_ROOT, 'bom-1.2-strict.SNAPSHOT.schema.json'),
|
|
60
60
|
// <= v1.1 is not defined in JSON
|
|
61
61
|
[Version.v1dot1]: undefined,
|
|
62
62
|
[Version.v1dot0]: undefined
|
|
63
63
|
})
|
|
64
64
|
}),
|
|
65
65
|
SPDX: Object.freeze({
|
|
66
|
-
XML_SCHEMA:
|
|
67
|
-
JSON_SCHEMA:
|
|
66
|
+
XML_SCHEMA: resolve(SCHEMA_ROOT, 'spdx.SNAPSHOT.xsd'),
|
|
67
|
+
JSON_SCHEMA: resolve(SCHEMA_ROOT, 'spdx.SNAPSHOT.schema.json')
|
|
68
68
|
}),
|
|
69
69
|
JSF: Object.freeze({
|
|
70
|
-
JSON_SCHEMA:
|
|
70
|
+
JSON_SCHEMA: resolve(SCHEMA_ROOT, 'jsf-0.82.SNAPSHOT.schema.json')
|
|
71
71
|
})
|
|
72
72
|
})
|
|
@@ -22,10 +22,13 @@ import type { SortableIterable } from '../../_helpers/sortable'
|
|
|
22
22
|
import type { Stringable } from '../../_helpers/stringable'
|
|
23
23
|
import { treeIteratorSymbol } from '../../_helpers/tree'
|
|
24
24
|
import { escapeUri } from '../../_helpers/uri'
|
|
25
|
-
import * as Models from '../../models'
|
|
25
|
+
import type * as Models from '../../models'
|
|
26
|
+
import { LicenseExpression, NamedLicense, SpdxLicense } from '../../models/license'
|
|
27
|
+
import { NamedLifecycle } from '../../models/lifecycle'
|
|
28
|
+
import { AffectedSingleVersion, AffectedVersionRange } from '../../models/vulnerability/affect'
|
|
26
29
|
import { isSupportedSpdxId } from '../../spdx'
|
|
27
|
-
import { Version as SpecVersion } from '../../spec'
|
|
28
30
|
import type { _SpecProtocol as Spec } from '../../spec/_protocol'
|
|
31
|
+
import { Version as SpecVersion } from '../../spec/enums'
|
|
29
32
|
import type { NormalizerOptions } from '../types'
|
|
30
33
|
import type { Normalized } from './types'
|
|
31
34
|
import { JsonSchema } from './types'
|
|
@@ -237,7 +240,7 @@ export class MetadataNormalizer extends BaseJsonNormalizer<Models.Metadata> {
|
|
|
237
240
|
|
|
238
241
|
export class LifecycleNormalizer extends BaseJsonNormalizer<Models.Lifecycle> {
|
|
239
242
|
normalize (data: Models.Lifecycle, options: NormalizerOptions): Normalized.Lifecycle {
|
|
240
|
-
return data instanceof
|
|
243
|
+
return data instanceof NamedLifecycle
|
|
241
244
|
? { name: data.name, description: data.description }
|
|
242
245
|
: { phase: data }
|
|
243
246
|
}
|
|
@@ -427,17 +430,17 @@ export class ComponentEvidenceNormalizer extends BaseJsonNormalizer<Models.Compo
|
|
|
427
430
|
export class LicenseNormalizer extends BaseJsonNormalizer<Models.License> {
|
|
428
431
|
normalize (data: Models.License, options: NormalizerOptions): Normalized.License {
|
|
429
432
|
switch (true) {
|
|
430
|
-
case data instanceof
|
|
433
|
+
case data instanceof NamedLicense:
|
|
431
434
|
return this.#normalizeNamedLicense(data, options)
|
|
432
|
-
case data instanceof
|
|
435
|
+
case data instanceof SpdxLicense:
|
|
433
436
|
return isSupportedSpdxId(data.id)
|
|
434
437
|
? this.#normalizeSpdxLicense(data, options)
|
|
435
|
-
: this.#normalizeNamedLicense(new
|
|
438
|
+
: this.#normalizeNamedLicense(new NamedLicense(
|
|
436
439
|
// prevent information loss -> convert to broader type
|
|
437
440
|
data.id,
|
|
438
441
|
{ url: data.url }
|
|
439
442
|
), options)
|
|
440
|
-
case data instanceof
|
|
443
|
+
case data instanceof LicenseExpression:
|
|
441
444
|
return this.#normalizeLicenseExpression(data)
|
|
442
445
|
/* c8 ignore start */
|
|
443
446
|
default:
|
|
@@ -501,7 +504,7 @@ export class LicenseNormalizer extends BaseJsonNormalizer<Models.License> {
|
|
|
501
504
|
: Array.from(data)
|
|
502
505
|
|
|
503
506
|
if (licenses.length > 1) {
|
|
504
|
-
const expressions = licenses.filter(l => l instanceof
|
|
507
|
+
const expressions = licenses.filter(l => l instanceof LicenseExpression) as Models.LicenseExpression[]
|
|
505
508
|
if (expressions.length > 0) {
|
|
506
509
|
// could have thrown {@link RangeError} when there is more than one only {@link Models.LicenseExpression | LicenseExpression}.
|
|
507
510
|
// but let's be graceful and just normalize to the most relevant choice: any expression
|
|
@@ -805,9 +808,9 @@ export class VulnerabilityAffectNormalizer extends BaseJsonNormalizer<Models.Vul
|
|
|
805
808
|
export class VulnerabilityAffectedVersionNormalizer extends BaseJsonNormalizer<Models.Vulnerability.AffectedVersion> {
|
|
806
809
|
normalize (data: Models.Vulnerability.AffectedVersion, options: NormalizerOptions): Normalized.Vulnerability.AffectedVersion | undefined {
|
|
807
810
|
switch (true) {
|
|
808
|
-
case data instanceof
|
|
811
|
+
case data instanceof AffectedSingleVersion:
|
|
809
812
|
return this.#normalizeAffectedSingleVersion(data)
|
|
810
|
-
case data instanceof
|
|
813
|
+
case data instanceof AffectedVersionRange:
|
|
811
814
|
return this.#normalizeAffectedVersionRange(data)
|
|
812
815
|
/* c8 ignore start */
|
|
813
816
|
default:
|
|
@@ -17,8 +17,9 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import type { Bom } from '../models'
|
|
21
|
-
import { Format
|
|
20
|
+
import type { Bom } from '../models/bom'
|
|
21
|
+
import { Format } from '../spec/enums'
|
|
22
|
+
import { UnsupportedFormatError } from '../spec/errors'
|
|
22
23
|
import { BaseSerializer } from './baseSerializer'
|
|
23
24
|
import type { Factory as NormalizerFactory } from './json/normalize'
|
|
24
25
|
import type { Normalized } from './json/types'
|