hexpm / specifications

Specifications for using and implementing Hex protocols
48 stars 26 forks source link

Add purl specification #27

Closed voltone closed 4 years ago

voltone commented 5 years ago

Would you be interested in formally defining and documenting the purl format for Hex packages? I believe this could help with SBOM tooling and vulnerability tracking.

ericmj commented 5 years ago

Is it only a specification or would we need to do something to implement this?

voltone commented 5 years ago

It's just a specification. Once the purl format for Hex packages has been formalised, tooling can be developed outside Hex that builds on it: for instance a Mix task that builds a CycloneDX BOM for use with OWASP Dependency-Track, or a Dependency-Track plugin that can deconstruct Hex package purls to query the hex.pm API to check for updates.

voltone commented 5 years ago

Maybe @sparrell or @GriffinMB want to weigh in as well, as we've been discussing supply chain security in the EEF Security WG

ericmj commented 5 years ago

This sounds like a good addition. I will read up on the specifications and your links and get back to you.

sparrell commented 5 years ago

I think providing ability to generate SBoM is a good idea. I predict this will be a requirement at some time in the future for anyone wanting anything claiming to have some security. It already is a requirement in financial industry and some others. Since we are a naturally more secure ecosystem, I think promoting security aspects will increase adoption of our ecosystem - so doing it is good marketing as well as good security.

In general I do think we should provide an SBoM with all software. What format could be debated (purl/sdpd/swid/cyclonedx) but the more complete the better (ie full tree not just one hop). At what point in tool chain could also be debated. I'm for doing whatever can be done easily at this point and we'll build on it.

sparrell commented 5 years ago

Should this be an issue instead of buried in a comment? I had trouble finding this since I looked for it in issues - which is just operator error on my part, but I might not the only one,

voltone commented 5 years ago

@sparrell this is a PR, that's why it doesn't show up under Issues. The changes, if approved, would add purl for Hex packages to the Hex specs. I imagine we'll then want to create a PR to add it also to the official purl repo, alongside the definitions for NPM, Maven and RubyGems.

At that point others can take over and create SBoM tooling, such as a Mix task for building a CycloneDX file with both Hex and NPM packages (calling cyclonedx-bom for the latter). I don't think such a tool needs to be an official Hex thing, it can be a 3rd party package that people can add.

voltone commented 5 years ago

(sorry, must have hit an unexpected GitHub keyboard shortcut)

voltone commented 5 years ago

I'm implementing a CycloneDX generator Mix task, and find myself wondering whether names (package, organisation, repo) are case sensitive. In practice it seems package names are case insensitive, while organisation and repo names are case sensitive, but I can't find any reference for that in the specs.

ericmj commented 5 years ago

They should all be case insensitive.

voltone commented 5 years ago

Ok, I'll update my purl proposal to reflect that. But please note that this does not appear to be implemented consistently in the tooling: both dependency resolution and the web UI treat the organization as case-sensitive...

voltone commented 5 years ago

FYI, I just published this package to generate an SBoM for a Mix project in CycloneDX format, with 'purl' package identifiers according to the spec proposed in this PR.

And yes, I realise I'm using one or two internal Mix and Hex APIs. If this tool proves useful I may want to have a chat with the Hex and Elixir maintainers to properly expose the necessary APIs.

voltone commented 4 years ago

I've been wondering whether to add an 'arch' qualifier, for packages with native code, e.g.:

pkg:hex/bcrypt_elixir@2.0.3?arch=amd64

michalmuskala commented 4 years ago

Usually packages themselves don't contain compiled binary code but just sources so I don't think it would be appropriate

voltone commented 4 years ago

@michalmuskala the files being pulled in during the build process are not architecture dependent, but the build artefacts (e.g. a release) are, and that's what the SBoM describes.

I don't think it's terribly important, but it is at least theoretically possible that a vulnerability only applies to certain architectures, and thanks to Nerves Hex packages get built for more than just x86/amd64...

ericmj commented 4 years ago

All nerves packages that are architecture specific have the architecture in the package name afaik.

ericmj commented 4 years ago

@voltone Is this ready to be merged?

voltone commented 4 years ago

Yeah, it would be great to make this official. Once it's merged I'll create a PR against the purl spec's Known purl types section