@cyclonedx/cyclonedx-library 1.3.4 → 1.4.2
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 +4 -2
- package/dist.node/builders/fromNodePackageJson.node.js +1 -1
- package/dist.node/builders/fromNodePackageJson.node.js.map +1 -1
- package/dist.node/builders/index.node.js.map +1 -1
- package/dist.node/factories/fromNodePackageJson.node.js +41 -2
- package/dist.node/factories/fromNodePackageJson.node.js.map +1 -1
- package/dist.node/factories/index.node.js.map +1 -1
- package/dist.node/factories/packageUrl.js +6 -3
- package/dist.node/factories/packageUrl.js.map +1 -1
- package/dist.node/helpers/packageUrl.js +28 -0
- package/dist.node/helpers/packageUrl.js.map +1 -0
- package/dist.node/helpers/tree.js +2 -2
- package/dist.node/helpers/tree.js.map +1 -1
- package/dist.node/index.common.js +50 -0
- package/dist.node/index.common.js.map +1 -0
- package/dist.node/index.node.js +5 -6
- package/dist.node/index.node.js.map +1 -1
- package/dist.node/models/bom.js +1 -1
- package/dist.node/models/bom.js.map +1 -1
- package/dist.node/models/component.js +5 -5
- package/dist.node/models/component.js.map +1 -1
- package/dist.node/models/metadata.js +1 -1
- package/dist.node/models/metadata.js.map +1 -1
- package/dist.node/models/tool.js +2 -2
- package/dist.node/models/tool.js.map +1 -1
- package/dist.node/serialize/index.common.js +4 -4
- package/dist.node/serialize/index.common.js.map +1 -1
- package/dist.node/serialize/index.node.js.map +1 -1
- package/dist.node/serialize/json/index.js +2 -2
- package/dist.node/serialize/json/index.js.map +1 -1
- package/dist.node/serialize/json/normalize.js +4 -4
- package/dist.node/serialize/json/normalize.js.map +1 -1
- package/dist.node/serialize/jsonSerializer.js.map +1 -1
- package/dist.node/serialize/xml/index.js +2 -2
- package/dist.node/serialize/xml/index.js.map +1 -1
- package/dist.node/serialize/xml/normalize.js +3 -3
- package/dist.node/serialize/xml/normalize.js.map +1 -1
- package/dist.node/serialize/xmlSerializer.node.js +1 -1
- package/dist.node/serialize/xmlSerializer.node.js.map +1 -1
- package/dist.web/lib.dev.js +133 -35
- package/dist.web/lib.dev.js.map +1 -1
- package/dist.web/lib.js +1 -1
- package/libs/universal-node-xml/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/builders/fromNodePackageJson.node.ts +3 -1
- package/src/builders/index.node.ts +1 -0
- package/src/factories/fromNodePackageJson.node.ts +55 -1
- package/src/factories/index.node.ts +5 -0
- package/src/factories/index.web.ts +6 -0
- package/src/factories/packageUrl.ts +10 -10
- package/src/helpers/packageUrl.ts +32 -0
- package/src/helpers/tree.ts +1 -1
- package/src/index.common.ts +25 -0
- package/src/index.node.ts +5 -6
- package/src/index.web.ts +6 -6
- package/src/models/bom.ts +1 -1
- package/src/models/component.ts +8 -8
- package/src/models/metadata.ts +2 -2
- package/src/models/tool.ts +2 -2
- package/src/serialize/baseSerializer.ts +1 -1
- package/src/serialize/index.common.ts +13 -2
- package/src/serialize/index.node.ts +4 -0
- package/src/serialize/index.web.ts +4 -0
- package/src/serialize/json/index.ts +1 -2
- package/src/serialize/json/normalize.ts +4 -4
- package/src/serialize/jsonSerializer.ts +1 -1
- package/src/serialize/xml/index.ts +1 -2
- package/src/serialize/xml/normalize.ts +3 -3
- package/src/serialize/xmlSerializer.node.ts +2 -2
- package/src/serialize/xmlSerializer.web.ts +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/**
|
|
21
|
+
* Known PURL qualifier names.
|
|
22
|
+
* To be used until {@link https://github.com/package-url/packageurl-js/pull/34} gets merged and released,
|
|
23
|
+
* and {@link https://github.com/package-url/packageurl-js/issues/35} gets sorted out.
|
|
24
|
+
*
|
|
25
|
+
* For the list/spec of the well-known keys,
|
|
26
|
+
* see {@link https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst#known-qualifiers-keyvalue-pairs}
|
|
27
|
+
*/
|
|
28
|
+
export const enum PackageUrlQualifierNames {
|
|
29
|
+
DownloadURL = 'download_url',
|
|
30
|
+
VcsUrl = 'vcs_url',
|
|
31
|
+
Checksum = 'checksum',
|
|
32
|
+
}
|
package/src/helpers/tree.ts
CHANGED
|
@@ -17,4 +17,4 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const treeIteratorSymbol = Symbol('iterator of a tree/nesting-like structure')
|
|
@@ -0,0 +1,25 @@
|
|
|
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 * as Enums from './enums'
|
|
21
|
+
export * as Models from './models'
|
|
22
|
+
export * as SPDX from './spdx'
|
|
23
|
+
export * as Spec from './spec'
|
|
24
|
+
export * as Types from './types'
|
|
25
|
+
// do not export the helpers, they are for internal use only
|
package/src/index.node.ts
CHANGED
|
@@ -17,16 +17,15 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
export * from './index.common'
|
|
21
|
+
|
|
22
|
+
// region node-specifics
|
|
23
|
+
|
|
20
24
|
export * as Builders from './builders/index.node'
|
|
21
|
-
export * as Enums from './enums'
|
|
22
25
|
export * as Factories from './factories/index.node'
|
|
23
|
-
export * as Models from './models'
|
|
24
26
|
export * as Serialize from './serialize/index.node'
|
|
25
|
-
export * as SPDX from './spdx'
|
|
26
|
-
export * as Spec from './spec'
|
|
27
|
-
export * as Types from './types'
|
|
28
27
|
|
|
29
28
|
/** @internal until the resources-module was finalized and showed value */
|
|
30
29
|
export * as _Resources from './resources.node'
|
|
31
30
|
|
|
32
|
-
//
|
|
31
|
+
// endregion node-specifics
|
package/src/index.web.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
|
-
export *
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export * from './index.common'
|
|
21
|
+
|
|
22
|
+
// region web-specifics
|
|
23
|
+
|
|
24
24
|
export * as Factories from './factories/index.web'
|
|
25
|
-
export * as Spec from './spec'
|
|
26
25
|
export * as Serialize from './serialize/index.web'
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
// endregion web-specifics
|
package/src/models/bom.ts
CHANGED
|
@@ -18,8 +18,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { isPositiveInteger, isUrnUuid, PositiveInteger, UrnUuid } from '../types'
|
|
21
|
-
import { Metadata } from './metadata'
|
|
22
21
|
import { ComponentRepository } from './component'
|
|
22
|
+
import { Metadata } from './metadata'
|
|
23
23
|
|
|
24
24
|
interface OptionalProperties {
|
|
25
25
|
metadata?: Bom['metadata']
|
package/src/models/component.ts
CHANGED
|
@@ -19,17 +19,17 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import { PackageURL } from 'packageurl-js'
|
|
21
21
|
|
|
22
|
-
import { CPE, isCPE } from '../types'
|
|
23
22
|
import { ComponentScope, ComponentType } from '../enums'
|
|
23
|
+
import { Comparable, SortableSet } from '../helpers/sortableSet'
|
|
24
|
+
import { treeIteratorSymbol } from '../helpers/tree'
|
|
25
|
+
import { CPE, isCPE } from '../types'
|
|
24
26
|
import { BomRef, BomRefRepository } from './bomRef'
|
|
25
|
-
import { HashRepository } from './hash'
|
|
26
|
-
import { OrganizationalEntity } from './organizationalEntity'
|
|
27
27
|
import { ExternalReferenceRepository } from './externalReference'
|
|
28
|
+
import { HashRepository } from './hash'
|
|
28
29
|
import { LicenseRepository } from './license'
|
|
29
|
-
import {
|
|
30
|
+
import { OrganizationalEntity } from './organizationalEntity'
|
|
30
31
|
import { PropertyRepository } from './property'
|
|
31
|
-
import {
|
|
32
|
-
import { treeIterator } from '../helpers/tree'
|
|
32
|
+
import { SWID } from './swid'
|
|
33
33
|
|
|
34
34
|
interface OptionalProperties {
|
|
35
35
|
bomRef?: BomRef['value']
|
|
@@ -142,10 +142,10 @@ export class Component implements Comparable {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export class ComponentRepository extends SortableSet<Component> {
|
|
145
|
-
* [
|
|
145
|
+
* [treeIteratorSymbol] (): Generator<Component> {
|
|
146
146
|
for (const component of this) {
|
|
147
147
|
yield component
|
|
148
|
-
yield * component.components[
|
|
148
|
+
yield * component.components[treeIteratorSymbol]()
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
package/src/models/metadata.ts
CHANGED
|
@@ -18,9 +18,9 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { Component } from './component'
|
|
21
|
-
import { ToolRepository } from './tool'
|
|
22
|
-
import { OrganizationalEntity } from './organizationalEntity'
|
|
23
21
|
import { OrganizationalContactRepository } from './organizationalContact'
|
|
22
|
+
import { OrganizationalEntity } from './organizationalEntity'
|
|
23
|
+
import { ToolRepository } from './tool'
|
|
24
24
|
|
|
25
25
|
interface OptionalProperties {
|
|
26
26
|
timestamp?: Metadata['timestamp']
|
package/src/models/tool.ts
CHANGED
|
@@ -17,9 +17,9 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { HashRepository } from './hash'
|
|
21
|
-
import { ExternalReferenceRepository } from './externalReference'
|
|
22
20
|
import { Comparable, SortableSet } from '../helpers/sortableSet'
|
|
21
|
+
import { ExternalReferenceRepository } from './externalReference'
|
|
22
|
+
import { HashRepository } from './hash'
|
|
23
23
|
|
|
24
24
|
interface OptionalProperties {
|
|
25
25
|
vendor?: Tool['vendor']
|
|
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { Bom, BomRef, Component } from '../models'
|
|
21
21
|
import { BomRefDiscriminator } from './bomRefDiscriminator'
|
|
22
22
|
import { NormalizerOptions, Serializer, SerializerOptions } from './types'
|
|
23
23
|
|
|
@@ -17,19 +17,30 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
// not everything is public, yet
|
|
20
|
+
// !!! not everything is public, yet
|
|
21
21
|
|
|
22
|
+
export * from './bomRefDiscriminator'
|
|
22
23
|
export * as Types from './types'
|
|
23
24
|
|
|
25
|
+
// region base
|
|
26
|
+
|
|
24
27
|
export * from './baseSerializer'
|
|
25
28
|
// export * from './baseDeserializer' // TODO
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
// endregion base
|
|
31
|
+
|
|
32
|
+
// region JSON
|
|
28
33
|
|
|
29
34
|
export * as JSON from './json'
|
|
30
35
|
export * from './jsonSerializer'
|
|
31
36
|
// export * from './jsonDeserializer' // TODO
|
|
32
37
|
|
|
38
|
+
// endregion JSON
|
|
39
|
+
|
|
40
|
+
// region XML
|
|
41
|
+
|
|
33
42
|
export * as XML from './xml'
|
|
34
43
|
export * from './xmlBaseSerializer'
|
|
35
44
|
// export * from './xmlBaseDeserializer' // TODO
|
|
45
|
+
|
|
46
|
+
// endregion XML
|
|
@@ -17,7 +17,6 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export * as Types from './types'
|
|
21
|
-
|
|
22
20
|
export * as Normalize from './normalize'
|
|
21
|
+
export * as Types from './types'
|
|
23
22
|
// export * as Denormalize from './denormalize' // TODO
|
|
@@ -19,11 +19,11 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import { isNotUndefined } from '../../helpers/notUndefined'
|
|
21
21
|
import { Stringable } from '../../helpers/stringable'
|
|
22
|
+
import { treeIteratorSymbol } from '../../helpers/tree'
|
|
22
23
|
import * as Models from '../../models'
|
|
23
24
|
import { Protocol as Spec, Version as SpecVersion } from '../../spec'
|
|
24
25
|
import { NormalizerOptions } from '../types'
|
|
25
26
|
import { JsonSchema, Normalized } from './types'
|
|
26
|
-
import { treeIterator } from '../../helpers/tree'
|
|
27
27
|
|
|
28
28
|
export class Factory {
|
|
29
29
|
readonly #spec: Spec
|
|
@@ -193,7 +193,7 @@ export class HashNormalizer extends Base {
|
|
|
193
193
|
return spec.supportsHashAlgorithm(algorithm) && spec.supportsHashValue(content)
|
|
194
194
|
? {
|
|
195
195
|
alg: algorithm,
|
|
196
|
-
content
|
|
196
|
+
content
|
|
197
197
|
}
|
|
198
198
|
: undefined
|
|
199
199
|
}
|
|
@@ -429,11 +429,11 @@ export class DependencyGraphNormalizer extends Base {
|
|
|
429
429
|
const allRefs = new Map<Models.BomRef, Models.BomRefRepository>()
|
|
430
430
|
if (data.metadata.component !== undefined) {
|
|
431
431
|
allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies)
|
|
432
|
-
for (const component of data.metadata.component.components[
|
|
432
|
+
for (const component of data.metadata.component.components[treeIteratorSymbol]()) {
|
|
433
433
|
allRefs.set(component.bomRef, component.dependencies)
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
|
-
for (const component of data.components[
|
|
436
|
+
for (const component of data.components[treeIteratorSymbol]()) {
|
|
437
437
|
allRefs.set(component.bomRef, component.dependencies)
|
|
438
438
|
}
|
|
439
439
|
|
|
@@ -19,10 +19,10 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import { Bom } from '../models'
|
|
21
21
|
import { Format, UnsupportedFormatError } from '../spec'
|
|
22
|
-
import { NormalizerOptions, SerializerOptions } from './types'
|
|
23
22
|
import { BaseSerializer } from './baseSerializer'
|
|
24
23
|
import { Factory as NormalizerFactory } from './json/normalize'
|
|
25
24
|
import { Normalized } from './json/types'
|
|
25
|
+
import { NormalizerOptions, SerializerOptions } from './types'
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Multi purpose Json serializer.
|
|
@@ -17,7 +17,6 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export * as Types from './types'
|
|
21
|
-
|
|
22
20
|
export * as Normalize from './normalize'
|
|
21
|
+
export * as Types from './types'
|
|
23
22
|
// export * as Denormalize from './denormalize' // TODO
|
|
@@ -19,11 +19,11 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import { isNotUndefined } from '../../helpers/notUndefined'
|
|
21
21
|
import { Stringable } from '../../helpers/stringable'
|
|
22
|
+
import { treeIteratorSymbol } from '../../helpers/tree'
|
|
22
23
|
import * as Models from '../../models'
|
|
23
24
|
import { Protocol as Spec, Version as SpecVersion } from '../../spec'
|
|
24
25
|
import { NormalizerOptions } from '../types'
|
|
25
26
|
import { SimpleXml, XmlSchema } from './types'
|
|
26
|
-
import { treeIterator } from '../../helpers/tree'
|
|
27
27
|
|
|
28
28
|
export class Factory {
|
|
29
29
|
readonly #spec: Spec
|
|
@@ -558,11 +558,11 @@ export class DependencyGraphNormalizer extends Base {
|
|
|
558
558
|
const allRefs = new Map<Models.BomRef, Models.BomRefRepository>()
|
|
559
559
|
if (data.metadata.component !== undefined) {
|
|
560
560
|
allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies)
|
|
561
|
-
for (const component of data.metadata.component.components[
|
|
561
|
+
for (const component of data.metadata.component.components[treeIteratorSymbol]()) {
|
|
562
562
|
allRefs.set(component.bomRef, component.dependencies)
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
for (const component of data.components[
|
|
565
|
+
for (const component of data.components[treeIteratorSymbol]()) {
|
|
566
566
|
allRefs.set(component.bomRef, component.dependencies)
|
|
567
567
|
}
|
|
568
568
|
|
|
@@ -17,10 +17,10 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
17
17
|
Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
import { stringifyFallback } from '../../libs/universal-node-xml'
|
|
20
21
|
import { SerializerOptions } from './types'
|
|
21
|
-
import { XmlBaseSerializer } from './xmlBaseSerializer'
|
|
22
22
|
import { SimpleXml } from './xml/types'
|
|
23
|
-
import {
|
|
23
|
+
import { XmlBaseSerializer } from './xmlBaseSerializer'
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* XML serializer for node.
|
|
@@ -19,8 +19,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
19
19
|
|
|
20
20
|
import { isNotUndefined } from '../helpers/notUndefined'
|
|
21
21
|
import { SerializerOptions } from './types'
|
|
22
|
-
import { XmlBaseSerializer } from './xmlBaseSerializer'
|
|
23
22
|
import { SimpleXml } from './xml/types'
|
|
23
|
+
import { XmlBaseSerializer } from './xmlBaseSerializer'
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* XML serializer for web browsers.
|