@cyclonedx/cyclonedx-library 2.0.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.
Files changed (103) hide show
  1. package/README.md +3 -2
  2. package/dist.d/enums/componentType.d.ts +5 -1
  3. package/dist.d/enums/componentType.d.ts.map +1 -1
  4. package/dist.d/enums/externalReferenceType.d.ts +23 -0
  5. package/dist.d/enums/externalReferenceType.d.ts.map +1 -1
  6. package/dist.d/enums/vulnerability/ratingMethod.d.ts +9 -4
  7. package/dist.d/enums/vulnerability/ratingMethod.d.ts.map +1 -1
  8. package/dist.d/models/bomLink.d.ts +66 -0
  9. package/dist.d/models/bomLink.d.ts.map +1 -0
  10. package/dist.d/models/bomRef.d.ts +4 -2
  11. package/dist.d/models/bomRef.d.ts.map +1 -1
  12. package/dist.d/models/externalReference.d.ts +2 -1
  13. package/dist.d/models/externalReference.d.ts.map +1 -1
  14. package/dist.d/models/index.d.ts +1 -0
  15. package/dist.d/models/index.d.ts.map +1 -1
  16. package/dist.d/models/vulnerability/affect.d.ts +3 -2
  17. package/dist.d/models/vulnerability/affect.d.ts.map +1 -1
  18. package/dist.d/serialize/json/normalize.d.ts.map +1 -1
  19. package/dist.d/serialize/json/types.d.ts +9 -5
  20. package/dist.d/serialize/json/types.d.ts.map +1 -1
  21. package/dist.d/serialize/xml/normalize.d.ts +9 -9
  22. package/dist.d/serialize/xml/normalize.d.ts.map +1 -1
  23. package/dist.d/spec.d.ts +9 -5
  24. package/dist.d/spec.d.ts.map +1 -1
  25. package/dist.d/types/integer.d.ts +2 -2
  26. package/dist.node/_helpers/packageUrl.js +1 -1
  27. package/dist.node/_helpers/packageUrl.js.map +1 -1
  28. package/dist.node/enums/attachmentEncoding.js +1 -1
  29. package/dist.node/enums/attachmentEncoding.js.map +1 -1
  30. package/dist.node/enums/componentScope.js +1 -1
  31. package/dist.node/enums/componentScope.js.map +1 -1
  32. package/dist.node/enums/componentType.js +5 -1
  33. package/dist.node/enums/componentType.js.map +1 -1
  34. package/dist.node/enums/externalReferenceType.js +24 -1
  35. package/dist.node/enums/externalReferenceType.js.map +1 -1
  36. package/dist.node/enums/hashAlogorithm.js +1 -1
  37. package/dist.node/enums/hashAlogorithm.js.map +1 -1
  38. package/dist.node/enums/vulnerability/affectStatus.js +1 -1
  39. package/dist.node/enums/vulnerability/affectStatus.js.map +1 -1
  40. package/dist.node/enums/vulnerability/analysisJustification.js +1 -1
  41. package/dist.node/enums/vulnerability/analysisJustification.js.map +1 -1
  42. package/dist.node/enums/vulnerability/analysisResponse.js +1 -1
  43. package/dist.node/enums/vulnerability/analysisResponse.js.map +1 -1
  44. package/dist.node/enums/vulnerability/analysisState.js +1 -1
  45. package/dist.node/enums/vulnerability/analysisState.js.map +1 -1
  46. package/dist.node/enums/vulnerability/ratingMethod.js +3 -1
  47. package/dist.node/enums/vulnerability/ratingMethod.js.map +1 -1
  48. package/dist.node/enums/vulnerability/severity.js +1 -1
  49. package/dist.node/enums/vulnerability/severity.js.map +1 -1
  50. package/dist.node/models/bomLink.js +80 -0
  51. package/dist.node/models/bomLink.js.map +1 -0
  52. package/dist.node/models/bomRef.js.map +1 -1
  53. package/dist.node/models/externalReference.js.map +1 -1
  54. package/dist.node/models/index.js +1 -0
  55. package/dist.node/models/index.js.map +1 -1
  56. package/dist.node/models/vulnerability/affect.js.map +1 -1
  57. package/dist.node/resources.node.js +15 -12
  58. package/dist.node/resources.node.js.map +1 -1
  59. package/dist.node/serialize/json/normalize.js +6 -3
  60. package/dist.node/serialize/json/normalize.js.map +1 -1
  61. package/dist.node/serialize/json/types.js +1 -1
  62. package/dist.node/serialize/json/types.js.map +1 -1
  63. package/dist.node/serialize/xml/normalize.js +18 -4
  64. package/dist.node/serialize/xml/normalize.js.map +1 -1
  65. package/dist.node/serialize/xml/types.js +1 -1
  66. package/dist.node/serialize/xml/types.js.map +1 -1
  67. package/dist.node/spec.js +106 -15
  68. package/dist.node/spec.js.map +1 -1
  69. package/dist.web/lib.dev.js +264 -37
  70. package/dist.web/lib.dev.js.map +1 -1
  71. package/dist.web/lib.js +1 -1
  72. package/dist.web/lib.js.map +1 -1
  73. package/libs/universal-node-xml/stringifiers/xmlbuilder2.js +1 -1
  74. package/package.json +9 -9
  75. package/res/schema/README.md +14 -11
  76. package/res/schema/bom-1.1.SNAPSHOT.xsd +8 -1
  77. package/res/schema/bom-1.2-strict.SNAPSHOT.schema.json +8 -5
  78. package/res/schema/bom-1.2.SNAPSHOT.schema.json +8 -4
  79. package/res/schema/bom-1.2.SNAPSHOT.xsd +10 -3
  80. package/res/schema/bom-1.3-strict.SNAPSHOT.schema.json +8 -4
  81. package/res/schema/bom-1.3.SNAPSHOT.schema.json +8 -4
  82. package/res/schema/bom-1.3.SNAPSHOT.xsd +14 -5
  83. package/res/schema/bom-1.4.SNAPSHOT.schema.json +2 -2
  84. package/res/schema/bom-1.4.SNAPSHOT.xsd +4 -2
  85. package/res/schema/bom-1.5.SNAPSHOT.schema.json +3799 -0
  86. package/res/schema/bom-1.5.SNAPSHOT.xsd +5464 -0
  87. package/res/schema/jsf-0.82.SNAPSHOT.schema.json +0 -4
  88. package/res/schema/spdx.SNAPSHOT.schema.json +569 -486
  89. package/res/schema/spdx.SNAPSHOT.xsd +1468 -1053
  90. package/src/enums/componentType.ts +4 -0
  91. package/src/enums/externalReferenceType.ts +23 -0
  92. package/src/enums/vulnerability/ratingMethod.ts +9 -4
  93. package/src/models/bomLink.ts +111 -0
  94. package/src/models/bomRef.ts +5 -2
  95. package/src/models/externalReference.ts +2 -1
  96. package/src/models/index.ts +1 -0
  97. package/src/models/vulnerability/affect.ts +3 -2
  98. package/src/resources.node.ts +20 -17
  99. package/src/serialize/json/normalize.ts +6 -3
  100. package/src/serialize/json/types.ts +10 -5
  101. package/src/serialize/xml/normalize.ts +17 -12
  102. package/src/spec.ts +121 -7
  103. 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
- /** [CVSS v2 standard](https://www.first.org/cvss/v2/) */
24
+ /** CVSSv2 - [Common Vulnerability Scoring System v2](https://www.first.org/cvss/v2/) */
25
25
  CVSSv2 = 'CVSSv2',
26
- /** [CVSS v3.0 standard](https://www.first.org/cvss/v3-0/) */
26
+ /** CVSSv3 - [Common Vulnerability Scoring System v3](https://www.first.org/cvss/v3-0/) */
27
27
  CVSSv3 = 'CVSSv3',
28
- /** [CVSS v3.1 standard](https://www.first.org/cvss/v3-1/) */
28
+ /** CVSSv31 - [Common Vulnerability Scoring System v3.1](https://www.first.org/cvss/v3-1/) */
29
29
  CVSSv31 = 'CVSSv31',
30
- /** [OWASP Risk Rating](https://owasp.org/www-community/OWASP_Risk_Rating_Methodology) */
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
@@ -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: BomRef): number {
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
 
@@ -19,6 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
19
19
 
20
20
  export * from './attachment'
21
21
  export * from './bom'
22
+ export * from './bomLink'
22
23
  export * from './bomRef'
23
24
  export * from './component'
24
25
  export * from './externalReference'
@@ -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: BomRef, op: OptionalAffectProperties = {}) {
34
+ constructor (ref: Affect['ref'], op: OptionalAffectProperties = {}) {
34
35
  this.ref = ref
35
36
  this.versions = op.versions ?? new AffectedVersionRepository()
36
37
  }
@@ -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.v1dot0]: path.resolve(SCHEMA_ROOT, 'bom-1.0.SNAPSHOT.xsd'),
35
- [Version.v1dot1]: path.resolve(SCHEMA_ROOT, 'bom-1.1.SNAPSHOT.xsd'),
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.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.xsd')
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
- // v1.0 is not defined in JSON
42
- [Version.v1dot0]: undefined,
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.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json')
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.0 is not defined in JSON
51
- [Version.v1dot0]: undefined,
52
- // v1.1 is not defined in JSON
53
- [Version.v1dot1]: undefined,
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
- // v1.4 is already strict - no special file here
57
- [Version.v1dot4]: path.resolve(SCHEMA_ROOT, 'bom-1.4.SNAPSHOT.schema.json')
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.v1dot2, 'http://cyclonedx.org/schema/bom-1.2b.schema.json'],
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.v1dot4, 'http://cyclonedx.org/schema/bom-1.4.schema.json']
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: string
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: RefType
204
- dependsOn?: RefType[]
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: string
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: RefType
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.v1dot2, 'http://cyclonedx.org/schema/bom/1.2'],
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.v1dot4, 'http://cyclonedx.org/schema/bom/1.4']
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> {
@@ -724,7 +727,7 @@ export class DependencyGraphNormalizer extends BaseXmlNormalizer<Models.Bom> {
724
727
  }
725
728
  }
726
729
 
727
- class VulnerabilityNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Vulnerability> {
730
+ export class VulnerabilityNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Vulnerability> {
728
731
  normalize (data: Models.Vulnerability.Vulnerability, options: NormalizerOptions, elementName: string): SimpleXml.Element {
729
732
  const references: SimpleXml.Element | undefined = data.references.size > 0
730
733
  ? {
@@ -820,7 +823,7 @@ class VulnerabilityNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Vul
820
823
  }
821
824
  }
822
825
 
823
- class VulnerabilitySourceNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Source> {
826
+ export class VulnerabilitySourceNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Source> {
824
827
  normalize (data: Models.Vulnerability.Source, options: NormalizerOptions, elementName: string): SimpleXml.Element {
825
828
  const url = data.url?.toString()
826
829
  return {
@@ -836,7 +839,7 @@ class VulnerabilitySourceNormalizer extends BaseXmlNormalizer<Models.Vulnerabili
836
839
  }
837
840
  }
838
841
 
839
- class VulnerabilityReferenceNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Reference> {
842
+ export class VulnerabilityReferenceNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Reference> {
840
843
  normalize (data: Models.Vulnerability.Reference, options: NormalizerOptions, elementName: string): SimpleXml.Element {
841
844
  return {
842
845
  type: 'element',
@@ -857,7 +860,7 @@ class VulnerabilityReferenceNormalizer extends BaseXmlNormalizer<Models.Vulnerab
857
860
  }
858
861
  }
859
862
 
860
- class VulnerabilityRatingNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Rating> {
863
+ export class VulnerabilityRatingNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Rating> {
861
864
  normalize (data: Models.Vulnerability.Rating, options: NormalizerOptions, elementName: string): SimpleXml.Element {
862
865
  return {
863
866
  type: 'element',
@@ -868,7 +871,9 @@ class VulnerabilityRatingNormalizer extends BaseXmlNormalizer<Models.Vulnerabili
868
871
  : this._factory.makeForVulnerabilitySource().normalize(data.source, options, 'source'),
869
872
  makeOptionalTextElement(data.score, 'score'),
870
873
  makeOptionalTextElement(data.severity, 'severity'),
871
- makeOptionalTextElement(data.method, 'method'),
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)
@@ -884,7 +889,7 @@ class VulnerabilityRatingNormalizer extends BaseXmlNormalizer<Models.Vulnerabili
884
889
  }
885
890
  }
886
891
 
887
- class VulnerabilityAdvisoryNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Advisory> {
892
+ export class VulnerabilityAdvisoryNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Advisory> {
888
893
  normalize (data: Models.Vulnerability.Advisory, options: NormalizerOptions, elementName: string): SimpleXml.Element | undefined {
889
894
  const url = data.url.toString()
890
895
  if (!XmlSchema.isAnyURI(url)) {
@@ -912,7 +917,7 @@ class VulnerabilityAdvisoryNormalizer extends BaseXmlNormalizer<Models.Vulnerabi
912
917
  }
913
918
  }
914
919
 
915
- class VulnerabilityCreditsNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Credits> {
920
+ export class VulnerabilityCreditsNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Credits> {
916
921
  normalize (data: Models.Vulnerability.Credits, options: NormalizerOptions, elementName: string): SimpleXml.Element {
917
922
  const organizations: SimpleXml.Element | undefined = data.organizations.size > 0
918
923
  ? {
@@ -939,7 +944,7 @@ class VulnerabilityCreditsNormalizer extends BaseXmlNormalizer<Models.Vulnerabil
939
944
  }
940
945
  }
941
946
 
942
- class VulnerabilityAnalysisNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Analysis> {
947
+ export class VulnerabilityAnalysisNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Analysis> {
943
948
  normalize (data: Models.Vulnerability.Analysis, options: NormalizerOptions, elementName: string): SimpleXml.Element {
944
949
  const responses: SimpleXml.Element | undefined = data.response.size > 0
945
950
  ? {
@@ -965,7 +970,7 @@ class VulnerabilityAnalysisNormalizer extends BaseXmlNormalizer<Models.Vulnerabi
965
970
  }
966
971
  }
967
972
 
968
- class VulnerabilityAffectNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Affect> {
973
+ export class VulnerabilityAffectNormalizer extends BaseXmlNormalizer<Models.Vulnerability.Affect> {
969
974
  normalize (data: Models.Vulnerability.Affect, options: NormalizerOptions, elementName: string): SimpleXml.Element {
970
975
  const versions: SimpleXml.Element | undefined = data.versions.size > 0
971
976
  ? {
@@ -993,7 +998,7 @@ class VulnerabilityAffectNormalizer extends BaseXmlNormalizer<Models.Vulnerabili
993
998
  }
994
999
  }
995
1000
 
996
- class VulnerabilityAffectedVersionNormalizer extends BaseXmlNormalizer<Models.Vulnerability.AffectedVersion> {
1001
+ export class VulnerabilityAffectedVersionNormalizer extends BaseXmlNormalizer<Models.Vulnerability.AffectedVersion> {
997
1002
  normalize (data: Models.Vulnerability.AffectedVersion, options: NormalizerOptions, elementName: string): SimpleXml.Element {
998
1003
  switch (true) {
999
1004
  case data instanceof Models.Vulnerability.AffectedSingleVersion: