Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PurlUtils): Add missing Debian Purl type to getPurlType #7620

Conversation

nnobelis
Copy link
Member

@nnobelis nnobelis commented Oct 4, 2023

No description provided.

Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.io>
@nnobelis nnobelis requested a review from a team as a code owner October 4, 2023 08:23
@@ -65,6 +65,7 @@ enum class PurlType(private val value: String) {
fun Identifier.getPurlType() =
when (type.lowercase()) {
"bower" -> PurlType.BOWER
"deb" -> PurlType.DEBIAN
Copy link
Member

@fviernau fviernau Oct 4, 2023

Choose a reason for hiding this comment

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

Can you please indicate why you think this value is missing? (I believe so far this mapping was limited keys which are actually used by package managers within ORT.)

Copy link
Member Author

Choose a reason for hiding this comment

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

At Bosch, we have a package manager plugin for Debian.
It used previously createPurl and I plan to migrate to toPurl following the merge of #7601.
toPurl calls this getPurlType function.

You wrote that getPurlType is meant to contains only package managers supported by ORT. In this case, we have a proprietary package manager plugin. How do you see it coexist with the rule you described in your comment ?

Copy link
Member

Choose a reason for hiding this comment

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

You wrote that getPurlType is meant to

Actually, I didn't mean "is meant to" but I meant: it currently only contains values from the package managers in ORT.

How do you see it coexist with the rule you described in your comment ?

ORT has a mechanism to plug-in package managers, but lacks a mechanism for plugging in logic related to the ecosystem that package manager uses, e.g. Identifier.type. In my view, that should be a plug-in as well for the exact same reason the package manager has been chosen to be a plugin. However, we do not have such mechanism yet.

There are further places in the code which would need to be considered.
For example, OSV has a mapping from Identifier.type to OSV ecosystem constants. So, currently OSV cannot be used for plugin package managers which would require extension of that mapping.

In my view, it would make sense to define start a dedicated PackageManagagerPlugin interface, which would contain (very roughly spkeaking):

  1. The existing factory method, currently called PackageManagerFactory.create()
  2. A function which gives the purlType to the corresponding type (optional to implement)
  3. A function which gives the OSV ecosystem to the corresponding type

What do other guys think? @oss-review-toolkit/core-devs

Copy link
Member

Choose a reason for hiding this comment

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

However, we do not have such mechanism yet.

Exactly. We had discussed that in past, and I have several branches on roughly that topic lying around (identifier-types, multiple-identifier-classes) that also try to deal with the problem that a package manager's project type does not need to match with it package type(s).

So for package manager that support multiple package types, like Pub, we'd even need a set of package types / PURLs / OSV ecosystem coordinates.

Copy link
Member

Choose a reason for hiding this comment

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

@sschuberth not sure if I get your point. Do you believe it's fine to add mappings for non-existing types now?

Copy link
Member

Choose a reason for hiding this comment

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

not sure if I get your point.

I was just amending to your API proposal more cases that we'd need to cover with such a new API.

Do you believe it's fine to add mappings for non-existing types now?

Basically no, but the right way to do it would require a rather large refactoring, I believe. Not sure whether that's feasible to do (now). I guess we should discuss this in a Kotlin developer meeting.

Copy link
Member Author

Choose a reason for hiding this comment

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

My 2 cents: for the time being I found a workaround so we can close this PR.
However this topic should definitively be discussed as it will surely arise again.

@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (13a4714) 68.03% compared to head (61adbf2) 68.03%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7620      +/-   ##
============================================
- Coverage     68.03%   68.03%   -0.01%     
  Complexity     2022     2022              
============================================
  Files           344      344              
  Lines         16725    16726       +1     
  Branches       2371     2371              
============================================
  Hits          11379    11379              
- Misses         4363     4364       +1     
  Partials        983      983              
Flag Coverage Δ
funTest-docker 69.36% <ø> (ø)
funTest-non-docker 36.43% <0.00%> (-0.01%) ⬇️
test 35.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
model/src/main/kotlin/utils/PurlUtils.kt 76.05% <0.00%> (-1.09%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nnobelis
Copy link
Member Author

Change not needed anymore.

@nnobelis nnobelis closed this Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants