@cyclonedx/cyclonedx-library 1.0.2 → 1.2.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 (49) hide show
  1. package/README.md +2 -1
  2. package/dist.node/builders/{fromPackageJson.node.js → fromNodePackageJson.node.js} +10 -1
  3. package/dist.node/builders/fromNodePackageJson.node.js.map +1 -0
  4. package/dist.node/builders/index.node.js +3 -2
  5. package/dist.node/builders/index.node.js.map +1 -1
  6. package/dist.node/factories/{fromPackageJson.node.js → fromNodePackageJson.node.js} +1 -1
  7. package/dist.node/factories/fromNodePackageJson.node.js.map +1 -0
  8. package/dist.node/factories/index.node.js +3 -2
  9. package/dist.node/factories/index.node.js.map +1 -1
  10. package/dist.node/factories/packageUrl.js +17 -5
  11. package/dist.node/factories/packageUrl.js.map +1 -1
  12. package/dist.node/helpers/tree.js +23 -0
  13. package/dist.node/helpers/tree.js.map +1 -0
  14. package/dist.node/models/component.js +8 -0
  15. package/dist.node/models/component.js.map +1 -1
  16. package/dist.node/serialize/bomRefDiscriminator.js +3 -0
  17. package/dist.node/serialize/bomRefDiscriminator.js.map +1 -1
  18. package/dist.node/serialize/json/normalize.js +18 -4
  19. package/dist.node/serialize/json/normalize.js.map +1 -1
  20. package/dist.node/serialize/jsonSerializer.js +3 -0
  21. package/dist.node/serialize/jsonSerializer.js.map +1 -1
  22. package/dist.node/serialize/xml/normalize.js +24 -5
  23. package/dist.node/serialize/xml/normalize.js.map +1 -1
  24. package/dist.node/serialize/xmlBaseSerializer.js +3 -0
  25. package/dist.node/serialize/xmlBaseSerializer.js.map +1 -1
  26. package/dist.node/spec.js +11 -6
  27. package/dist.node/spec.js.map +1 -1
  28. package/dist.node/types/cpe.js +1 -1
  29. package/dist.node/types/cpe.js.map +1 -1
  30. package/dist.web/lib.dev.js +120 -21
  31. package/dist.web/lib.dev.js.map +1 -1
  32. package/dist.web/lib.js +1 -1
  33. package/package.json +4 -2
  34. package/src/builders/{fromPackageJson.node.ts → fromNodePackageJson.node.ts} +16 -4
  35. package/src/builders/index.node.ts +4 -1
  36. package/src/factories/{fromPackageJson.node.ts → fromNodePackageJson.node.ts} +0 -0
  37. package/src/factories/index.node.ts +4 -1
  38. package/src/factories/packageUrl.ts +31 -8
  39. package/src/helpers/tree.ts +20 -0
  40. package/src/models/component.ts +10 -0
  41. package/src/serialize/bomRefDiscriminator.ts +5 -0
  42. package/src/serialize/json/normalize.ts +19 -5
  43. package/src/serialize/jsonSerializer.ts +4 -0
  44. package/src/serialize/xml/normalize.ts +30 -9
  45. package/src/serialize/xmlBaseSerializer.ts +4 -0
  46. package/src/spec.ts +16 -4
  47. package/src/types/cpe.ts +2 -2
  48. package/dist.node/builders/fromPackageJson.node.js.map +0 -1
  49. package/dist.node/factories/fromPackageJson.node.js.map +0 -1
package/dist.node/spec.js CHANGED
@@ -28,7 +28,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
28
28
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
29
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
30
  };
31
- var _Spec_version, _Spec_formats, _Spec_componentTypes, _Spec_hashAlgorithms, _Spec_hashValuePattern, _Spec_externalReferenceTypes, _Spec_supportsDependencyGraph, _Spec_supportsToolReferences;
31
+ var _Spec_version, _Spec_formats, _Spec_componentTypes, _Spec_hashAlgorithms, _Spec_hashValuePattern, _Spec_externalReferenceTypes, _Spec_supportsDependencyGraph, _Spec_supportsToolReferences, _Spec_requiresComponentVersion;
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.SpecVersionDict = exports.Spec1dot4 = exports.Spec1dot3 = exports.Spec1dot2 = exports.UnsupportedFormatError = exports.Format = exports.Version = void 0;
34
34
  const enums_1 = require("./enums");
@@ -49,7 +49,7 @@ class UnsupportedFormatError extends Error {
49
49
  }
50
50
  exports.UnsupportedFormatError = UnsupportedFormatError;
51
51
  class Spec {
52
- constructor(version, formats, componentTypes, hashAlgorithms, hashValuePattern, externalReferenceTypes, supportsDependencyGraph, supportsToolReferences) {
52
+ constructor(version, formats, componentTypes, hashAlgorithms, hashValuePattern, externalReferenceTypes, supportsDependencyGraph, supportsToolReferences, requiresComponentVersion) {
53
53
  _Spec_version.set(this, void 0);
54
54
  _Spec_formats.set(this, void 0);
55
55
  _Spec_componentTypes.set(this, void 0);
@@ -58,6 +58,7 @@ class Spec {
58
58
  _Spec_externalReferenceTypes.set(this, void 0);
59
59
  _Spec_supportsDependencyGraph.set(this, void 0);
60
60
  _Spec_supportsToolReferences.set(this, void 0);
61
+ _Spec_requiresComponentVersion.set(this, void 0);
61
62
  __classPrivateFieldSet(this, _Spec_version, version, "f");
62
63
  __classPrivateFieldSet(this, _Spec_formats, new Set(formats), "f");
63
64
  __classPrivateFieldSet(this, _Spec_componentTypes, new Set(componentTypes), "f");
@@ -66,6 +67,7 @@ class Spec {
66
67
  __classPrivateFieldSet(this, _Spec_externalReferenceTypes, new Set(externalReferenceTypes), "f");
67
68
  __classPrivateFieldSet(this, _Spec_supportsDependencyGraph, supportsDependencyGraph, "f");
68
69
  __classPrivateFieldSet(this, _Spec_supportsToolReferences, supportsToolReferences, "f");
70
+ __classPrivateFieldSet(this, _Spec_requiresComponentVersion, requiresComponentVersion, "f");
69
71
  }
70
72
  get version() {
71
73
  return __classPrivateFieldGet(this, _Spec_version, "f");
@@ -92,8 +94,11 @@ class Spec {
92
94
  get supportsToolReferences() {
93
95
  return __classPrivateFieldGet(this, _Spec_supportsToolReferences, "f");
94
96
  }
97
+ get requiresComponentVersion() {
98
+ return __classPrivateFieldGet(this, _Spec_requiresComponentVersion, "f");
99
+ }
95
100
  }
96
- _Spec_version = new WeakMap(), _Spec_formats = new WeakMap(), _Spec_componentTypes = new WeakMap(), _Spec_hashAlgorithms = new WeakMap(), _Spec_hashValuePattern = new WeakMap(), _Spec_externalReferenceTypes = new WeakMap(), _Spec_supportsDependencyGraph = new WeakMap(), _Spec_supportsToolReferences = new WeakMap();
101
+ _Spec_version = new WeakMap(), _Spec_formats = new WeakMap(), _Spec_componentTypes = new WeakMap(), _Spec_hashAlgorithms = new WeakMap(), _Spec_hashValuePattern = new WeakMap(), _Spec_externalReferenceTypes = new WeakMap(), _Spec_supportsDependencyGraph = new WeakMap(), _Spec_supportsToolReferences = new WeakMap(), _Spec_requiresComponentVersion = new WeakMap();
97
102
  exports.Spec1dot2 = Object.freeze(new Spec(Version.v1dot2, [
98
103
  Format.XML,
99
104
  Format.JSON
@@ -135,7 +140,7 @@ exports.Spec1dot2 = Object.freeze(new Spec(Version.v1dot2, [
135
140
  enums_1.ExternalReferenceType.BuildMeta,
136
141
  enums_1.ExternalReferenceType.BuildSystem,
137
142
  enums_1.ExternalReferenceType.Other
138
- ], true, false));
143
+ ], true, false, true));
139
144
  exports.Spec1dot3 = Object.freeze(new Spec(Version.v1dot3, [
140
145
  Format.XML,
141
146
  Format.JSON
@@ -177,7 +182,7 @@ exports.Spec1dot3 = Object.freeze(new Spec(Version.v1dot3, [
177
182
  enums_1.ExternalReferenceType.BuildMeta,
178
183
  enums_1.ExternalReferenceType.BuildSystem,
179
184
  enums_1.ExternalReferenceType.Other
180
- ], true, false));
185
+ ], true, false, true));
181
186
  exports.Spec1dot4 = Object.freeze(new Spec(Version.v1dot4, [
182
187
  Format.XML,
183
188
  Format.JSON
@@ -220,7 +225,7 @@ exports.Spec1dot4 = Object.freeze(new Spec(Version.v1dot4, [
220
225
  enums_1.ExternalReferenceType.BuildSystem,
221
226
  enums_1.ExternalReferenceType.ReleaseNotes,
222
227
  enums_1.ExternalReferenceType.Other
223
- ], true, true));
228
+ ], true, true, false));
224
229
  exports.SpecVersionDict = Object.freeze(Object.fromEntries([
225
230
  [Version.v1dot2, exports.Spec1dot2],
226
231
  [Version.v1dot3, exports.Spec1dot3],
@@ -1 +1 @@
1
- {"version":3,"file":"spec.js","sourceRoot":"","sources":["../src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IAC5B,qBAAa,CAAC,aAAa,CAAC;IAC5B,qBAAa,CAAC,aAAa,CAAC;IAC5B,qBAAa,CAAC,MAAM;CACrB,EACD,sGAAsG,EACtG;IACE,6BAAqB,CAAC,GAAG;IACzB,6BAAqB,CAAC,YAAY;IAClC,6BAAqB,CAAC,OAAO;IAC7B,6BAAqB,CAAC,UAAU;IAChC,6BAAqB,CAAC,GAAG;IACzB,6BAAqB,CAAC,WAAW;IACjC,6BAAqB,CAAC,MAAM;IAC5B,6BAAqB,CAAC,IAAI;IAC1B,6BAAqB,CAAC,aAAa;IACnC,6BAAqB,CAAC,OAAO;IAC7B,6BAAqB,CAAC,YAAY;IAClC,6BAAqB,CAAC,OAAO;IAC7B,6BAAqB,CAAC,SAAS;IAC/B,6BAAqB,CAAC,WAAW;IACjC,6BAAqB,CAAC,YAAY;IAClC,6BAAqB,CAAC,KAAK;CAC5B,EACD,IAAI,EACJ,IAAI,EACJ,KAAK,CACN,CAAC,CAAA;AAEW,QAAA,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;IAC9D,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAS,CAAC;IAC3B,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAS,CAAC;IAC3B,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAS,CAAC;CAC5B,CAA8C,CAAC,CAAA"}
@@ -19,7 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.isCPE = void 0;
22
- const cpePattern = /^([c][pP][eE]:\/[AHOaho]?(:[A-Za-z0-9\._\-~%]*){0,6})$|^(cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4})$/;
22
+ const cpePattern = /^([c][pP][eE]:\/[AHOaho]?(:[A-Za-z0-9\._\-~%]*){0,6})$|^(cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4})$/;
23
23
  function isCPE(value) {
24
24
  return typeof value === 'string' &&
25
25
  cpePattern.test(value);
@@ -1 +1 @@
1
- {"version":3,"file":"cpe.js","sourceRoot":"","sources":["../../src/types/cpe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAUF,MAAM,UAAU,GAAG,gXAAgX,CAAA;AAEnY,SAAgB,KAAK,CAAE,KAAU;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC1B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAHD,sBAGC"}
1
+ {"version":3,"file":"cpe.js","sourceRoot":"","sources":["../../src/types/cpe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAUF,MAAM,UAAU,GAAG,kVAAkV,CAAA;AAErW,SAAgB,KAAK,CAAE,KAAU;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC1B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAHD,sBAGC"}
@@ -473,15 +473,27 @@ class PackageUrlFactory {
473
473
  _PackageUrlFactory_type.set(this, void 0);
474
474
  __classPrivateFieldSet(this, _PackageUrlFactory_type, type, "f");
475
475
  }
476
- makeFromComponent(component) {
476
+ get type() {
477
+ return __classPrivateFieldGet(this, _PackageUrlFactory_type, "f");
478
+ }
479
+ makeFromComponent(component, sort = false) {
477
480
  const qualifiers = {};
478
481
  let subpath;
479
- for (const e of component.externalReferences) {
480
- if (e.type === enums_1.ExternalReferenceType.VCS) {
481
- [qualifiers.vcs_url, subpath] = e.url.toString().split('#', 2);
482
- break;
482
+ const extRefs = component.externalReferences;
483
+ for (const extRef of (sort ? extRefs.sorted() : extRefs)) {
484
+ switch (extRef.type) {
485
+ case enums_1.ExternalReferenceType.VCS:
486
+ [qualifiers.vcs_url, subpath] = extRef.url.toString().split('#', 2);
487
+ break;
488
+ case enums_1.ExternalReferenceType.Distribution:
489
+ qualifiers.download_url = extRef.url.toString();
490
+ break;
483
491
  }
484
492
  }
493
+ const hashes = component.hashes;
494
+ if (hashes.size > 0) {
495
+ qualifiers.checksum = Array.from(sort ? hashes.sorted() : hashes, ([hashAlgo, hashCont]) => `${hashAlgo.toLowerCase()}:${hashCont.toLowerCase()}`).join(',');
496
+ }
485
497
  try {
486
498
  return new packageurl_js_1.PackageURL(__classPrivateFieldGet(this, _PackageUrlFactory_type, "f"), component.group, component.name, component.version, qualifiers, subpath);
487
499
  }
@@ -566,6 +578,38 @@ class SortableSet extends Set {
566
578
  exports.SortableSet = SortableSet;
567
579
 
568
580
 
581
+ /***/ }),
582
+
583
+ /***/ "./src/helpers/tree.ts":
584
+ /*!*****************************!*\
585
+ !*** ./src/helpers/tree.ts ***!
586
+ \*****************************/
587
+ /***/ ((__unused_webpack_module, exports) => {
588
+
589
+
590
+ /*!
591
+ This file is part of CycloneDX JavaScript Library.
592
+
593
+ Licensed under the Apache License, Version 2.0 (the "License");
594
+ you may not use this file except in compliance with the License.
595
+ You may obtain a copy of the License at
596
+
597
+ http://www.apache.org/licenses/LICENSE-2.0
598
+
599
+ Unless required by applicable law or agreed to in writing, software
600
+ distributed under the License is distributed on an "AS IS" BASIS,
601
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
602
+ See the License for the specific language governing permissions and
603
+ limitations under the License.
604
+
605
+ SPDX-License-Identifier: Apache-2.0
606
+ Copyright (c) OWASP Foundation. All Rights Reserved.
607
+ */
608
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
609
+ exports.treeIterator = void 0;
610
+ exports.treeIterator = Symbol('iterator of a tree/nesting-like structure');
611
+
612
+
569
613
  /***/ }),
570
614
 
571
615
  /***/ "./src/index.web.ts":
@@ -835,6 +879,7 @@ const hash_1 = __webpack_require__(/*! ./hash */ "./src/models/hash.ts");
835
879
  const externalReference_1 = __webpack_require__(/*! ./externalReference */ "./src/models/externalReference.ts");
836
880
  const license_1 = __webpack_require__(/*! ./license */ "./src/models/license.ts");
837
881
  const sortableSet_1 = __webpack_require__(/*! ../helpers/sortableSet */ "./src/helpers/sortableSet.ts");
882
+ const tree_1 = __webpack_require__(/*! ../helpers/tree */ "./src/helpers/tree.ts");
838
883
  class Component {
839
884
  constructor(type, name, op = {}) {
840
885
  _Component_bomRef.set(this, void 0);
@@ -856,6 +901,7 @@ class Component {
856
901
  this.version = op.version;
857
902
  this.description = op.description;
858
903
  this.dependencies = op.dependencies ?? new bomRef_1.BomRefRepository();
904
+ this.components = op.components ?? new ComponentRepository();
859
905
  this.cpe = op.cpe;
860
906
  }
861
907
  get bomRef() {
@@ -889,6 +935,12 @@ class Component {
889
935
  exports.Component = Component;
890
936
  _Component_bomRef = new WeakMap(), _Component_cpe = new WeakMap();
891
937
  class ComponentRepository extends sortableSet_1.SortableSet {
938
+ *[tree_1.treeIterator]() {
939
+ for (const component of this) {
940
+ yield component;
941
+ yield* component.components[tree_1.treeIterator]();
942
+ }
943
+ }
892
944
  }
893
945
  exports.ComponentRepository = ComponentRepository;
894
946
 
@@ -1531,6 +1583,9 @@ class BomRefDiscriminator {
1531
1583
  __classPrivateFieldSet(this, _BomRefDiscriminator_originalValues, new Map(Array.from(bomRefs).map(ref => [ref, ref.value])), "f");
1532
1584
  __classPrivateFieldSet(this, _BomRefDiscriminator_prefix, prefix, "f");
1533
1585
  }
1586
+ get prefix() {
1587
+ return __classPrivateFieldGet(this, _BomRefDiscriminator_prefix, "f");
1588
+ }
1534
1589
  [(_BomRefDiscriminator_originalValues = new WeakMap(), _BomRefDiscriminator_prefix = new WeakMap(), _BomRefDiscriminator_instances = new WeakSet(), Symbol.iterator)]() {
1535
1590
  return __classPrivateFieldGet(this, _BomRefDiscriminator_originalValues, "f").keys();
1536
1591
  }
@@ -1791,6 +1846,7 @@ const notUndefined_1 = __webpack_require__(/*! ../../helpers/notUndefined */ "./
1791
1846
  const Models = __importStar(__webpack_require__(/*! ../../models */ "./src/models/index.ts"));
1792
1847
  const spec_1 = __webpack_require__(/*! ../../spec */ "./src/spec.ts");
1793
1848
  const types_1 = __webpack_require__(/*! ./types */ "./src/serialize/json/types.ts");
1849
+ const tree_1 = __webpack_require__(/*! ../../helpers/tree */ "./src/helpers/tree.ts");
1794
1850
  class Factory {
1795
1851
  constructor(spec) {
1796
1852
  _Factory_spec.set(this, void 0);
@@ -1847,6 +1903,9 @@ class Base {
1847
1903
  constructor(factory) {
1848
1904
  this._factory = factory;
1849
1905
  }
1906
+ get factory() {
1907
+ return this._factory;
1908
+ }
1850
1909
  }
1851
1910
  class BomNormalizer extends Base {
1852
1911
  normalize(data, options) {
@@ -1964,12 +2023,16 @@ class OrganizationalEntityNormalizer extends Base {
1964
2023
  exports.OrganizationalEntityNormalizer = OrganizationalEntityNormalizer;
1965
2024
  class ComponentNormalizer extends Base {
1966
2025
  normalize(data, options) {
1967
- return this._factory.spec.supportsComponentType(data.type)
2026
+ const spec = this._factory.spec;
2027
+ const version = data.version ?? '';
2028
+ return spec.supportsComponentType(data.type)
1968
2029
  ? {
1969
2030
  type: data.type,
1970
2031
  name: data.name,
1971
2032
  group: data.group || undefined,
1972
- version: data.version || '',
2033
+ version: version.length > 0 || spec.requiresComponentVersion
2034
+ ? version
2035
+ : undefined,
1973
2036
  'bom-ref': data.bomRef.value || undefined,
1974
2037
  supplier: data.supplier === undefined
1975
2038
  ? undefined
@@ -1992,6 +2055,9 @@ class ComponentNormalizer extends Base {
1992
2055
  : this._factory.makeForSWID().normalize(data.swid, options),
1993
2056
  externalReferences: data.externalReferences.size > 0
1994
2057
  ? this._factory.makeForExternalReference().normalizeRepository(data.externalReferences, options)
2058
+ : undefined,
2059
+ components: data.components.size > 0
2060
+ ? this.normalizeRepository(data.components, options)
1995
2061
  : undefined
1996
2062
  }
1997
2063
  : undefined;
@@ -2107,9 +2173,12 @@ class DependencyGraphNormalizer extends Base {
2107
2173
  const allRefs = new Map();
2108
2174
  if (data.metadata.component !== undefined) {
2109
2175
  allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies);
2176
+ for (const component of data.metadata.component.components[tree_1.treeIterator]()) {
2177
+ allRefs.set(component.bomRef, component.dependencies);
2178
+ }
2110
2179
  }
2111
- for (const c of data.components) {
2112
- allRefs.set(c.bomRef, new Models.BomRefRepository(c.dependencies));
2180
+ for (const component of data.components[tree_1.treeIterator]()) {
2181
+ allRefs.set(component.bomRef, component.dependencies);
2113
2182
  }
2114
2183
  const normalized = [];
2115
2184
  for (const [ref, deps] of allRefs) {
@@ -2243,6 +2312,9 @@ class JsonSerializer extends baseSerializer_1.BaseSerializer {
2243
2312
  _JsonSerializer_normalizerFactory.set(this, void 0);
2244
2313
  __classPrivateFieldSet(this, _JsonSerializer_normalizerFactory, normalizerFactory, "f");
2245
2314
  }
2315
+ get normalizerFactory() {
2316
+ return __classPrivateFieldGet(this, _JsonSerializer_normalizerFactory, "f");
2317
+ }
2246
2318
  _normalize(bom, options = {}) {
2247
2319
  return __classPrivateFieldGet(this, _JsonSerializer_normalizerFactory, "f").makeForBom()
2248
2320
  .normalize(bom, options);
@@ -2409,6 +2481,7 @@ const notUndefined_1 = __webpack_require__(/*! ../../helpers/notUndefined */ "./
2409
2481
  const Models = __importStar(__webpack_require__(/*! ../../models */ "./src/models/index.ts"));
2410
2482
  const spec_1 = __webpack_require__(/*! ../../spec */ "./src/spec.ts");
2411
2483
  const types_1 = __webpack_require__(/*! ./types */ "./src/serialize/xml/types.ts");
2484
+ const tree_1 = __webpack_require__(/*! ../../helpers/tree */ "./src/helpers/tree.ts");
2412
2485
  class Factory {
2413
2486
  constructor(spec) {
2414
2487
  _Factory_spec.set(this, void 0);
@@ -2465,6 +2538,9 @@ class Base {
2465
2538
  constructor(factory) {
2466
2539
  this._factory = factory;
2467
2540
  }
2541
+ get factory() {
2542
+ return this._factory;
2543
+ }
2468
2544
  }
2469
2545
  class BomNormalizer extends Base {
2470
2546
  normalize(data, options) {
@@ -2633,12 +2709,16 @@ class OrganizationalEntityNormalizer extends Base {
2633
2709
  exports.OrganizationalEntityNormalizer = OrganizationalEntityNormalizer;
2634
2710
  class ComponentNormalizer extends Base {
2635
2711
  normalize(data, options, elementName) {
2636
- if (!this._factory.spec.supportsComponentType(data.type)) {
2712
+ const spec = this._factory.spec;
2713
+ if (!spec.supportsComponentType(data.type)) {
2637
2714
  return undefined;
2638
2715
  }
2639
2716
  const supplier = data.supplier === undefined
2640
2717
  ? undefined
2641
2718
  : this._factory.makeForOrganizationalEntity().normalize(data.supplier, options, 'supplier');
2719
+ const version = (spec.requiresComponentVersion
2720
+ ? makeTextElement
2721
+ : makeOptionalTextElement)(data.version ?? '', 'version');
2642
2722
  const hashes = data.hashes.size > 0
2643
2723
  ? {
2644
2724
  type: 'element',
@@ -2664,6 +2744,13 @@ class ComponentNormalizer extends Base {
2664
2744
  .normalizeRepository(data.externalReferences, options, 'reference')
2665
2745
  }
2666
2746
  : undefined;
2747
+ const components = data.components.size > 0
2748
+ ? {
2749
+ type: 'element',
2750
+ name: 'components',
2751
+ children: this.normalizeRepository(data.components, options, 'component')
2752
+ }
2753
+ : undefined;
2667
2754
  return {
2668
2755
  type: 'element',
2669
2756
  name: elementName,
@@ -2677,7 +2764,7 @@ class ComponentNormalizer extends Base {
2677
2764
  makeOptionalTextElement(data.publisher, 'publisher'),
2678
2765
  makeOptionalTextElement(data.group, 'group'),
2679
2766
  makeTextElement(data.name, 'name'),
2680
- makeTextElement(data.version ?? '', 'version'),
2767
+ version,
2681
2768
  makeOptionalTextElement(data.description, 'description'),
2682
2769
  makeOptionalTextElement(data.scope, 'scope'),
2683
2770
  hashes,
@@ -2686,7 +2773,8 @@ class ComponentNormalizer extends Base {
2686
2773
  makeOptionalTextElement(data.cpe, 'cpe'),
2687
2774
  makeOptionalTextElement(data.purl, 'purl'),
2688
2775
  swid,
2689
- extRefs
2776
+ extRefs,
2777
+ components
2690
2778
  ].filter(notUndefined_1.isNotUndefined)
2691
2779
  };
2692
2780
  }
@@ -2829,9 +2917,12 @@ class DependencyGraphNormalizer extends Base {
2829
2917
  const allRefs = new Map();
2830
2918
  if (data.metadata.component !== undefined) {
2831
2919
  allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies);
2920
+ for (const component of data.metadata.component.components[tree_1.treeIterator]()) {
2921
+ allRefs.set(component.bomRef, component.dependencies);
2922
+ }
2832
2923
  }
2833
- for (const c of data.components) {
2834
- allRefs.set(c.bomRef, new Models.BomRefRepository(c.dependencies));
2924
+ for (const component of data.components[tree_1.treeIterator]()) {
2925
+ allRefs.set(component.bomRef, component.dependencies);
2835
2926
  }
2836
2927
  const normalized = [];
2837
2928
  for (const [ref, deps] of allRefs) {
@@ -2986,6 +3077,9 @@ class XmlBaseSerializer extends baseSerializer_1.BaseSerializer {
2986
3077
  _XmlBaseSerializer_normalizerFactory.set(this, void 0);
2987
3078
  __classPrivateFieldSet(this, _XmlBaseSerializer_normalizerFactory, normalizerFactory, "f");
2988
3079
  }
3080
+ get normalizerFactory() {
3081
+ return __classPrivateFieldGet(this, _XmlBaseSerializer_normalizerFactory, "f");
3082
+ }
2989
3083
  _normalize(bom, options = {}) {
2990
3084
  return __classPrivateFieldGet(this, _XmlBaseSerializer_normalizerFactory, "f").makeForBom()
2991
3085
  .normalize(bom, options);
@@ -3165,7 +3259,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3165
3259
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3166
3260
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3167
3261
  };
3168
- var _Spec_version, _Spec_formats, _Spec_componentTypes, _Spec_hashAlgorithms, _Spec_hashValuePattern, _Spec_externalReferenceTypes, _Spec_supportsDependencyGraph, _Spec_supportsToolReferences;
3262
+ var _Spec_version, _Spec_formats, _Spec_componentTypes, _Spec_hashAlgorithms, _Spec_hashValuePattern, _Spec_externalReferenceTypes, _Spec_supportsDependencyGraph, _Spec_supportsToolReferences, _Spec_requiresComponentVersion;
3169
3263
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3170
3264
  exports.SpecVersionDict = exports.Spec1dot4 = exports.Spec1dot3 = exports.Spec1dot2 = exports.UnsupportedFormatError = exports.Format = exports.Version = void 0;
3171
3265
  const enums_1 = __webpack_require__(/*! ./enums */ "./src/enums/index.ts");
@@ -3186,7 +3280,7 @@ class UnsupportedFormatError extends Error {
3186
3280
  }
3187
3281
  exports.UnsupportedFormatError = UnsupportedFormatError;
3188
3282
  class Spec {
3189
- constructor(version, formats, componentTypes, hashAlgorithms, hashValuePattern, externalReferenceTypes, supportsDependencyGraph, supportsToolReferences) {
3283
+ constructor(version, formats, componentTypes, hashAlgorithms, hashValuePattern, externalReferenceTypes, supportsDependencyGraph, supportsToolReferences, requiresComponentVersion) {
3190
3284
  _Spec_version.set(this, void 0);
3191
3285
  _Spec_formats.set(this, void 0);
3192
3286
  _Spec_componentTypes.set(this, void 0);
@@ -3195,6 +3289,7 @@ class Spec {
3195
3289
  _Spec_externalReferenceTypes.set(this, void 0);
3196
3290
  _Spec_supportsDependencyGraph.set(this, void 0);
3197
3291
  _Spec_supportsToolReferences.set(this, void 0);
3292
+ _Spec_requiresComponentVersion.set(this, void 0);
3198
3293
  __classPrivateFieldSet(this, _Spec_version, version, "f");
3199
3294
  __classPrivateFieldSet(this, _Spec_formats, new Set(formats), "f");
3200
3295
  __classPrivateFieldSet(this, _Spec_componentTypes, new Set(componentTypes), "f");
@@ -3203,6 +3298,7 @@ class Spec {
3203
3298
  __classPrivateFieldSet(this, _Spec_externalReferenceTypes, new Set(externalReferenceTypes), "f");
3204
3299
  __classPrivateFieldSet(this, _Spec_supportsDependencyGraph, supportsDependencyGraph, "f");
3205
3300
  __classPrivateFieldSet(this, _Spec_supportsToolReferences, supportsToolReferences, "f");
3301
+ __classPrivateFieldSet(this, _Spec_requiresComponentVersion, requiresComponentVersion, "f");
3206
3302
  }
3207
3303
  get version() {
3208
3304
  return __classPrivateFieldGet(this, _Spec_version, "f");
@@ -3229,8 +3325,11 @@ class Spec {
3229
3325
  get supportsToolReferences() {
3230
3326
  return __classPrivateFieldGet(this, _Spec_supportsToolReferences, "f");
3231
3327
  }
3328
+ get requiresComponentVersion() {
3329
+ return __classPrivateFieldGet(this, _Spec_requiresComponentVersion, "f");
3330
+ }
3232
3331
  }
3233
- _Spec_version = new WeakMap(), _Spec_formats = new WeakMap(), _Spec_componentTypes = new WeakMap(), _Spec_hashAlgorithms = new WeakMap(), _Spec_hashValuePattern = new WeakMap(), _Spec_externalReferenceTypes = new WeakMap(), _Spec_supportsDependencyGraph = new WeakMap(), _Spec_supportsToolReferences = new WeakMap();
3332
+ _Spec_version = new WeakMap(), _Spec_formats = new WeakMap(), _Spec_componentTypes = new WeakMap(), _Spec_hashAlgorithms = new WeakMap(), _Spec_hashValuePattern = new WeakMap(), _Spec_externalReferenceTypes = new WeakMap(), _Spec_supportsDependencyGraph = new WeakMap(), _Spec_supportsToolReferences = new WeakMap(), _Spec_requiresComponentVersion = new WeakMap();
3234
3333
  exports.Spec1dot2 = Object.freeze(new Spec(Version.v1dot2, [
3235
3334
  Format.XML,
3236
3335
  Format.JSON
@@ -3272,7 +3371,7 @@ exports.Spec1dot2 = Object.freeze(new Spec(Version.v1dot2, [
3272
3371
  enums_1.ExternalReferenceType.BuildMeta,
3273
3372
  enums_1.ExternalReferenceType.BuildSystem,
3274
3373
  enums_1.ExternalReferenceType.Other
3275
- ], true, false));
3374
+ ], true, false, true));
3276
3375
  exports.Spec1dot3 = Object.freeze(new Spec(Version.v1dot3, [
3277
3376
  Format.XML,
3278
3377
  Format.JSON
@@ -3314,7 +3413,7 @@ exports.Spec1dot3 = Object.freeze(new Spec(Version.v1dot3, [
3314
3413
  enums_1.ExternalReferenceType.BuildMeta,
3315
3414
  enums_1.ExternalReferenceType.BuildSystem,
3316
3415
  enums_1.ExternalReferenceType.Other
3317
- ], true, false));
3416
+ ], true, false, true));
3318
3417
  exports.Spec1dot4 = Object.freeze(new Spec(Version.v1dot4, [
3319
3418
  Format.XML,
3320
3419
  Format.JSON
@@ -3357,7 +3456,7 @@ exports.Spec1dot4 = Object.freeze(new Spec(Version.v1dot4, [
3357
3456
  enums_1.ExternalReferenceType.BuildSystem,
3358
3457
  enums_1.ExternalReferenceType.ReleaseNotes,
3359
3458
  enums_1.ExternalReferenceType.Other
3360
- ], true, true));
3459
+ ], true, true, false));
3361
3460
  exports.SpecVersionDict = Object.freeze(Object.fromEntries([
3362
3461
  [Version.v1dot2, exports.Spec1dot2],
3363
3462
  [Version.v1dot3, exports.Spec1dot3],
@@ -3394,7 +3493,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
3394
3493
  */
3395
3494
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3396
3495
  exports.isCPE = void 0;
3397
- const cpePattern = /^([c][pP][eE]:\/[AHOaho]?(:[A-Za-z0-9\._\-~%]*){0,6})$|^(cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!&quot;#$$%&amp;'\(\)\+,\/:;&lt;=&gt;@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!&quot;#$$%&amp;'\(\)\+,\/:;&lt;=&gt;@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4})$/;
3496
+ const cpePattern = /^([c][pP][eE]:\/[AHOaho]?(:[A-Za-z0-9\._\-~%]*){0,6})$|^(cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!"#$$%&'\(\)\+,\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4})$/;
3398
3497
  function isCPE(value) {
3399
3498
  return typeof value === 'string' &&
3400
3499
  cpePattern.test(value);