@trustify-da/trustify-da-javascript-client 0.3.0-ea.189199e → 0.3.0-ea.1938f68

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/dist/package.json CHANGED
@@ -48,7 +48,6 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/core": "^7.23.2",
51
- "@cyclonedx/cyclonedx-library": "^10.0.0",
52
51
  "eslint-import-resolver-typescript": "^4.4.4",
53
52
  "fast-glob": "^3.3.3",
54
53
  "fast-xml-parser": "^5.3.4",
@@ -26,6 +26,19 @@ export default class CycloneDxSbom {
26
26
  alg: string;
27
27
  content: string;
28
28
  }>): CycloneDxSbom;
29
+ /**
30
+ * Attach hashes to already-added components by matching their PURL. This is a
31
+ * post-processing step so ecosystem-specific hash sources (e.g. Maven reading
32
+ * the local .m2 cache) can enrich the SBOM without threading their concern
33
+ * through the shared dependency-tree parser. Components without a matching
34
+ * entry, or whose hashes are already set, are left untouched.
35
+ * @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
36
+ * @return {CycloneDxSbom} the updated SBOM
37
+ */
38
+ attachHashes(hashMap: Map<string, Array<{
39
+ alg: string;
40
+ content: string;
41
+ }>>): CycloneDxSbom;
29
42
  /** @param {{}} opts - various options, settings and configuration of application.
30
43
  * @return String CycloneDx Sbom json object in a string format
31
44
  */
@@ -135,6 +135,30 @@ export default class CycloneDxSbom {
135
135
  }
136
136
  return this;
137
137
  }
138
+ /**
139
+ * Attach hashes to already-added components by matching their PURL. This is a
140
+ * post-processing step so ecosystem-specific hash sources (e.g. Maven reading
141
+ * the local .m2 cache) can enrich the SBOM without threading their concern
142
+ * through the shared dependency-tree parser. Components without a matching
143
+ * entry, or whose hashes are already set, are left untouched.
144
+ * @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
145
+ * @return {CycloneDxSbom} the updated SBOM
146
+ */
147
+ attachHashes(hashMap) {
148
+ if (!hashMap || hashMap.size === 0) {
149
+ return this;
150
+ }
151
+ for (const component of this.components) {
152
+ if (component.hashes) {
153
+ continue;
154
+ }
155
+ const hashes = hashMap.get(component.purl);
156
+ if (hashes && hashes.length > 0) {
157
+ component.hashes = hashes;
158
+ }
159
+ }
160
+ return this;
161
+ }
138
162
  /** @param {{}} opts - various options, settings and configuration of application.
139
163
  * @return String CycloneDx Sbom json object in a string format
140
164
  */
@@ -10,6 +10,13 @@ export type ecosystem_maven = any;
10
10
  export const ecosystem_maven: string;
11
11
  export const ecosystem_gradle: "gradle";
12
12
  export default class Base_Java {
13
+ /**
14
+ * Maven dependency scopes. Used to detect whether the trailing column of a
15
+ * dependency-tree line is a scope keyword — which in turn signals that an
16
+ * optional classifier column is present between the packaging and version.
17
+ * @type {string[]}
18
+ */
19
+ static MAVEN_SCOPES: string[];
13
20
  /**
14
21
  *
15
22
  * @param {string} globalBinary name of the global binary
@@ -40,6 +47,52 @@ export default class Base_Java {
40
47
  * @protected
41
48
  */
42
49
  protected _getDepth(line: string): number;
50
+ /**
51
+ * Parse a single dependency-tree line into its Maven coordinate parts.
52
+ *
53
+ * This is the single source of truth for interpreting a dependency-tree
54
+ * line. Both {@link parseDep} (used to build SBOM component PURLs) and the
55
+ * Maven hash-map builder rely on it, so the PURL key and the artifact file
56
+ * path can never drift from one another.
57
+ *
58
+ * A line has the shape `groupId:artifactId:packaging[:classifier]:version[:scope]`.
59
+ * The classifier column is only present when a sixth column holds a known
60
+ * Maven scope keyword; otherwise the fourth column is the version.
61
+ *
62
+ * @param {string} line - line to parse from a dependency tree
63
+ * @returns {{groupId: string, artifactId: string, packaging: string, classifier: (string|null), version: string, scope: (string|null), overridden: boolean}}
64
+ * Parsed coordinate. `version` is the resolved concrete version — when the
65
+ * line carries a conflict override the override version replaces it and
66
+ * `overridden` is set, mirroring how Maven records the winning version.
67
+ */
68
+ parseCoordinate(line: string): {
69
+ groupId: string;
70
+ artifactId: string;
71
+ packaging: string;
72
+ classifier: (string | null);
73
+ version: string;
74
+ scope: (string | null);
75
+ overridden: boolean;
76
+ };
77
+ /**
78
+ * Build the canonical PackageURL for a parsed coordinate.
79
+ *
80
+ * The classifier is folded into the version component (e.g.
81
+ * `4.1.0-linux-x86_64`) except when the version came from a conflict
82
+ * override, in which case the override version stands alone — matching the
83
+ * historical behavior of {@link parseDep}.
84
+ *
85
+ * @param {{groupId: string, artifactId: string, classifier: (string|null), version: string, overridden: boolean}} coord
86
+ * @returns {PackageURL} The canonical packageURL for the coordinate
87
+ * @protected
88
+ */
89
+ protected _coordinateToPurl(coord: {
90
+ groupId: string;
91
+ artifactId: string;
92
+ classifier: (string | null);
93
+ version: string;
94
+ overridden: boolean;
95
+ }): PackageURL;
43
96
  /**
44
97
  * Create a PackageURL from any line in a Text Graph dependency tree for a manifest path.
45
98
  * @param {string} line - line to parse from a dependencies.txt file
@@ -14,6 +14,13 @@ export const ecosystem_gradle = 'gradle';
14
14
  export default class Base_Java {
15
15
  DEP_REGEX = /(([-a-zA-Z0-9._]{2,})|[0-9])/g;
16
16
  CONFLICT_REGEX = /.*omitted for conflict with (\S+)\)/;
17
+ /**
18
+ * Maven dependency scopes. Used to detect whether the trailing column of a
19
+ * dependency-tree line is a scope keyword — which in turn signals that an
20
+ * optional classifier column is present between the packaging and version.
21
+ * @type {string[]}
22
+ */
23
+ static MAVEN_SCOPES = ['compile', 'provided', 'runtime', 'test', 'system', 'import'];
17
24
  globalBinary;
18
25
  localWrapper;
19
26
  /**
@@ -82,31 +89,71 @@ export default class Base_Java {
82
89
  }
83
90
  return ((line.indexOf('-') - 1) / 3) + 1;
84
91
  }
92
+ /**
93
+ * Parse a single dependency-tree line into its Maven coordinate parts.
94
+ *
95
+ * This is the single source of truth for interpreting a dependency-tree
96
+ * line. Both {@link parseDep} (used to build SBOM component PURLs) and the
97
+ * Maven hash-map builder rely on it, so the PURL key and the artifact file
98
+ * path can never drift from one another.
99
+ *
100
+ * A line has the shape `groupId:artifactId:packaging[:classifier]:version[:scope]`.
101
+ * The classifier column is only present when a sixth column holds a known
102
+ * Maven scope keyword; otherwise the fourth column is the version.
103
+ *
104
+ * @param {string} line - line to parse from a dependency tree
105
+ * @returns {{groupId: string, artifactId: string, packaging: string, classifier: (string|null), version: string, scope: (string|null), overridden: boolean}}
106
+ * Parsed coordinate. `version` is the resolved concrete version — when the
107
+ * line carries a conflict override the override version replaces it and
108
+ * `overridden` is set, mirroring how Maven records the winning version.
109
+ */
110
+ parseCoordinate(line) {
111
+ const parts = line.split(':').map(part => part ? part.match(this.DEP_REGEX)?.[0] ?? '' : '');
112
+ const groupId = parts[0] ?? '';
113
+ const artifactId = parts[1] ?? '';
114
+ const packaging = parts[2] ?? '';
115
+ // A classifier column exists only when a sixth column holds a scope keyword.
116
+ const hasClassifier = parts.length >= 6 && Base_Java.MAVEN_SCOPES.includes(parts[5]);
117
+ const classifier = hasClassifier ? parts[3] : null;
118
+ let version = (hasClassifier ? parts[4] : parts[3]) ?? '';
119
+ const scope = hasClassifier ? parts[5] : (parts.length >= 5 ? parts[4] : null);
120
+ // A conflict override replaces the resolved version entirely.
121
+ const override = line.match(this.CONFLICT_REGEX);
122
+ const overridden = Boolean(override);
123
+ if (overridden) {
124
+ version = override[1];
125
+ }
126
+ return { groupId, artifactId, packaging, classifier, version, scope, overridden };
127
+ }
128
+ /**
129
+ * Build the canonical PackageURL for a parsed coordinate.
130
+ *
131
+ * The classifier is folded into the version component (e.g.
132
+ * `4.1.0-linux-x86_64`) except when the version came from a conflict
133
+ * override, in which case the override version stands alone — matching the
134
+ * historical behavior of {@link parseDep}.
135
+ *
136
+ * @param {{groupId: string, artifactId: string, classifier: (string|null), version: string, overridden: boolean}} coord
137
+ * @returns {PackageURL} The canonical packageURL for the coordinate
138
+ * @protected
139
+ */
140
+ _coordinateToPurl(coord) {
141
+ const purlVersion = (coord.classifier && !coord.overridden)
142
+ ? `${coord.version}-${coord.classifier}`
143
+ : coord.version;
144
+ return this.toPurl(coord.groupId, coord.artifactId, purlVersion);
145
+ }
85
146
  /**
86
147
  * Create a PackageURL from any line in a Text Graph dependency tree for a manifest path.
87
148
  * @param {string} line - line to parse from a dependencies.txt file
88
149
  * @returns {PackageURL} The parsed packageURL
89
150
  */
90
151
  parseDep(line) {
91
- let match = line.split(':').map(part => part ? part.match(this.DEP_REGEX)[0] : '');
92
- if (!match) {
93
- throw new Error(`Unable generate SBOM from dependency tree. Line: ${line} cannot be parsed into a PackageURL`);
94
- }
95
- let version;
96
- if (match.length >= 5 && ['compile', 'provided', 'runtime'].includes(match[5])) {
97
- version = `${match[4]}-${match[3]}`;
98
- }
99
- else {
100
- version = match[3];
101
- }
102
- let override = line.match(this.CONFLICT_REGEX);
103
- if (override) {
104
- version = override[1];
105
- }
106
- if (match[0].trim() === '') {
152
+ const coord = this.parseCoordinate(line);
153
+ if (coord.groupId.trim() === '') {
107
154
  throw new Error(`Artifact coordinates should have a non-empty group ID: ${line}`);
108
155
  }
109
- return this.toPurl(match[0], match[1], version);
156
+ return this._coordinateToPurl(coord);
110
157
  }
111
158
  /**
112
159
  * Returns a PackageUrl For Java maven dependencies
@@ -11,6 +11,10 @@ export function discoverMavenModules(workspaceRoot: string, opts?: object): Prom
11
11
  /** @typedef {{name: string, version: string}} Package */
12
12
  /** @typedef {{groupId: string, artifactId: string, version: string, scope: string, ignore: boolean}} Dependency */
13
13
  export default class Java_maven extends Base_java {
14
+ /** @type {Object<string, string>} Packaging types that produce .jar files despite non-jar packaging names. */
15
+ static PACKAGING_TO_JAR: {
16
+ [x: string]: string;
17
+ };
14
18
  constructor();
15
19
  /**
16
20
  * @param {string} manifestName - the subject manifest name-type
@@ -25,9 +29,9 @@ export default class Java_maven extends Base_java {
25
29
  * Provide content and content type for maven-maven stack analysis.
26
30
  * @param {string} manifest - the manifest path or name
27
31
  * @param {{}} [opts={}] - optional various options to pass along the application
28
- * @returns {Provided}
32
+ * @returns {Promise<Provided>}
29
33
  */
30
- provideStack(manifest: string, opts?: {}): Provided;
34
+ provideStack(manifest: string, opts?: {}): Promise<Provided>;
31
35
  /**
32
36
  * Provide content and content type for maven-maven component analysis.
33
37
  * @param {string} manifest - path to the manifest file
@@ -42,13 +46,34 @@ export default class Java_maven extends Base_java {
42
46
  */
43
47
  readLicenseFromManifest(manifestPath: string): string | null;
44
48
  /**
49
+ * Build a Map of PURL string → CycloneDX hash entries by reading artifact files from the local Maven repository.
50
+ *
51
+ * Both the artifact file path and the hash-map key are derived from the
52
+ * shared {@link Base_java#parseCoordinate} parser: the file path uses the
53
+ * resolved version and raw classifier, while the key uses the same canonical
54
+ * PURL builder as {@link Base_java#parseDep}. This guarantees the key always
55
+ * matches the PURL that {@link Base_java#parseDependencyTree} looks up.
45
56
  *
57
+ * @param {string} depTreeText Raw dependency tree text from mvn dependency:tree
58
+ * @param {{}} [opts={}] Options bag (may contain TRUSTIFY_DA_MVN_REPO)
59
+ * @returns {Promise<Map<string, Array<{alg: string, content: string}>>>}
60
+ */
61
+ _buildMavenHashMap(depTreeText: string, opts?: {}): Promise<Map<string, Array<{
62
+ alg: string;
63
+ content: string;
64
+ }>>>;
65
+ /**
46
66
  * @param {String} textGraphList Text graph String of the manifest
47
67
  * @param {[String]} ignoredDeps List of ignored dependencies to be omitted from sbom
68
+ * @param {{}} opts Options
48
69
  * @param {String} manifestPath Path to the pom.xml manifest
70
+ * @param {Map<string, Array<{alg: string, content: string}>>} [hashMap] PURL→hashes map
49
71
  * @return {String} formatted sbom Json String with all dependencies
50
72
  */
51
- createSbomFileFromTextFormat(textGraphList: string, ignoredDeps: [string], opts: any, manifestPath: string): string;
73
+ createSbomFileFromTextFormat(textGraphList: string, ignoredDeps: [string], opts: {}, manifestPath: string, hashMap?: Map<string, Array<{
74
+ alg: string;
75
+ content: string;
76
+ }>>): string;
52
77
  #private;
53
78
  }
54
79
  export type Java_maven = any;
@@ -1,3 +1,4 @@
1
+ import crypto from 'node:crypto';
1
2
  import fs from 'node:fs';
2
3
  import os from 'node:os';
3
4
  import path from 'node:path';
@@ -31,12 +32,12 @@ export default class Java_maven extends Base_java {
31
32
  * Provide content and content type for maven-maven stack analysis.
32
33
  * @param {string} manifest - the manifest path or name
33
34
  * @param {{}} [opts={}] - optional various options to pass along the application
34
- * @returns {Provided}
35
+ * @returns {Promise<Provided>}
35
36
  */
36
- provideStack(manifest, opts = {}) {
37
+ async provideStack(manifest, opts = {}) {
37
38
  return {
38
39
  ecosystem: ecosystem_maven,
39
- content: this.#createSbomStackAnalysis(manifest, opts),
40
+ content: await this.#createSbomStackAnalysis(manifest, opts),
40
41
  contentType: 'application/vnd.cyclonedx+json'
41
42
  };
42
43
  }
@@ -81,10 +82,10 @@ export default class Java_maven extends Base_java {
81
82
  * Create a Dot Graph dependency tree for a manifest path.
82
83
  * @param {string} manifest - path for pom.xml
83
84
  * @param {{}} [opts={}] - optional various options to pass along the application
84
- * @returns {string} the Dot Graph content
85
+ * @returns {Promise<string>} the Dot Graph content
85
86
  * @private
86
87
  */
87
- #createSbomStackAnalysis(manifest, opts = {}) {
88
+ async #createSbomStackAnalysis(manifest, opts = {}) {
88
89
  const manifestDir = path.dirname(manifest);
89
90
  const mvn = this.selectToolBinary(manifest, opts);
90
91
  const mvnArgs = JSON.parse(getCustom('TRUSTIFY_DA_MVN_ARGS', '[]', opts));
@@ -131,20 +132,105 @@ export default class Java_maven extends Base_java {
131
132
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
132
133
  console.error("Dependency tree that will be used as input for creating the BOM =>" + EOL + EOL + content.toString());
133
134
  }
134
- let sbom = this.createSbomFileFromTextFormat(content.toString(), ignoredDeps, opts, manifest);
135
+ const depTreeContent = content.toString();
136
+ const hashMap = await this._buildMavenHashMap(depTreeContent, opts);
137
+ let sbom = this.createSbomFileFromTextFormat(depTreeContent, ignoredDeps, opts, manifest, hashMap);
135
138
  // delete temp file and directory
136
139
  fs.rmSync(tmpDir, { recursive: true, force: true });
137
140
  // return dependency graph as string
138
141
  return sbom;
139
142
  }
143
+ /** @type {Object<string, string>} Packaging types that produce .jar files despite non-jar packaging names. */
144
+ static PACKAGING_TO_JAR = { 'bundle': 'jar', 'eclipse-plugin': 'jar' };
140
145
  /**
146
+ * Build a Map of PURL string → CycloneDX hash entries by reading artifact files from the local Maven repository.
147
+ *
148
+ * Both the artifact file path and the hash-map key are derived from the
149
+ * shared {@link Base_java#parseCoordinate} parser: the file path uses the
150
+ * resolved version and raw classifier, while the key uses the same canonical
151
+ * PURL builder as {@link Base_java#parseDep}. This guarantees the key always
152
+ * matches the PURL that {@link Base_java#parseDependencyTree} looks up.
141
153
  *
154
+ * @param {string} depTreeText Raw dependency tree text from mvn dependency:tree
155
+ * @param {{}} [opts={}] Options bag (may contain TRUSTIFY_DA_MVN_REPO)
156
+ * @returns {Promise<Map<string, Array<{alg: string, content: string}>>>}
157
+ */
158
+ async _buildMavenHashMap(depTreeText, opts = {}) {
159
+ const m2Repo = getCustom('TRUSTIFY_DA_MVN_REPO', path.join(os.homedir(), '.m2', 'repository'), opts);
160
+ const hashMap = new Map();
161
+ const lines = depTreeText.split(EOL);
162
+ // Track hash coverage so an incomplete .m2 cache (e.g. ephemeral CI
163
+ // containers or resolve-only phases) surfaces a summary warning instead
164
+ // of silently producing an SBOM with missing hashes.
165
+ let attempted = 0;
166
+ let missed = 0;
167
+ for (const rawLine of lines) {
168
+ const trimmed = rawLine.trim();
169
+ // Strip leading tree-drawing characters (e.g. "\-", "+-", "|") so the
170
+ // parenthesized-line check sees the coordinate itself. Omitted
171
+ // duplicate/conflict lines start with these characters after trim(),
172
+ // then an opening "(" — without stripping, the "(" check never fires.
173
+ const cleaned = trimmed.replace(/^[|+\\\- ]+/, '');
174
+ if (!cleaned || cleaned.startsWith('(')) {
175
+ continue;
176
+ }
177
+ const coord = this.parseCoordinate(rawLine);
178
+ if (!coord.groupId || !coord.artifactId || !coord.packaging) {
179
+ continue;
180
+ }
181
+ if (coord.packaging === 'pom') {
182
+ continue;
183
+ }
184
+ // Key by the exact PURL parseDep() produces, so the lookup in
185
+ // parseDependencyTree (hashMap.get(to.toString())) always hits.
186
+ const purl = this._coordinateToPurl(coord).toString();
187
+ // The same artifact recurs across dependency-tree branches — notably in
188
+ // multi-module reactor builds, where every module re-lists shared deps.
189
+ // The digest is deterministic per PURL, so skip the redundant file read
190
+ // and SHA-256 computation once this PURL is already hashed.
191
+ if (hashMap.has(purl)) {
192
+ continue;
193
+ }
194
+ const ext = Java_maven.PACKAGING_TO_JAR[coord.packaging] || coord.packaging;
195
+ const groupPath = coord.groupId.replaceAll('.', path.sep);
196
+ const fileName = coord.classifier
197
+ ? `${coord.artifactId}-${coord.version}-${coord.classifier}.${ext}`
198
+ : `${coord.artifactId}-${coord.version}.${ext}`;
199
+ const artifactPath = path.join(m2Repo, groupPath, coord.artifactId, coord.version, fileName);
200
+ attempted++;
201
+ try {
202
+ const stream = fs.createReadStream(artifactPath);
203
+ const hash = crypto.createHash('sha256');
204
+ for await (const chunk of stream) {
205
+ hash.update(chunk);
206
+ }
207
+ const digest = hash.digest('hex');
208
+ hashMap.set(purl, [{ alg: 'SHA-256', content: digest }]);
209
+ }
210
+ catch {
211
+ missed++;
212
+ if (process.env['TRUSTIFY_DA_DEBUG'] === 'true') {
213
+ console.error(`Maven hash: artifact not found at ${artifactPath}, omitting hash`);
214
+ }
215
+ }
216
+ }
217
+ // Mirror the pip provider's convention (python_controller.js): surface an
218
+ // unconditional warning when hashes could not be computed, so incomplete
219
+ // hash coverage is visible even without TRUSTIFY_DA_DEBUG.
220
+ if (missed > 0) {
221
+ console.warn(`Maven hash: ${missed} of ${attempted} artifacts could not be read from the local .m2 cache; SBOM will be generated without hashes for those components.`);
222
+ }
223
+ return hashMap;
224
+ }
225
+ /**
142
226
  * @param {String} textGraphList Text graph String of the manifest
143
227
  * @param {[String]} ignoredDeps List of ignored dependencies to be omitted from sbom
228
+ * @param {{}} opts Options
144
229
  * @param {String} manifestPath Path to the pom.xml manifest
230
+ * @param {Map<string, Array<{alg: string, content: string}>>} [hashMap] PURL→hashes map
145
231
  * @return {String} formatted sbom Json String with all dependencies
146
232
  */
147
- createSbomFileFromTextFormat(textGraphList, ignoredDeps, opts, manifestPath) {
233
+ createSbomFileFromTextFormat(textGraphList, ignoredDeps, opts, manifestPath, hashMap) {
148
234
  let lines = textGraphList.split(EOL);
149
235
  // get root component
150
236
  let root = lines[0];
@@ -153,6 +239,9 @@ export default class Java_maven extends Base_java {
153
239
  let sbom = new Sbom();
154
240
  sbom.addRoot(rootPurl, license);
155
241
  this.parseDependencyTree(root, 0, lines.slice(1), sbom);
242
+ // Attach Maven artifact hashes as a post-processing step, keeping this
243
+ // Maven-specific concern out of the shared dependency-tree parser.
244
+ sbom.attachHashes(hashMap);
156
245
  return sbom.filterIgnoredDeps(ignoredDeps).getAsJsonString(opts);
157
246
  }
158
247
  /**
@@ -14,7 +14,7 @@ export function runRemediation(targetPath: string, options?: {
14
14
  dryRun?: boolean | undefined;
15
15
  providers?: string | undefined;
16
16
  sources?: string | undefined;
17
- groupBy?: "dependency" | "bundle" | undefined;
17
+ groupBy?: "bundle" | "dependency" | undefined;
18
18
  }): Promise<{
19
19
  exitCode: number;
20
20
  output: string;
@@ -26,7 +26,7 @@ export function generateReport(remediations: Array<{
26
26
  severity: string;
27
27
  cves: string[];
28
28
  }>, options?: {
29
- groupBy?: "dependency" | "bundle" | undefined;
29
+ groupBy?: "bundle" | "dependency" | undefined;
30
30
  format?: "markdown" | "json" | undefined;
31
31
  dryRun?: boolean | undefined;
32
32
  }): string;
@@ -33,6 +33,17 @@ export default class Sbom {
33
33
  alg: string;
34
34
  content: string;
35
35
  }>): CycloneDxSbom;
36
+ /**
37
+ * Attach hashes to existing components by matching their PURL. Post-processing
38
+ * step used by ecosystem-specific providers (e.g. Maven) to enrich the SBOM
39
+ * with artifact hashes without leaking their concern into the shared parser.
40
+ * @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
41
+ * @return {Sbom}
42
+ */
43
+ attachHashes(hashMap: Map<string, Array<{
44
+ alg: string;
45
+ content: string;
46
+ }>>): Sbom;
36
47
  /**
37
48
  * @return String sbom json in a string format
38
49
  */
package/dist/src/sbom.js CHANGED
@@ -50,6 +50,16 @@ export default class Sbom {
50
50
  addDependency(sourceRef, targetRef, scope, targetHashes) {
51
51
  return this.sbomModel.addDependency(sourceRef, targetRef, scope, targetHashes);
52
52
  }
53
+ /**
54
+ * Attach hashes to existing components by matching their PURL. Post-processing
55
+ * step used by ecosystem-specific providers (e.g. Maven) to enrich the SBOM
56
+ * with artifact hashes without leaking their concern into the shared parser.
57
+ * @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
58
+ * @return {Sbom}
59
+ */
60
+ attachHashes(hashMap) {
61
+ return this.sbomModel.attachHashes(hashMap);
62
+ }
53
63
  /**
54
64
  * @return String sbom json in a string format
55
65
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustify-da/trustify-da-javascript-client",
3
- "version": "0.3.0-ea.189199e",
3
+ "version": "0.3.0-ea.1938f68",
4
4
  "description": "Code-Ready Dependency Analytics JavaScript API.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",
@@ -48,7 +48,6 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/core": "^7.23.2",
51
- "@cyclonedx/cyclonedx-library": "^10.0.0",
52
51
  "eslint-import-resolver-typescript": "^4.4.4",
53
52
  "fast-glob": "^3.3.3",
54
53
  "fast-xml-parser": "^5.3.4",