@cyclonedx/cyclonedx-library 2.1.0 → 3.0.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 +3 -2
- package/dist.d/enums/componentType.d.ts +5 -1
- package/dist.d/enums/componentType.d.ts.map +1 -1
- package/dist.d/enums/externalReferenceType.d.ts +23 -0
- package/dist.d/enums/externalReferenceType.d.ts.map +1 -1
- package/dist.d/enums/vulnerability/ratingMethod.d.ts +9 -4
- package/dist.d/enums/vulnerability/ratingMethod.d.ts.map +1 -1
- package/dist.d/models/bomLink.d.ts +66 -0
- package/dist.d/models/bomLink.d.ts.map +1 -0
- package/dist.d/models/bomRef.d.ts +4 -2
- package/dist.d/models/bomRef.d.ts.map +1 -1
- package/dist.d/models/externalReference.d.ts +2 -1
- package/dist.d/models/externalReference.d.ts.map +1 -1
- package/dist.d/models/index.d.ts +1 -0
- package/dist.d/models/index.d.ts.map +1 -1
- package/dist.d/models/vulnerability/affect.d.ts +3 -2
- package/dist.d/models/vulnerability/affect.d.ts.map +1 -1
- package/dist.d/serialize/json/normalize.d.ts.map +1 -1
- package/dist.d/serialize/json/types.d.ts +9 -5
- package/dist.d/serialize/json/types.d.ts.map +1 -1
- package/dist.d/serialize/xml/normalize.d.ts.map +1 -1
- package/dist.d/spec.d.ts +9 -5
- package/dist.d/spec.d.ts.map +1 -1
- package/dist.d/types/integer.d.ts +2 -2
- package/dist.node/enums/componentType.js +4 -0
- package/dist.node/enums/componentType.js.map +1 -1
- package/dist.node/enums/externalReferenceType.js +23 -0
- package/dist.node/enums/externalReferenceType.js.map +1 -1
- package/dist.node/enums/vulnerability/ratingMethod.js +2 -0
- package/dist.node/enums/vulnerability/ratingMethod.js.map +1 -1
- package/dist.node/models/bomLink.js +80 -0
- package/dist.node/models/bomLink.js.map +1 -0
- package/dist.node/models/bomRef.js.map +1 -1
- package/dist.node/models/externalReference.js.map +1 -1
- package/dist.node/models/index.js +1 -0
- package/dist.node/models/index.js.map +1 -1
- package/dist.node/models/vulnerability/affect.js.map +1 -1
- package/dist.node/resources.node.js +15 -12
- package/dist.node/resources.node.js.map +1 -1
- package/dist.node/serialize/json/normalize.js +6 -3
- package/dist.node/serialize/json/normalize.js.map +1 -1
- package/dist.node/serialize/xml/normalize.js +8 -3
- package/dist.node/serialize/xml/normalize.js.map +1 -1
- package/dist.node/spec.js +104 -13
- package/dist.node/spec.js.map +1 -1
- package/dist.web/lib.dev.js +238 -20
- 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 +4 -4
- package/res/schema/README.md +14 -11
- package/res/schema/bom-1.1.SNAPSHOT.xsd +8 -1
- package/res/schema/bom-1.2-strict.SNAPSHOT.schema.json +8 -5
- package/res/schema/bom-1.2.SNAPSHOT.schema.json +8 -4
- package/res/schema/bom-1.2.SNAPSHOT.xsd +10 -3
- package/res/schema/bom-1.3-strict.SNAPSHOT.schema.json +8 -4
- package/res/schema/bom-1.3.SNAPSHOT.schema.json +8 -4
- package/res/schema/bom-1.3.SNAPSHOT.xsd +14 -5
- package/res/schema/bom-1.4.SNAPSHOT.schema.json +2 -2
- package/res/schema/bom-1.4.SNAPSHOT.xsd +4 -2
- package/res/schema/bom-1.5.SNAPSHOT.schema.json +3799 -0
- package/res/schema/bom-1.5.SNAPSHOT.xsd +5464 -0
- package/res/schema/jsf-0.82.SNAPSHOT.schema.json +0 -4
- package/res/schema/spdx.SNAPSHOT.schema.json +569 -486
- package/res/schema/spdx.SNAPSHOT.xsd +1468 -1053
- package/src/enums/componentType.ts +4 -0
- package/src/enums/externalReferenceType.ts +23 -0
- package/src/enums/vulnerability/ratingMethod.ts +9 -4
- package/src/models/bomLink.ts +111 -0
- package/src/models/bomRef.ts +5 -2
- package/src/models/externalReference.ts +2 -1
- package/src/models/index.ts +1 -0
- package/src/models/vulnerability/affect.ts +3 -2
- package/src/resources.node.ts +20 -17
- package/src/serialize/json/normalize.ts +6 -3
- package/src/serialize/json/types.ts +10 -5
- package/src/serialize/xml/normalize.ts +8 -3
- package/src/spec.ts +121 -7
- package/src/types/integer.ts +2 -2
|
@@ -22,8 +22,12 @@ export enum ComponentType {
|
|
|
22
22
|
Framework = 'framework',
|
|
23
23
|
Library = 'library',
|
|
24
24
|
Container = 'container',
|
|
25
|
+
Platform = 'platform',
|
|
25
26
|
OperatingSystem = 'operating-system',
|
|
26
27
|
Device = 'device',
|
|
28
|
+
DeviceDriver = 'device-driver',
|
|
27
29
|
Firmware = 'firmware',
|
|
28
30
|
File = 'file',
|
|
31
|
+
MachineLearningModel = 'machine-learning-model',
|
|
32
|
+
Data = 'data',
|
|
29
33
|
}
|
|
@@ -29,9 +29,32 @@ export enum ExternalReferenceType {
|
|
|
29
29
|
Documentation = 'documentation',
|
|
30
30
|
Support = 'support',
|
|
31
31
|
Distribution = 'distribution',
|
|
32
|
+
DistributionIntake = 'distribution-intake',
|
|
32
33
|
License = 'license',
|
|
33
34
|
BuildMeta = 'build-meta',
|
|
34
35
|
BuildSystem = 'build-system',
|
|
35
36
|
ReleaseNotes = 'release-notes',
|
|
37
|
+
SecurityContact = 'security-contact',
|
|
38
|
+
ModelCard = 'model-card',
|
|
39
|
+
Log = 'log',
|
|
40
|
+
Configuration = 'configuration',
|
|
41
|
+
Evidence = 'evidence',
|
|
42
|
+
Formulation = 'formulation',
|
|
43
|
+
Attestation = 'attestation',
|
|
44
|
+
ThreatModel = 'threat-model',
|
|
45
|
+
AdversaryModel = 'adversary-model',
|
|
46
|
+
RiskAssessment = 'risk-assessment',
|
|
47
|
+
VulnerabilityAssertion = 'vulnerability-assertion',
|
|
48
|
+
ExploitabilityStatement = 'exploitability-statement',
|
|
49
|
+
PentestReport = 'pentest-report',
|
|
50
|
+
StaticAnalysisReport = 'static-analysis-report',
|
|
51
|
+
DynamicAnalysisReport = 'dynamic-analysis-report',
|
|
52
|
+
RuntimeAnalysisReport = 'runtime-analysis-report',
|
|
53
|
+
ComponentAnalysisReport = 'component-analysis-report',
|
|
54
|
+
MaturityReport = 'maturity-report',
|
|
55
|
+
CertificationReport = 'certification-report',
|
|
56
|
+
CodifiedInfrastructure = 'codified-infrastructure',
|
|
57
|
+
QualityMetrics = 'quality-metrics',
|
|
58
|
+
POAM = 'poam',
|
|
36
59
|
Other = 'other',
|
|
37
60
|
}
|
|
@@ -21,13 +21,18 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
21
21
|
* Specifies the severity or risk scoring methodology or standard used.
|
|
22
22
|
*/
|
|
23
23
|
export enum RatingMethod {
|
|
24
|
-
/** [
|
|
24
|
+
/** CVSSv2 - [Common Vulnerability Scoring System v2](https://www.first.org/cvss/v2/) */
|
|
25
25
|
CVSSv2 = 'CVSSv2',
|
|
26
|
-
/** [
|
|
26
|
+
/** CVSSv3 - [Common Vulnerability Scoring System v3](https://www.first.org/cvss/v3-0/) */
|
|
27
27
|
CVSSv3 = 'CVSSv3',
|
|
28
|
-
/** [
|
|
28
|
+
/** CVSSv31 - [Common Vulnerability Scoring System v3.1](https://www.first.org/cvss/v3-1/) */
|
|
29
29
|
CVSSv31 = 'CVSSv31',
|
|
30
|
-
/** [
|
|
30
|
+
/** CVSSv4 - [Common Vulnerability Scoring System v4](https://www.first.org/cvss/v4-0/) */
|
|
31
|
+
CVSSv4 = 'CVSSv4',
|
|
32
|
+
/** OWASP - [OWASP Risk Rating Methodology](https://owasp.org/www-community/OWASP_Risk_Rating_Methodology) */
|
|
31
33
|
OWASP = 'OWASP',
|
|
34
|
+
/** SSVC - [Stakeholder Specific Vulnerability Categorization](https://github.com/CERTCC/SSVC) (all versions) */
|
|
35
|
+
SSVC = 'SSVC',
|
|
36
|
+
/** any other */
|
|
32
37
|
Other = 'other',
|
|
33
38
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
This file is part of CycloneDX JavaScript Library.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
|
|
16
|
+
SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { Comparable } from '../_helpers/sortable'
|
|
21
|
+
import type { Stringable } from '../_helpers/stringable'
|
|
22
|
+
|
|
23
|
+
abstract class BomLinkBase implements Stringable, Comparable<Stringable> {
|
|
24
|
+
/* @ts-expect-error TS2564 */
|
|
25
|
+
#value: string
|
|
26
|
+
|
|
27
|
+
/** @internal */
|
|
28
|
+
protected abstract _isValid (value: any): boolean
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @throws {@link RangeError} if value is invalid
|
|
32
|
+
*/
|
|
33
|
+
constructor (value: string) {
|
|
34
|
+
this.value = value
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @throws {@link RangeError} if value is invalid
|
|
39
|
+
*/
|
|
40
|
+
set value (value: string) {
|
|
41
|
+
if (!this._isValid(value)) {
|
|
42
|
+
throw new RangeError('invalid value')
|
|
43
|
+
}
|
|
44
|
+
this.#value = value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get value (): string {
|
|
48
|
+
return this.#value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
compare (other: Stringable): number {
|
|
52
|
+
return this.toString().localeCompare(other.toString())
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
toString (): string {
|
|
56
|
+
return this.value
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Descriptor for another BOM document.
|
|
62
|
+
*
|
|
63
|
+
* See [the docs](https://cyclonedx.org/capabilities/bomlink/)
|
|
64
|
+
*/
|
|
65
|
+
export class BomLinkDocument extends BomLinkBase {
|
|
66
|
+
/* regular expressions were taken from the CycloneDX schema definitions. */
|
|
67
|
+
static #pattern = /^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[1-9][0-9]*$/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether the `value` is a valid descriptor for another BOM document.
|
|
71
|
+
*/
|
|
72
|
+
static isValid (value: any): boolean {
|
|
73
|
+
return typeof value === 'string' &&
|
|
74
|
+
this.#pattern.test(value)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @internal */
|
|
78
|
+
protected _isValid (value: any): boolean {
|
|
79
|
+
return BomLinkDocument.isValid(value)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Descriptor for an element in a BOM document.
|
|
85
|
+
*
|
|
86
|
+
* See [the docs](https://cyclonedx.org/capabilities/bomlink/)
|
|
87
|
+
*/
|
|
88
|
+
export class BomLinkElement extends BomLinkBase {
|
|
89
|
+
/* regular expressions were taken from the CycloneDX schema definitions. */
|
|
90
|
+
static #pattern = /^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[1-9][0-9]*#.+$/
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether the `value` is a valid descriptor for an element in a BOM document.
|
|
94
|
+
*/
|
|
95
|
+
static isValid (value: any): boolean {
|
|
96
|
+
return typeof value === 'string' &&
|
|
97
|
+
this.#pattern.test(value)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** @internal */
|
|
101
|
+
protected _isValid (value: any): boolean {
|
|
102
|
+
return BomLinkElement.isValid(value)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Either {@link BomLinkDocument} or {@link BomLinkElement}.
|
|
108
|
+
*
|
|
109
|
+
* See [the docs](https://cyclonedx.org/capabilities/bomlink/)
|
|
110
|
+
*/
|
|
111
|
+
export type BomLink = BomLinkDocument | BomLinkElement
|
package/src/models/bomRef.ts
CHANGED
|
@@ -17,18 +17,21 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
import type { Comparable } from '../_helpers/sortable'
|
|
21
|
+
import type { Stringable } from '../_helpers/stringable'
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* Proxy for the BomRef.
|
|
22
25
|
* This way a `BomRef` gets unique by the in-memory-address of the object.
|
|
23
26
|
*/
|
|
24
|
-
export class BomRef {
|
|
27
|
+
export class BomRef implements Stringable, Comparable<Stringable> {
|
|
25
28
|
value?: string
|
|
26
29
|
|
|
27
30
|
constructor (value?: BomRef['value']) {
|
|
28
31
|
this.value = value
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
compare (other:
|
|
34
|
+
compare (other: Stringable): number {
|
|
32
35
|
return this.toString().localeCompare(other.toString())
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -20,13 +20,14 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
20
20
|
import type { Comparable } from '../_helpers/sortable'
|
|
21
21
|
import { SortableComparables } from '../_helpers/sortable'
|
|
22
22
|
import type { ExternalReferenceType } from '../enums'
|
|
23
|
+
import type { BomLink } from './bomLink'
|
|
23
24
|
|
|
24
25
|
export interface OptionalExternalReferenceProperties {
|
|
25
26
|
comment?: ExternalReference['comment']
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export class ExternalReference implements Comparable<ExternalReference> {
|
|
29
|
-
url: URL | string
|
|
30
|
+
url: URL | BomLink | string
|
|
30
31
|
type: ExternalReferenceType
|
|
31
32
|
comment?: string
|
|
32
33
|
|
package/src/models/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
20
20
|
import type { Comparable } from '../../_helpers/sortable'
|
|
21
21
|
import { SortableComparables } from '../../_helpers/sortable'
|
|
22
22
|
import type { AffectStatus } from '../../enums/vulnerability'
|
|
23
|
+
import type { BomLinkElement } from '../bomLink'
|
|
23
24
|
import type { BomRef } from '../bomRef'
|
|
24
25
|
|
|
25
26
|
export interface OptionalAffectProperties {
|
|
@@ -27,10 +28,10 @@ export interface OptionalAffectProperties {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export class Affect implements Comparable<Affect> {
|
|
30
|
-
ref: BomRef
|
|
31
|
+
ref: BomRef | BomLinkElement
|
|
31
32
|
versions: AffectedVersionRepository
|
|
32
33
|
|
|
33
|
-
constructor (ref:
|
|
34
|
+
constructor (ref: Affect['ref'], op: OptionalAffectProperties = {}) {
|
|
34
35
|
this.ref = ref
|
|
35
36
|
this.versions = op.versions ?? new AffectedVersionRepository()
|
|
36
37
|
}
|
package/src/resources.node.ts
CHANGED
|
@@ -31,30 +31,33 @@ export const SCHEMA_ROOT = path.resolve(ROOT, 'schema')
|
|
|
31
31
|
export const FILES = Object.freeze({
|
|
32
32
|
CDX: Object.freeze({
|
|
33
33
|
XML_SCHEMA: Object.freeze({
|
|
34
|
-
[Version.
|
|
35
|
-
[Version.
|
|
36
|
-
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.xsd'),
|
|
34
|
+
[Version.v1dot5]: path.resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.xsd'),
|
|
35
|
+
[Version.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.xsd'),
|
|
37
36
|
[Version.v1dot3]: path.resolve(SCHEMA_ROOT, 'bom-1.3.SNAPSHOT.xsd'),
|
|
38
|
-
[Version.
|
|
37
|
+
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.xsd'),
|
|
38
|
+
[Version.v1dot1]: path.resolve(SCHEMA_ROOT, 'bom-1.1.SNAPSHOT.xsd'),
|
|
39
|
+
[Version.v1dot0]: path.resolve(SCHEMA_ROOT, 'bom-1.0.SNAPSHOT.xsd')
|
|
40
|
+
|
|
39
41
|
}),
|
|
40
42
|
JSON_SCHEMA: Object.freeze({
|
|
41
|
-
|
|
42
|
-
[Version.
|
|
43
|
-
// v1.1 is not defined in JSON
|
|
44
|
-
[Version.v1dot1]: undefined,
|
|
45
|
-
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.schema.json'),
|
|
43
|
+
[Version.v1dot5]: path.resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.schema.json'),
|
|
44
|
+
[Version.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json'),
|
|
46
45
|
[Version.v1dot3]: path.resolve(SCHEMA_ROOT, 'bom-1.3.SNAPSHOT.schema.json'),
|
|
47
|
-
[Version.
|
|
46
|
+
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2.SNAPSHOT.schema.json'),
|
|
47
|
+
// <= v1.1 is not defined in JSON
|
|
48
|
+
[Version.v1dot1]: undefined,
|
|
49
|
+
[Version.v1dot0]: undefined
|
|
48
50
|
}),
|
|
49
51
|
JSON_STRICT_SCHEMA: Object.freeze({
|
|
50
|
-
// v1.
|
|
51
|
-
[Version.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2-strict.SNAPSHOT.schema.json'),
|
|
52
|
+
// >= v1.4 is already strict - no special file here
|
|
53
|
+
[Version.v1dot5]: path.resolve(SCHEMA_ROOT, 'bom-1.5.SNAPSHOT.schema.json'),
|
|
54
|
+
[Version.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json'),
|
|
55
|
+
// <= 1.3 need special files
|
|
55
56
|
[Version.v1dot3]: path.resolve(SCHEMA_ROOT, 'bom-1.3-strict.SNAPSHOT.schema.json'),
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
[Version.v1dot2]: path.resolve(SCHEMA_ROOT, 'bom-1.2-strict.SNAPSHOT.schema.json'),
|
|
58
|
+
// <= v1.1 is not defined in JSON
|
|
59
|
+
[Version.v1dot1]: undefined,
|
|
60
|
+
[Version.v1dot0]: undefined
|
|
58
61
|
})
|
|
59
62
|
}),
|
|
60
63
|
SPDX: Object.freeze({
|
|
@@ -134,9 +134,10 @@ export class Factory {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const schemaUrl: ReadonlyMap<SpecVersion, string> = new Map([
|
|
137
|
-
[SpecVersion.
|
|
137
|
+
[SpecVersion.v1dot5, 'http://cyclonedx.org/schema/bom-1.5.schema.json'],
|
|
138
|
+
[SpecVersion.v1dot4, 'http://cyclonedx.org/schema/bom-1.4.schema.json'],
|
|
138
139
|
[SpecVersion.v1dot3, 'http://cyclonedx.org/schema/bom-1.3a.schema.json'],
|
|
139
|
-
[SpecVersion.
|
|
140
|
+
[SpecVersion.v1dot2, 'http://cyclonedx.org/schema/bom-1.2b.schema.json']
|
|
140
141
|
])
|
|
141
142
|
|
|
142
143
|
interface JsonNormalizer<TModel, TNormalized> {
|
|
@@ -680,7 +681,9 @@ export class VulnerabilityRatingNormalizer extends BaseJsonNormalizer<Models.Vul
|
|
|
680
681
|
: this._factory.makeForVulnerabilitySource().normalize(data.source, options),
|
|
681
682
|
score: data.score,
|
|
682
683
|
severity: data.severity,
|
|
683
|
-
method: data.method
|
|
684
|
+
method: this._factory.spec.supportsVulnerabilityRatingMethod(data.method)
|
|
685
|
+
? data.method
|
|
686
|
+
: undefined,
|
|
684
687
|
vector: data.vector,
|
|
685
688
|
justification: data.justification
|
|
686
689
|
}
|
|
@@ -66,6 +66,11 @@ export namespace JsonSchema {
|
|
|
66
66
|
export namespace Normalized {
|
|
67
67
|
|
|
68
68
|
export type RefType = string
|
|
69
|
+
export type RefLinkType = RefType
|
|
70
|
+
|
|
71
|
+
export type BomLinkDocumentType = string
|
|
72
|
+
export type BomLinkElementType = string
|
|
73
|
+
export type BomLink = BomLinkDocumentType | BomLinkElementType
|
|
69
74
|
|
|
70
75
|
export interface Bom {
|
|
71
76
|
$schema?: string
|
|
@@ -183,7 +188,7 @@ export namespace Normalized {
|
|
|
183
188
|
}
|
|
184
189
|
|
|
185
190
|
export interface ExternalReference {
|
|
186
|
-
url:
|
|
191
|
+
url: JsonSchema.IriReference | BomLink
|
|
187
192
|
type: Enums.ExternalReferenceType
|
|
188
193
|
comment?: string
|
|
189
194
|
}
|
|
@@ -200,8 +205,8 @@ export namespace Normalized {
|
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
export interface Dependency {
|
|
203
|
-
ref:
|
|
204
|
-
dependsOn?:
|
|
208
|
+
ref: RefLinkType
|
|
209
|
+
dependsOn?: RefLinkType[]
|
|
205
210
|
}
|
|
206
211
|
|
|
207
212
|
export interface Vulnerability {
|
|
@@ -248,7 +253,7 @@ export namespace Normalized {
|
|
|
248
253
|
|
|
249
254
|
export interface Advisory {
|
|
250
255
|
title?: string
|
|
251
|
-
url:
|
|
256
|
+
url: JsonSchema.IriReference
|
|
252
257
|
}
|
|
253
258
|
|
|
254
259
|
export interface Credits {
|
|
@@ -264,7 +269,7 @@ export namespace Normalized {
|
|
|
264
269
|
}
|
|
265
270
|
|
|
266
271
|
export interface Affect {
|
|
267
|
-
ref:
|
|
272
|
+
ref: RefLinkType | BomLinkElementType
|
|
268
273
|
versions?: AffectedVersion[]
|
|
269
274
|
}
|
|
270
275
|
|
|
@@ -134,9 +134,12 @@ export class Factory {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const xmlNamespace: ReadonlyMap<SpecVersion, string> = new Map([
|
|
137
|
-
[SpecVersion.
|
|
137
|
+
[SpecVersion.v1dot5, 'http://cyclonedx.org/schema/bom/1.5'],
|
|
138
|
+
[SpecVersion.v1dot4, 'http://cyclonedx.org/schema/bom/1.4'],
|
|
138
139
|
[SpecVersion.v1dot3, 'http://cyclonedx.org/schema/bom/1.3'],
|
|
139
|
-
[SpecVersion.
|
|
140
|
+
[SpecVersion.v1dot2, 'http://cyclonedx.org/schema/bom/1.2'],
|
|
141
|
+
[SpecVersion.v1dot1, 'http://cyclonedx.org/schema/bom/1.1'],
|
|
142
|
+
[SpecVersion.v1dot0, 'http://cyclonedx.org/schema/bom/1.0']
|
|
140
143
|
])
|
|
141
144
|
|
|
142
145
|
interface XmlNormalizer<TModel, TNormalized> {
|
|
@@ -868,7 +871,9 @@ export class VulnerabilityRatingNormalizer extends BaseXmlNormalizer<Models.Vuln
|
|
|
868
871
|
: this._factory.makeForVulnerabilitySource().normalize(data.source, options, 'source'),
|
|
869
872
|
makeOptionalTextElement(data.score, 'score'),
|
|
870
873
|
makeOptionalTextElement(data.severity, 'severity'),
|
|
871
|
-
|
|
874
|
+
this._factory.spec.supportsVulnerabilityRatingMethod(data.method)
|
|
875
|
+
? makeOptionalTextElement(data.method, 'method')
|
|
876
|
+
: undefined,
|
|
872
877
|
makeOptionalTextElement(data.vector, 'vector'),
|
|
873
878
|
makeOptionalTextElement(data.justification, 'justification')
|
|
874
879
|
].filter(isNotUndefined)
|
package/src/spec.ts
CHANGED
|
@@ -17,15 +17,16 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { ComponentType, ExternalReferenceType, HashAlgorithm } from './enums'
|
|
20
|
+
import { ComponentType, ExternalReferenceType, HashAlgorithm, Vulnerability } from './enums'
|
|
21
21
|
import type { HashContent } from './models'
|
|
22
22
|
|
|
23
23
|
export enum Version {
|
|
24
|
-
|
|
25
|
-
v1dot1 = '1.1',
|
|
26
|
-
v1dot2 = '1.2',
|
|
27
|
-
v1dot3 = '1.3',
|
|
24
|
+
v1dot5 = '1.5',
|
|
28
25
|
v1dot4 = '1.4',
|
|
26
|
+
v1dot3 = '1.3',
|
|
27
|
+
v1dot2 = '1.2',
|
|
28
|
+
v1dot1 = '1.1',
|
|
29
|
+
v1dot0 = '1.0',
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export enum Format {
|
|
@@ -48,6 +49,7 @@ export interface Protocol {
|
|
|
48
49
|
requiresComponentVersion: boolean
|
|
49
50
|
supportsProperties: (model: any) => boolean
|
|
50
51
|
supportsVulnerabilities: boolean
|
|
52
|
+
supportsVulnerabilityRatingMethod: (rm: Vulnerability.RatingMethod | any) => boolean
|
|
51
53
|
supportsComponentEvidence: boolean
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -62,6 +64,7 @@ class Spec implements Protocol {
|
|
|
62
64
|
readonly #hashAlgorithms: ReadonlySet<HashAlgorithm>
|
|
63
65
|
readonly #hashValuePattern: RegExp
|
|
64
66
|
readonly #externalReferenceTypes: ReadonlySet<ExternalReferenceType>
|
|
67
|
+
readonly #vulnerabilityRatingMethods: ReadonlySet<Vulnerability.RatingMethod>
|
|
65
68
|
readonly #supportsDependencyGraph: boolean
|
|
66
69
|
readonly #supportsToolReferences: boolean
|
|
67
70
|
readonly #requiresComponentVersion: boolean
|
|
@@ -81,6 +84,7 @@ class Spec implements Protocol {
|
|
|
81
84
|
requiresComponentVersion: boolean,
|
|
82
85
|
supportsProperties: boolean,
|
|
83
86
|
supportsVulnerabilities: boolean,
|
|
87
|
+
vulnerabilityRatingMethods: Iterable<Vulnerability.RatingMethod>,
|
|
84
88
|
supportsComponentEvidence: boolean
|
|
85
89
|
) {
|
|
86
90
|
this.#version = version
|
|
@@ -94,6 +98,7 @@ class Spec implements Protocol {
|
|
|
94
98
|
this.#requiresComponentVersion = requiresComponentVersion
|
|
95
99
|
this.#supportsProperties = supportsProperties
|
|
96
100
|
this.#supportsVulnerabilities = supportsVulnerabilities
|
|
101
|
+
this.#vulnerabilityRatingMethods = new Set(vulnerabilityRatingMethods)
|
|
97
102
|
this.#supportsComponentEvidence = supportsComponentEvidence
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -143,6 +148,10 @@ class Spec implements Protocol {
|
|
|
143
148
|
return this.#supportsVulnerabilities
|
|
144
149
|
}
|
|
145
150
|
|
|
151
|
+
supportsVulnerabilityRatingMethod (rm: Vulnerability.RatingMethod | any): boolean {
|
|
152
|
+
return this.#vulnerabilityRatingMethods.has(rm)
|
|
153
|
+
}
|
|
154
|
+
|
|
146
155
|
get supportsComponentEvidence (): boolean {
|
|
147
156
|
return this.#supportsComponentEvidence
|
|
148
157
|
}
|
|
@@ -202,6 +211,7 @@ export const Spec1dot2: Readonly<Protocol> = Object.freeze(new Spec(
|
|
|
202
211
|
true,
|
|
203
212
|
false,
|
|
204
213
|
false,
|
|
214
|
+
[],
|
|
205
215
|
false
|
|
206
216
|
))
|
|
207
217
|
|
|
@@ -259,6 +269,7 @@ export const Spec1dot3: Readonly<Protocol> = Object.freeze(new Spec(
|
|
|
259
269
|
true,
|
|
260
270
|
true,
|
|
261
271
|
false,
|
|
272
|
+
[],
|
|
262
273
|
true
|
|
263
274
|
))
|
|
264
275
|
|
|
@@ -317,11 +328,114 @@ export const Spec1dot4: Readonly<Protocol> = Object.freeze(new Spec(
|
|
|
317
328
|
false,
|
|
318
329
|
true,
|
|
319
330
|
true,
|
|
331
|
+
[
|
|
332
|
+
Vulnerability.RatingMethod.CVSSv2,
|
|
333
|
+
Vulnerability.RatingMethod.CVSSv3,
|
|
334
|
+
Vulnerability.RatingMethod.CVSSv31,
|
|
335
|
+
Vulnerability.RatingMethod.OWASP,
|
|
336
|
+
Vulnerability.RatingMethod.Other
|
|
337
|
+
],
|
|
338
|
+
true
|
|
339
|
+
))
|
|
340
|
+
|
|
341
|
+
/** Specification v1.5 */
|
|
342
|
+
export const Spec1dot5: Readonly<Protocol> = Object.freeze(new Spec(
|
|
343
|
+
Version.v1dot5,
|
|
344
|
+
[
|
|
345
|
+
Format.XML,
|
|
346
|
+
Format.JSON
|
|
347
|
+
],
|
|
348
|
+
[
|
|
349
|
+
ComponentType.Application,
|
|
350
|
+
ComponentType.Framework,
|
|
351
|
+
ComponentType.Library,
|
|
352
|
+
ComponentType.Container,
|
|
353
|
+
ComponentType.Platform,
|
|
354
|
+
ComponentType.OperatingSystem,
|
|
355
|
+
ComponentType.Device,
|
|
356
|
+
ComponentType.DeviceDriver,
|
|
357
|
+
ComponentType.Firmware,
|
|
358
|
+
ComponentType.File,
|
|
359
|
+
ComponentType.MachineLearningModel,
|
|
360
|
+
ComponentType.Data
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
HashAlgorithm.MD5,
|
|
364
|
+
HashAlgorithm['SHA-1'],
|
|
365
|
+
HashAlgorithm['SHA-256'],
|
|
366
|
+
HashAlgorithm['SHA-384'],
|
|
367
|
+
HashAlgorithm['SHA-512'],
|
|
368
|
+
HashAlgorithm['SHA3-256'],
|
|
369
|
+
HashAlgorithm['SHA3-384'],
|
|
370
|
+
HashAlgorithm['SHA3-512'],
|
|
371
|
+
HashAlgorithm['BLAKE2b-256'],
|
|
372
|
+
HashAlgorithm['BLAKE2b-384'],
|
|
373
|
+
HashAlgorithm['BLAKE2b-512'],
|
|
374
|
+
HashAlgorithm.BLAKE3
|
|
375
|
+
],
|
|
376
|
+
/^([a-fA-F0-9]{32})$|^([a-fA-F0-9]{40})$|^([a-fA-F0-9]{64})$|^([a-fA-F0-9]{96})$|^([a-fA-F0-9]{128})$/,
|
|
377
|
+
[
|
|
378
|
+
ExternalReferenceType.VCS,
|
|
379
|
+
ExternalReferenceType.IssueTracker,
|
|
380
|
+
ExternalReferenceType.Website,
|
|
381
|
+
ExternalReferenceType.Advisories,
|
|
382
|
+
ExternalReferenceType.BOM,
|
|
383
|
+
ExternalReferenceType.MailingList,
|
|
384
|
+
ExternalReferenceType.Social,
|
|
385
|
+
ExternalReferenceType.Chat,
|
|
386
|
+
ExternalReferenceType.Documentation,
|
|
387
|
+
ExternalReferenceType.Support,
|
|
388
|
+
ExternalReferenceType.Distribution,
|
|
389
|
+
ExternalReferenceType.DistributionIntake,
|
|
390
|
+
ExternalReferenceType.License,
|
|
391
|
+
ExternalReferenceType.BuildMeta,
|
|
392
|
+
ExternalReferenceType.BuildSystem,
|
|
393
|
+
ExternalReferenceType.ReleaseNotes,
|
|
394
|
+
ExternalReferenceType.SecurityContact,
|
|
395
|
+
ExternalReferenceType.ModelCard,
|
|
396
|
+
ExternalReferenceType.Log,
|
|
397
|
+
ExternalReferenceType.Configuration,
|
|
398
|
+
ExternalReferenceType.Evidence,
|
|
399
|
+
ExternalReferenceType.Formulation,
|
|
400
|
+
ExternalReferenceType.Attestation,
|
|
401
|
+
ExternalReferenceType.ThreatModel,
|
|
402
|
+
ExternalReferenceType.AdversaryModel,
|
|
403
|
+
ExternalReferenceType.RiskAssessment,
|
|
404
|
+
ExternalReferenceType.VulnerabilityAssertion,
|
|
405
|
+
ExternalReferenceType.ExploitabilityStatement,
|
|
406
|
+
ExternalReferenceType.PentestReport,
|
|
407
|
+
ExternalReferenceType.StaticAnalysisReport,
|
|
408
|
+
ExternalReferenceType.DynamicAnalysisReport,
|
|
409
|
+
ExternalReferenceType.RuntimeAnalysisReport,
|
|
410
|
+
ExternalReferenceType.ComponentAnalysisReport,
|
|
411
|
+
ExternalReferenceType.MaturityReport,
|
|
412
|
+
ExternalReferenceType.CertificationReport,
|
|
413
|
+
ExternalReferenceType.CodifiedInfrastructure,
|
|
414
|
+
ExternalReferenceType.QualityMetrics,
|
|
415
|
+
ExternalReferenceType.POAM,
|
|
416
|
+
ExternalReferenceType.Other
|
|
417
|
+
],
|
|
418
|
+
true,
|
|
419
|
+
true,
|
|
420
|
+
false,
|
|
421
|
+
true,
|
|
422
|
+
true,
|
|
423
|
+
[
|
|
424
|
+
Vulnerability.RatingMethod.CVSSv2,
|
|
425
|
+
Vulnerability.RatingMethod.CVSSv3,
|
|
426
|
+
Vulnerability.RatingMethod.CVSSv31,
|
|
427
|
+
Vulnerability.RatingMethod.CVSSv4,
|
|
428
|
+
Vulnerability.RatingMethod.OWASP,
|
|
429
|
+
Vulnerability.RatingMethod.SSVC,
|
|
430
|
+
Vulnerability.RatingMethod.Other
|
|
431
|
+
],
|
|
320
432
|
true
|
|
321
433
|
))
|
|
322
434
|
|
|
323
435
|
export const SpecVersionDict: Readonly<Partial<Record<Version, Readonly<Protocol>>>> = Object.freeze({
|
|
324
|
-
[Version.
|
|
436
|
+
[Version.v1dot5]: Spec1dot5,
|
|
437
|
+
[Version.v1dot4]: Spec1dot4,
|
|
325
438
|
[Version.v1dot3]: Spec1dot3,
|
|
326
|
-
[Version.
|
|
439
|
+
[Version.v1dot2]: Spec1dot2
|
|
440
|
+
// <= v1.1 is not implemented
|
|
327
441
|
})
|
package/src/types/integer.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function isInteger (value: any): value is Integer {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Integer greater than 0
|
|
32
|
+
* Integer greater than or equal to `0`
|
|
33
33
|
*
|
|
34
34
|
* @see {@link isNonNegativeInteger}
|
|
35
35
|
*/
|
|
@@ -41,7 +41,7 @@ export function isNonNegativeInteger (value: any): value is NonNegativeInteger {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Integer greater 0
|
|
44
|
+
* Integer greater `0`
|
|
45
45
|
*
|
|
46
46
|
* @see {@link isPositiveInteger}
|
|
47
47
|
*/
|