#3746·grype

`match.dpkg.using-cpes`(以及`match.rpm.using-cpes`)被接受,但没有任何效果

作者: amitschendel创建于 2026年9月27日更新于 2026年9月27日

What happened: Setting `match.dpkg.using-cpes: true` (or `GRYPE_MATCH_DPKG_USING_CPES=true`) does not change matching. `grype config --load` shows the value as `true`, but a `.deb` that Debian does not ship still gets no CPE-based matches, even when its CPE has NVD records. In the config code, `dpkgConfig` and `rpmConfig` embed `matcherConfig`, so both get the `using-cpes` key. When the matchers are built, `getMatcherConfig` passes only `MissingEpochStrategy` and `UseCPEsForEOL` (and `dpkg.MatcherConfig` / `rpm.MatcherConfig` have no field for the value). Nothing reads `opts.Match.Dpkg.UseCPEs` or `opts.Match.Rpm.UseCPEs` except the default-value tests. - https://GitHub.com/anchore/grype/blob/c24afc3a5e23b6961682c27187dc0b5f199dc120/cmd/grype/cli/options/match.go#L42-L43 - https://GitHub.com/anchore/grype/blob/c24afc3a5e23b6961682c27187dc0b5f199dc120/cmd/grype/cli/commands/root.go#L390-L397 - https://GitHub.com/anchore/grype/blob/c24afc3a5e23b6961682c27187dc0b5f199dc120/grype/matcher/dpkg/matcher.go#L21-L24 - https://GitHub.com/anchore/grype/blob/c24afc3a5e23b6961682c27187dc0b5f199dc120/grype/matcher/dpkg/matcher.go#L73 The key was exposed in #2976, which added the dpkg/rpm sections for the missing-epoch setting. The dpkg and rpm `using-cpes` keys are also the only ones without a description in `DescribeFields`, so `grype config` prints them with no comment. What you expected to happen: One of the following: 1. `match.dpkg.using-cpes: true` runs CPE matching for dpkg packages in addition to the distro feed, as `using-cpes` does for the other matchers; or 2. the key is removed (or rejected or warned about), so it isn't a silent no-op. The use case for (1) is third-party `.deb` packages installed from a vendor's own repository, like Grafana, which the Debian feed has no records for. At the moment `use-cpes-for-eol` is the only way to get CPE matching for dpkg packages, and it applies only to EOL distros. How to reproduce it (as minimally and precisely as possible): A directory with a Debian 12 `os-release` and one dpkg entry for Grafana's own `.deb` (`grafana:grafana` CPE, not packaged by Debian): sh mkdir -p repro/etc repro/var/lib/dpkg cat > repro/etc/os-release <<'OS' PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" ID=debian VERSION_ID="12" VERSION_CODENAME=bookworm OS cat > repro/var/lib/dpkg/status <<'DPKG' Package: grafana Status: install ok installed Maintainer: [email protected] Architecture: amd64 Version: 10.0.0 Description: Grafana DPKG echo "defaults:"; grype dir:repro -q | tail -n +2 | wc -l echo "dpkg using-cpes on:"; GRYPE_MATCH_DPKG_USING_CPES=true grype dir:repro -q | tail -n +2 | wc -l Output: defaults: 0 dpkg using-cpes on: 0 Syft generates `cpe:2.3:a:grafana:grafana:10.0.0:*:*:*:*:*:*:*` for this package. Scanning the same CPE as a CycloneDX `application` component returns 31 matches, so the data is there. The same result happens with a config file (`match: