-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Cyclonedx sbom for tycho dependencies #137
Comments
Any Maven project, including Tycho, is supported. I'd recommend integrating CycloneDX Maven plugin into the pom itself that way it becomes part of the Maven lifecycle. |
I tried the cyclonedx maven plugin( pom.xml) on repo : https://github.com/eclipse/tycho/tree/master/demo/itp04-rcp to generate sbom. Used following block in pom.xml
Please refer to the attached sbom report. |
Sounds like the tycho project either needs to:
or
I would strongly encourage the second approach. Other Eclipse projects are already adopting CycloneDX including Eclipse Temurin. |
Do you mean this should be done on tycho side ? so currently for projects with builds based on tycho we either need to fill a bug against tycho asking them to adopt CycloneDX, or create a CycloneDX implementation by ourself if they are not willing to do so, right ? |
The project you mentioned does not reference a single "maven" dependency but only P2 dependencies (beside that its using an old target+tycho version) so the question is how should this ever work? If you use the latest Tycho version, there is an option to map P2 dependencies to "regular" maven ones as much as possible and you can reference maven dependencies directly in your target, but without that there is not much Tycho can do for you. |
@stevespringett can you please explain if the plugin can be somehow extended by a third party?
while for a P2 dependency one probably want something like: "pkg:p2/bundle/org.eclipse.m2e.archetype.common@3.2.103" |
@laeubi I guess there would be two ways to do this. The first being to merge the results from the Maven plugin with a BOM containing the p2 components. The CycloneDX CLI performs merging. The second option would be to add direct, but optional support for p2 in the Maven plugin. I don’t know what this would involve as I have no experience with p2. @hboutemy at the Apache Foundation is leading the development efforts of this plugin. @hboutemy would you by chance know how this could potentially work? |
I know sufficiently about Tycho to know that I don't know, sorry |
Maybe it would be possible to have a parameter in the CycloneDX Plugin to specify some "merge boms", Tycho could then just generate it at the standard location (e.g.
It is actually a quite easy rule:
Then it mapped in the following way;
then one might get a result of |
By the way is there a libary I could use to write a SBOM in CycloneDX format? |
@laeubi please share a simple Tycho project that we can transform into cyclonedx-maven-plugin IT we can try and see how hard this will be |
https://github.com/CycloneDX/cyclonedx-core-java is used by cyclonedx-maven-plugin |
I'll try to prepare a demo for this purpose, for a quick look there is the example from the comment above: it has a zip file attached and there you can search for
this is actually a P2 dependency with |
What is the status of this? I read the conversation several times but I didn't fully get what can/should be done in order to get "real" Maven PURLs out of Eclipse plug-ins. Is there some information that can be put into the the Eclipse plug-in Jars that can be consumes by the cyclonedx Maven plug-in? Or are there code changes required in the Maven plug-in or in Tycho? I'm happy to invest some time since we are very interested in this feature but I will need some more concrete hints where and how to start. |
@sithmein it all depends on the context and use case, to summarize a Eclipse plug-in can be a maven deployed in which case it can be mapped as a maven PURL, if that's not the case it can't and one obviously needs a different scheme, but its not clear how useful this is. It seems this is not really something the usual committer/contributors encounter and thus handled with very low priority, so if this is crucial to your business and you likes to speed up the development you can contact me for an individual contract for working dedicated on this specific issue. |
I completely overlooked the example, now diving into it: I now understand the problem in provided
is a Tycho / OSGi bundle (with its specific hashes) associated to I suppose an original "classical" non-OSGi jar (and its original hashes) and you want to track the transformation of the original jar file (that is known to the usual non-OSGi community) into the OSGi bundle I still need to understand the magic behind these OSGi bundle. I ran the example, and as of today, I got this download
(I suppose the version difference is just an update in the example code) What Maven coordinates is this OSGi bundle supposed to match? FYI, rebuilding today, the group in generated please help clarifying the problem, then we'll see what solutions may be found (probably at multiple levels) |
As said there is not a 1:1 mapping to maven artifacts, it might be that a maven artifact was used and just wrapped as a bundle, it might be build from source with some modification, it might even not be on maven central at all, it could even be directly consumed from maven, but the unit-id does not mean anything in this regard. |
What we see in our applications is the following:
Case 1 is already covered in my opinion. Having a solution for case 2 would cover > 80% (in our case). Case 3 is very similar to case 2 and I guess they could be solved together. Case 4 isn't something that has to (or can be) be supported. |
ok, I think I'm starting to understand the problem space I propose the following plan:
when I see the |
It should be something like
The value is an implementation detail of Tycho and can't be changed it is purely used inside the current reactor build to specify system scoped dependencies in the maven model, the only thing we somehow gurantee as stable is that is starts with
The is no guarantee at all that a P2 artifact has ever been "repacked" from a maven artifact, the tycho-packaging:update-consumer-pom performs some back-resolving for items that where consumed directly from maven but this is more to support consumers of the pom not as a mean of what is shipped with a product.
This has nothing to do with Tycho and not every bundle build by Tycho is an orbit one, actually orbit uses bnd to build its bundles. Please don't repeat the error of the Eclipse license tool to assume every bundle originates from orbit, that is simply wrong.
See above, there is no such documentation because it is internal behavior of Tycho to overcome the restrictions of the maven model, also note that P2 != Tycho, Tycho just supports using P2 repositories as it supports to use Maven Repositories as well. |
on updating https://github.com/package-url/purl-spec, it all starts with a PR On cyclonedx-maven-plugin generating such p2 purl, IIUC, it' about detecting Maven We'll see later if heuristics can be done to try to generate a pedigree from a p2 purl to a Maven artifact: honestly, that part is the type of tricks that I'd prefer to keep out of cyclonedx-maven-plugin |
P2 can store different type, e.g. bundles, features, products, ... so the type should be represented somehow to not run into issues later on.
If that helps anything it could be done that way yes, another indication is that it is a system scoped dependency. |
if there are different "types" for p2 that need to be represented in purl |
I think the most relevant ones are
There are also update sites, products and target but those are usually nothing one can depend on. |
are all these really related to an artifact? When I read, it feels to me that it is related to the repository where the artifact comes from |
Sorry I don't fully understand. A bundle is not a feature even if both are stored as a jar file (a feature usually groups bundles and other features), the repository (like a maven repository) can store different things but do not really care of course much here but I'm not that familiar with SBOM to decide if / hwo it makes a difference so would say it should be handled like in maven where an artifact can be type xml, jar, zip, .... |
nobody of us is expert in both p2 Tycho and SBOM, that's why we need to share examples to try to define what best fits the different aspects the current question is to define if p2 has a notion of namespace or not: see It seems that the "bundle", "feature", "update site", "product", "target" examples that you shares are in fact a precision of a sub-part of a p2 repository location is Notice: perhaps that instead of having this discussion in this cyclonedx-maven-plugin issue, we should move to the same discussion in a purl issue... |
another source of examples for purl is https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst can be useful to imagine how p2 would be added to the page; |
P2 artifacts originate from P2 repositories, such a repository for example can look like this: https://download.eclipse.org/technology/m2e/releases/latest/ if you download the content.jar you will see a set of units each unit can have artifacts, a unit usually provides a capability of
or for a feature
So |
when I see https://download.eclipse.org/technology/m2e/releases/latest/features/ and https://download.eclipse.org/technology/m2e/releases/latest/plugins/ it looks very similar ok, why not: this will have to be described in https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst with the same approach as other types I won't lead p2 addition to purl, as I'm not an expert of p2: once p2 will be added to purl types, I hope that the way Tycho defines Maven coordinates will permit us to implement in cyclonedx-maven-plugin a way to point to a p2 purl instead of a fake maven purl as it is currently the case |
Given that this feature would be quite interesting for us, I took the liberty to create both package-url/purl-spec#271 and package-url/purl-spec#272. Even though I'm not an expert, I like to think that I'm familiar enough with both Tycho and p2 that I'm willing to further pursue this topic. As an example, the bundle
Assuming that this proposition gets accepted, how exactly would the Maven coordinates need to look like, in order for CycloneDX to detect them as p2 artifacts? The problems I can see so far are that:
|
you proposition for p2 support in purl looks reasonable to me
in fact, I think that in we can probably try to create a draft PR (sorry, I'm quite buy for now, I won't have time before December, but I love this) |
By the way, if @ptziegler while |
How can we make sure that with the new PURL prefix, p2 bundles that are merely converted Maven artifacts are correctly recognized as such and vulnerability databases are able to match vulnerabilities correctly? |
There is no such thing as "p2 bundles"... P2 is a repository format like Maven, so there are no "maven bundles" either there are only artifacts that have some coordinates. The whole purpose is to have a way to "target" artifacts (!) stored only in a P2 repository, Tycho already tries to map artifacts stored in a P2 repository to maven as good as possible. If that's not possible, because an artifact was taken from maven, then modified ("merely converted") and republished as P2 then in fact it is not the same artifact and you can't be sure it has or has not a CVE assigned to the original thing. That's a reason why we at Tycho/Platform more and more move towards reusing contents directly from maven because then one can match those by the SHA-1/SHA-256 hashsums as a last resort. |
Alternatively CycloneDX could check whether the artifact contains e.g. the feature.xml or OSGi metadata in the Manifest file (in an agnostic way, unrelated to Tycho). Though just by writing it down, I'm already not a huge fan of the additional overhead.
I've currently described it as a required property. Do you think it'd be better to keep it optional or to drop it entirely?
I'd agree with laeubi that if an artifact also exists on Maven Central, Tycho should try to (and already can) map it to its Maven GAV, which I think that's also something that could be handled within a potential extension. Otherwise you have no guarantee what's inside and have to treat it as a black box. Now the interesting question whether there is a way to define aliases between purls. If an artifact was first uploaded to a p2 repository, but later to Maven Central, we end up with a p2 and a maven purl, both describing the same artifact. At least from my side, the main goal is to have a formal way to report CVEs for "pure" p2 artifacts. The only way right now is via the artifical coordinates generated by Tycho, which I don't think is appropriate for such a case. I can hopefully get some time towards the end of the month, to have a closer look at how this could work for CycloneDX/Tycho and perhaps even work on a small PoC. |
This won't work as just because a jar is a bundle or contains a feature does not mean it is an p2 hosted artifact...
Yes at least optional, with P2 its quite common that an artifact "travels along", so question is how one finds it, I don't know how Maven does it but I assume one has to supply some kind of repositories to search for (with default to central), so for P2 one likely want to specify the repositories as well if one wants to resolve the artifact itself.
That's the biggest point for me regarding the bom "hype", this all works if you have well defined sources and the tools all know it and people report things transparent but in the end, if a purl is NOT found it does not imply that there is no problem at all and if one is found not that there are not others. |
As far as I understand, the tool already provides those extension points in form of the ModelConverter:
and
So I assume Tycho (or any tool for that matter) would only need to provide their own implementation, which is then used instead of the default implementation. |
Alright... I've just set up a small project containing a mock implementation of the ModelConverter:
In the META-INF/plexus folder, I've created a components.xml file with content:
This project is then added as a dependency to the cyclonedx-maven-plugin
And so far, my own implementation takes precedence over the default implementation. The first step should now probably be to clean up the definition of a p2 PURL and then, if there is interest, I could try to create a draft for Tycho with a proper implementation of the ModelConverter. |
@ptziegler There certainly is interest. Looking forward to your implementation. |
A proof-of-concept has recently been merged to Tycho, which generates a p2 PURL for OSGi artifacts. Example: While implementing it, I noticed some weird edge-cases, where I'm not really sure how to handle them, or whether they are problematic to begin with: The concept of a
I don't know whether this is a critical component and what the implications are, if this value changes. Is there a document where I can look up the meaning of those entries? |
@ptziegler I would recommend not using the artificial group id, as it is more a technical thing as maven requires one. I would simply align here with the osgi.identity Namespace specification and choose |
@stevespringett - We would also very much welcome a solution to the problem of not being able to associate p2.eclipse-plugin artifacts with the source artifacts in Maven Central (or whatever other original repository). This would be very useful to us. |
@JayAtFujifilm if they are from central and you haven't disable it Tycho will map them for you, but if your using something thats not on central it obviously can't be associated... |
@laeubi Thanks for your quick reply. We are primarily interested in artifacts that originally came from Maven Central. We will look into this. |
Hi Cyclonedx Team,
Is there any way to scan the Tycho dependencies using cyclonedx-maven-plugin?.
I found that syft tool can generate cyclonedx format but it has limitations. It does not generate license information.
Thanks,
Swapnil Bharshankar
The text was updated successfully, but these errors were encountered: