anchore / syft

CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Apache License 2.0
6.1k stars 561 forks source link

Improve distro specification on PURLs #2243

Open willmurphyscode opened 11 months ago

willmurphyscode commented 11 months ago

What would you like to be added:

Today, syft puts &distro=<distro info> on some PURLs. But there are instances where, for example, a version is missing.

Consider:

❯ syft -q -o json debian:trixie-20231009-slim | jq '.artifacts[0].purl'
"pkg:deb/debian/apt@2.7.6?arch=arm64&distro=debian"

has no version info, but there is at least a codename in:

❯ syft -q -o json debian:trixie-20231009-slim | jq '.distro'
{
  "prettyName": "Debian GNU/Linux trixie/sid",
  "name": "Debian GNU/Linux",
  "id": "debian",
  "versionCodename": "trixie",
  "homeURL": "https://www.debian.org/",
  "supportURL": "https://www.debian.org/support",
  "bugReportURL": "https://bugs.debian.org/"
}

Whereas for amazonlinux 2023, for example, the version is already encoded in the PURL:

❯ syft -q -o json amazonlinux:2023.2.20231011.0 | jq '.artifacts[0].purl'
"pkg:rpm/amzn/alternatives@1.15-2.amzn2023.0.2?arch=aarch64&upstream=chkconfig-1.15-2.amzn2023.0.2.src.rpm&distro=amzn-2023"

Why is this needed:

https://github.com/anchore/grype/issues/86

Additional context: Syft might need to do this by keeping a map of debian codenames to versions, and we should also see which other supported distros don't get version info in the PURLs.

willmurphyscode commented 11 months ago

Blocks https://github.com/anchore/grype/pull/1530