Skip to content

Commit 4e0dfff

Browse files
committed
fix: fix grype pkg:golang/k8s.io/[email protected] does not show cve because namespace not handled
Signed-off-by: goatwu1993 <[email protected]>
1 parent f100d57 commit 4e0dfff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

grype/pkg/purl_provider.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,17 @@ func purlToPackage(rawLine string) (*Package, *pkg.Package, string, string, erro
201201
PURL: purl.String(),
202202
Language: pkg.LanguageByName(purl.Type),
203203
}
204+
// copy to avoid mutating the original purl object
205+
name := purl.Name
206+
if purl.Namespace != "" {
207+
name = fmt.Sprintf("%s/%s", purl.Namespace, purl.Name)
208+
}
204209

205210
syftPkg.SetID()
206211
return &Package{
207212
ID: ID(purl.String()),
208213
CPEs: cpes,
209-
Name: purl.Name,
214+
Name: name,
210215
Version: version,
211216
Type: pkgType,
212217
Language: pkg.LanguageByName(purl.Type),

0 commit comments

Comments
 (0)