@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
|
@@ -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 { SimpleXml } from './types'
|
|
31
34
|
import { XmlSchema } from './types'
|
|
@@ -287,7 +290,7 @@ export class MetadataNormalizer extends BaseXmlNormalizer<Models.Metadata> {
|
|
|
287
290
|
|
|
288
291
|
export class LifecycleNormalizer extends BaseXmlNormalizer<Models.Lifecycle> {
|
|
289
292
|
normalize (data: Models.Lifecycle, options: NormalizerOptions, elementName: string): SimpleXml.Element {
|
|
290
|
-
return data instanceof
|
|
293
|
+
return data instanceof NamedLifecycle
|
|
291
294
|
? {
|
|
292
295
|
type: 'element',
|
|
293
296
|
name: elementName,
|
|
@@ -553,17 +556,17 @@ export class ComponentEvidenceNormalizer extends BaseXmlNormalizer<Models.Compon
|
|
|
553
556
|
export class LicenseNormalizer extends BaseXmlNormalizer<Models.License> {
|
|
554
557
|
normalize (data: Models.License, options: NormalizerOptions): SimpleXml.Element {
|
|
555
558
|
switch (true) {
|
|
556
|
-
case data instanceof
|
|
559
|
+
case data instanceof NamedLicense:
|
|
557
560
|
return this.#normalizeNamedLicense(data, options)
|
|
558
|
-
case data instanceof
|
|
561
|
+
case data instanceof SpdxLicense:
|
|
559
562
|
return isSupportedSpdxId(data.id)
|
|
560
563
|
? this.#normalizeSpdxLicense(data, options)
|
|
561
|
-
: this.#normalizeNamedLicense(new
|
|
564
|
+
: this.#normalizeNamedLicense(new NamedLicense(
|
|
562
565
|
// prevent information loss -> convert to broader type
|
|
563
566
|
data.id,
|
|
564
567
|
{ url: data.url }
|
|
565
568
|
), options)
|
|
566
|
-
case data instanceof
|
|
569
|
+
case data instanceof LicenseExpression:
|
|
567
570
|
return this.#normalizeLicenseExpression(data)
|
|
568
571
|
/* c8 ignore start */
|
|
569
572
|
default:
|
|
@@ -636,7 +639,7 @@ export class LicenseNormalizer extends BaseXmlNormalizer<Models.License> {
|
|
|
636
639
|
: Array.from(data)
|
|
637
640
|
|
|
638
641
|
if (licenses.length > 1) {
|
|
639
|
-
const expressions = licenses.filter(l => l instanceof
|
|
642
|
+
const expressions = licenses.filter(l => l instanceof LicenseExpression) as Models.LicenseExpression[]
|
|
640
643
|
if (expressions.length > 0) {
|
|
641
644
|
// could have thrown {@link RangeError} when there is more than one only {@link Models.LicenseExpression | LicenseExpression}.
|
|
642
645
|
// but let's be graceful and just normalize to the most relevant choice: any expression
|
|
@@ -1086,9 +1089,9 @@ export class VulnerabilityAffectNormalizer extends BaseXmlNormalizer<Models.Vuln
|
|
|
1086
1089
|
export class VulnerabilityAffectedVersionNormalizer extends BaseXmlNormalizer<Models.Vulnerability.AffectedVersion> {
|
|
1087
1090
|
normalize (data: Models.Vulnerability.AffectedVersion, options: NormalizerOptions, elementName: string): SimpleXml.Element {
|
|
1088
1091
|
switch (true) {
|
|
1089
|
-
case data instanceof
|
|
1092
|
+
case data instanceof AffectedSingleVersion:
|
|
1090
1093
|
return this.#normalizeAffectedSingleVersion(data, elementName)
|
|
1091
|
-
case data instanceof
|
|
1094
|
+
case data instanceof AffectedVersionRange:
|
|
1092
1095
|
return this.#normalizeAffectedVersionRange(data, elementName)
|
|
1093
1096
|
/* c8 ignore start */
|
|
1094
1097
|
default:
|
|
@@ -18,7 +18,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Bom } from '../models'
|
|
21
|
-
import { Format
|
|
21
|
+
import { Format } from '../spec/enums'
|
|
22
|
+
import { UnsupportedFormatError } from '../spec/errors'
|
|
22
23
|
import { BaseSerializer } from './baseSerializer'
|
|
23
24
|
import type { NormalizerOptions } from './types'
|
|
24
25
|
import type { Factory as NormalizerFactory } from './xml/normalize'
|
package/src/spec/consts.ts
CHANGED
|
@@ -17,7 +17,10 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { ComponentType
|
|
20
|
+
import { ComponentType } from '../enums/componentType'
|
|
21
|
+
import { ExternalReferenceType } from '../enums/externalReferenceType'
|
|
22
|
+
import { HashAlgorithm } from '../enums/hashAlogorithm'
|
|
23
|
+
import { RatingMethod as VulnerabilityRatingMethod } from '../enums/vulnerability/ratingMethod'
|
|
21
24
|
import type { _SpecProtocol } from './_protocol'
|
|
22
25
|
import { _Spec } from './_protocol'
|
|
23
26
|
import { Format, Version } from './enums'
|
|
@@ -204,11 +207,11 @@ export const Spec1dot4: Readonly<_SpecProtocol> = Object.freeze(new _Spec(
|
|
|
204
207
|
true,
|
|
205
208
|
true,
|
|
206
209
|
[
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
VulnerabilityRatingMethod.CVSSv2,
|
|
211
|
+
VulnerabilityRatingMethod.CVSSv3,
|
|
212
|
+
VulnerabilityRatingMethod.CVSSv31,
|
|
213
|
+
VulnerabilityRatingMethod.OWASP,
|
|
214
|
+
VulnerabilityRatingMethod.Other
|
|
212
215
|
],
|
|
213
216
|
true,
|
|
214
217
|
false,
|
|
@@ -301,13 +304,13 @@ export const Spec1dot5: Readonly<_SpecProtocol> = Object.freeze(new _Spec(
|
|
|
301
304
|
true,
|
|
302
305
|
true,
|
|
303
306
|
[
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
307
|
+
VulnerabilityRatingMethod.CVSSv2,
|
|
308
|
+
VulnerabilityRatingMethod.CVSSv3,
|
|
309
|
+
VulnerabilityRatingMethod.CVSSv31,
|
|
310
|
+
VulnerabilityRatingMethod.CVSSv4,
|
|
311
|
+
VulnerabilityRatingMethod.OWASP,
|
|
312
|
+
VulnerabilityRatingMethod.SSVC,
|
|
313
|
+
VulnerabilityRatingMethod.Other
|
|
311
314
|
],
|
|
312
315
|
true,
|
|
313
316
|
true,
|
|
@@ -405,13 +408,13 @@ export const Spec1dot6: Readonly<_SpecProtocol> = Object.freeze(new _Spec(
|
|
|
405
408
|
true,
|
|
406
409
|
true,
|
|
407
410
|
[
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
411
|
+
VulnerabilityRatingMethod.CVSSv2,
|
|
412
|
+
VulnerabilityRatingMethod.CVSSv3,
|
|
413
|
+
VulnerabilityRatingMethod.CVSSv31,
|
|
414
|
+
VulnerabilityRatingMethod.CVSSv4,
|
|
415
|
+
VulnerabilityRatingMethod.OWASP,
|
|
416
|
+
VulnerabilityRatingMethod.SSVC,
|
|
417
|
+
VulnerabilityRatingMethod.Other
|
|
415
418
|
],
|
|
416
419
|
true,
|
|
417
420
|
true,
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export class UnsupportedFormatError extends Error {
|
|
21
|
+
}
|