Skip to content

Commit

Permalink
feat: kubernetes bill of materials
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan committed Jun 15, 2023
1 parent 31d8659 commit 93f993e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 11 additions & 2 deletions pkg/k8s/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (s *Scanner) filter(ctx context.Context, r types.Report, artifact *artifact
const (
golang = "golang"
oci = "oci"
kubelet = "kubelet"
kubelet = "k8s.io/kubelet"
pod = "PodInfo"
nodeInfo = "NodeInfo"
nodeCoreComponents = "node-core-components"
Expand Down Expand Up @@ -271,7 +271,16 @@ func osNameVersion(name string) (string, string) {
func runtimeNameVersion(name string) (string, string) {
parts := strings.Split(name, "://")
if len(parts) == 2 {
return parts[0], parts[1]
name := parts[0]
switch parts[0] {
case "cri-o":
name = "github.com/cri-o/cri-o"
case "containerd":
name = "github.com/containerd/containerd"
case "cri-dockerd":
name = "github.com/Mirantis/cri-dockerd"
}
return name, parts[1]
}
return "", ""
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/k8s/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,31 @@ func TestK8sClusterInfoReport(t *testing.T) {
Components: []*core.Component{
{
Type: cdx.ComponentTypeLibrary,
Name: "kubelet",
Name: "k8s.io/kubelet",
Version: "1.21.1",
Properties: map[string]string{
"PkgType": "golang",
},
PackageURL: &purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: "golang",
Name: "kubelet",
Name: "k8s.io/kubelet",
Version: "1.21.1",
Qualifiers: packageurl.Qualifiers{},
},
},
},
{
Type: cdx.ComponentTypeLibrary,
Name: "containerd",
Name: "github.com/containerd/containerd",
Version: "1.5.2",
Properties: map[string]string{
cyc.PropertyPkgType: "golang",
},
PackageURL: &purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: "golang",
Name: "containerd",
Name: "github.com/containerd/containerd",
Version: "1.5.2",
Qualifiers: packageurl.Qualifiers{},
},
Expand Down

0 comments on commit 93f993e

Please sign in to comment.