Skip to content

Add dependency graph info to BoM - #244

Closed
ManjunathMS35 wants to merge 3 commits into
CycloneDX:masterfrom
ManjunathMS35:implement-dependency-graph
Closed

Add dependency graph info to BoM#244
ManjunathMS35 wants to merge 3 commits into
CycloneDX:masterfrom
ManjunathMS35:implement-dependency-graph

Conversation

@ManjunathMS35

Copy link
Copy Markdown

This is related to the issue #61

Changes:

  • Added dependencies info to the BoM so that the dependency tree can be derived out of this.

ToDo:

  • Introduce new class by the name BomReference so that the creation of PackageUrl for both Component and Dependency is done through this single class

Signed-off-by: Manjunath Mandya Surendrakumar <manjunathms35@gmail.com>
@ManjunathMS35
ManjunathMS35 requested a review from a team as a code owner January 21, 2022 07:51
@jkowalleck

Copy link
Copy Markdown
Member

this PR supersedes #243

Comment thread model/Bom.js
Comment thread model/Bom.js Outdated
@jkowalleck

jkowalleck commented Jan 21, 2022

Copy link
Copy Markdown
Member

@ManjunathMS35
please don't confuse BomRefs with PackageURLs(PURL).
it might be appealing that a BomRef looks like a PURL, bit a BomRef might be any arbitrary string.


regarding your TODO:

Introduce new class by the name BomReference so that the creation of PackageUrl for both Component and Dependency is done through this single class

you might find this write-up/decision-paper from another CycloneDX project helpful: https://github.com/CycloneDX/cyclonedx-php-library/blob/master/docs/dev/decisions/BomDependencyDataModel.md
it might give you some ideas and point out some constraints. Since the other project is written in PHP, it might not be close to the JavaScript implementation and its needs.

Signed-off-by: Manjunath Mandya Surendrakumar <manjunathms35@gmail.com>
Comment thread tests/__snapshots__/index.test.js.snap Outdated
Signed-off-by: Manjunath Mandya Surendrakumar <manjunathms35@gmail.com>
Comment thread model/Bom.js
return deplist
}

createPackageURL (pkg) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ there is code to crate a PURL already. see

if (this._name && this._version) { this._purl = new PackageURL('npm', this._group, this._name, this._version, null, null).toString() }

if you really want to use a PURL as the bom-ref's value, please incorporate the already existing PURL creation.
Reasons: if a bom-ref looks like a PURL, i would expect it to be the actual PURL of a Component, not a string that was crafted somehow else.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason I wanted to implement the BomReference class and make use of creation of PURL in both Component and Bom. Is it okay to do something like this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkowalleck Any suggestions on this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread model/Bom.js
Object.keys(pkg._dependencies)
.map(x => pkg.dependencies[x])
.filter(x => x !== undefined && typeof (x) !== 'string') // remove cycles
.map(x => deplist.push(new Dependency(this.createPackageURL(x), this.createDependency(x, list))))

@jkowalleck jkowalleck Jan 22, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


how do you handle, if this.createPackageURL() returns null? which is totally possible from the current algorithm used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not handled yet and as I said in the previous comment, creation of BomReference class will solve this issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkowalleck

jkowalleck commented Jan 22, 2022

Copy link
Copy Markdown
Member

@ManjunathMS35, thanks for working on this feature. it is appreciated.

I am not too familiar with the JavaScript code base, so some of my latest comments might be not justified a 100%
Bare with me and help me understand things better :)

@ManjunathMS35

Copy link
Copy Markdown
Author

@ManjunathMS35, thanks for working on this feature. it is appreciated.

I am not too familiar with the JavaScript code base, so some of my latest comments might be not justified a 100% Bare with me and help me understand things better :)

Even I am not familiar with best practices of JavaScript, I will try my best to answer your questions.

@jkowalleck

Copy link
Copy Markdown
Member

will come back as soon as #247 was addressed.

@jkowalleck

jkowalleck commented Jan 29, 2022

Copy link
Copy Markdown
Member

a good solution would be to "find" the component that is referenced in the already existing Bom.components,
and use its bomRef getter. this way you have the correct ref value, definitely.

need to think more about the topic. will come back later.

@jkowalleck

Copy link
Copy Markdown
Member

re #244 (comment)

i think having dedicated Type for bom-ref/ref is the way to go. I would totally support the new Type for bom-ref/ref - it is in the spirit of CycloneDX/specification#114

A constraint i see: In the current major version the new type must extend String, because the current implementation of the component.bomRef returns string or undefined.

@kabo kabo mentioned this pull request May 4, 2022
@jkowalleck

Copy link
Copy Markdown
Member

superseded by #296

@jkowalleck jkowalleck closed this May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for dependency graph introduced in v1.2 of the spec

2 participants