From cf0f0d00c23744d6ed9e9a9494e9095898f888ae Mon Sep 17 00:00:00 2001 From: chenk Date: Thu, 22 Feb 2024 06:35:47 +0200 Subject: [PATCH] feat(k8s): rancher rke2 version support (#5988) Signed-off-by: chenk --- go.mod | 2 +- go.sum | 4 ++-- pkg/k8s/scanner/scanner.go | 2 -- pkg/k8s/scanner/scanner_test.go | 4 ++-- pkg/purl/purl.go | 3 --- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 412cf86ebbf4..957b43db3ed5 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/aquasecurity/trivy-aws v0.7.2-0.20240212233003-6359c269e5d2 github.com/aquasecurity/trivy-db v0.0.0-20231005141211-4fc651f7ac8d github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48 - github.com/aquasecurity/trivy-kubernetes v0.6.3-0.20240118072219-c433b06f98e1 + github.com/aquasecurity/trivy-kubernetes v0.6.3 github.com/aquasecurity/trivy-policies v0.9.1-0.20240212232053-c450017d5624 github.com/aws/aws-sdk-go-v2 v1.24.1 github.com/aws/aws-sdk-go-v2/config v1.26.6 diff --git a/go.sum b/go.sum index 6f6fe6aa2278..19cc04eb947c 100644 --- a/go.sum +++ b/go.sum @@ -350,8 +350,8 @@ github.com/aquasecurity/trivy-db v0.0.0-20231005141211-4fc651f7ac8d h1:fjI9mkoTU github.com/aquasecurity/trivy-db v0.0.0-20231005141211-4fc651f7ac8d/go.mod h1:cj9/QmD9N3OZnKQMp+/DvdV+ym3HyIkd4e+F0ZM3ZGs= github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48 h1:JVgBIuIYbwG+ekC5lUHUpGJboPYiCcxiz06RCtz8neI= github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48/go.mod h1:Ldya37FLi0e/5Cjq2T5Bty7cFkzUDwTcPeQua+2M8i8= -github.com/aquasecurity/trivy-kubernetes v0.6.3-0.20240118072219-c433b06f98e1 h1:/LsIHMQJ4SOxZeib/bvLP7S3YDTXJVIsQyS4kIIP0GQ= -github.com/aquasecurity/trivy-kubernetes v0.6.3-0.20240118072219-c433b06f98e1/go.mod h1:v6B8SO2ep718ccGbbjhpzMn6p27IijS+dMb+MeYz3jQ= +github.com/aquasecurity/trivy-kubernetes v0.6.3 h1:Hmo0pefXRsyVYsii62WUQyt3xMHjm37ipPESeWM/LNA= +github.com/aquasecurity/trivy-kubernetes v0.6.3/go.mod h1:v6B8SO2ep718ccGbbjhpzMn6p27IijS+dMb+MeYz3jQ= github.com/aquasecurity/trivy-policies v0.9.1-0.20240212232053-c450017d5624 h1:OKJa4JRaB54tY3XxrUA5waEPuI+AsNMoz7PR5rkDQj0= github.com/aquasecurity/trivy-policies v0.9.1-0.20240212232053-c450017d5624/go.mod h1:AHMSfZ86npbvCMRxrGFw51PIfl60FRwXWgrvxWy7EU0= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= diff --git a/pkg/k8s/scanner/scanner.go b/pkg/k8s/scanner/scanner.go index ca08f8a86bd1..2c70b51f6173 100644 --- a/pkg/k8s/scanner/scanner.go +++ b/pkg/k8s/scanner/scanner.go @@ -623,8 +623,6 @@ func k8sNamespace(ver, nodeName string) string { namespace = purl.NamespaceEKS case strings.Contains(ver, "gke"): namespace = purl.NamespaceGKE - case strings.Contains(ver, "rke2"): - namespace = purl.NamespaceRKE case strings.Contains(ver, "hotfix"): if !strings.Contains(nodeName, "aks") { // Unknown k8s distribution diff --git a/pkg/k8s/scanner/scanner_test.go b/pkg/k8s/scanner/scanner_test.go index ec6d78f73c05..ff879d2ac14c 100644 --- a/pkg/k8s/scanner/scanner_test.go +++ b/pkg/k8s/scanner/scanner_test.go @@ -384,7 +384,7 @@ func TestGeneratePURL(t *testing.T) { compName: "k8s.io/kubelet", compVersion: "1.24.11+rke2r1", nodeName: "ip-10-0-5-23", - want: "pkg:k8s/rke/k8s.io%2Fkubelet@1.24.11%2Brke2r1", + want: "pkg:k8s/k8s.io%2Fkubelet@1.24.11%2Brke2r1", }, { name: "OCP", @@ -438,7 +438,7 @@ func TestK8sNamespace(t *testing.T) { name: "Rancher", compVersion: "1.24.11+rke2r1", nodeName: "ip-10-0-5-23", - want: "rke", + want: "kubernetes", }, { name: "OCP", diff --git a/pkg/purl/purl.go b/pkg/purl/purl.go index bd62ce57cef8..de02b309667a 100644 --- a/pkg/purl/purl.go +++ b/pkg/purl/purl.go @@ -37,7 +37,6 @@ const ( NamespaceEKS = "eks" NamespaceAKS = "aks" NamespaceGKE = "gke" - NamespaceRKE = "rke" NamespaceOCP = "ocp" TypeUnknown = "unknown" @@ -211,8 +210,6 @@ func (p *PackageURL) LangType() ftypes.LangType { return ftypes.GKE case NamespaceAKS: return ftypes.AKS - case NamespaceRKE: - return ftypes.RKE case NamespaceOCP: return ftypes.OCP case "":