Skip to content

Commit 90b41d9

Browse files
authored
fix: prevent multiple, duplicate build-system entries (#1355)
PR #1349, for some projects, ends up creating multiple duplicate `build-system` external references. The fix is to ensure we have not already added an external reference of type: `build-system`. With the current implementation, I've seen the plugin produce records like: ```json "externalReferences": [ { "url": "https://some.build.system.internal/job/88", "type": "build-system", "comment": "as declared via cyclonedx-webpack-plugin config \"rootComponentBuildSystem\"" }, { "url": "https://some.internal.vcs/org/repo", "type": "vcs", "comment": "as declared via cyclonedx-webpack-plugin config \"rootComponentVCS\"" }, { "url": "https://some.build.system.internal/job/88", "type": "build-system", "comment": "as declared via cyclonedx-webpack-plugin config \"rootComponentBuildSystem\"" }, { "url": "https://some.build.system.internal/job/88", "type": "build-system", "comment": "as declared via cyclonedx-webpack-plugin config \"rootComponentBuildSystem\"" }, { "url": "https://some.build.system.internal/job/88", "type": "build-system", "comment": "as declared via cyclonedx-webpack-plugin config \"rootComponentBuildSystem\"" } ] ``` fixes #1356 Signed-off-by: Jeremy Long <[email protected]>
1 parent ca1291f commit 90b41d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ export class CycloneDxWebpackPlugin {
327327
if (component === undefined) { return }
328328
if (
329329
typeof this.rootComponentBuildSystem === 'string' &&
330-
this.rootComponentBuildSystem.length > 0
330+
this.rootComponentBuildSystem.length > 0 &&
331+
!iterableSome(
332+
component.externalReferences,
333+
ref => ref.type === CDX.Enums.ExternalReferenceType.BuildSystem
334+
)
331335
) {
332336
component.externalReferences.add(
333337
new CDX.Models.ExternalReference(

0 commit comments

Comments
 (0)