Skip to content

Commit

Permalink
Change prefix in taxonomy and cyclondx
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Dymiński <dyminski@gmail.com>
  • Loading branch information
mateuszdyminski committed May 31, 2024
1 parent 61e8f90 commit 47f7176
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ linters-settings:
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/ksoc-private
local-prefixes: github.com/rad-security
golint:
min-confidence: 0
lll:
Expand Down
61 changes: 31 additions & 30 deletions cmd/cyclonexdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"github.com/CycloneDX/cyclonedx-go"
"github.com/google/uuid"
"github.com/mitchellh/hashstructure/v2"

"github.com/rad-security/kbom/internal/model"
)

const (
CdxPrefix = "cdx:"
KSOCPrefix = "ksoc:kbom:"
RADPrefix = "rad:kbom:"
K8sComponentType = "k8s:component:type"
K8sComponentName = "k8s:component:name"

Expand Down Expand Up @@ -50,28 +51,28 @@ func transformToCycloneDXBOM(kbom *model.KBOM) *cyclonedx.BOM { //nolint:funlen
Value: kbom.Cluster.Name,
},
{
Name: KSOCPrefix + "k8s:cluster:nodes",
Name: RADPrefix + "k8s:cluster:nodes",
Value: fmt.Sprintf("%d", kbom.Cluster.NodesCount),
},
}

if kbom.Cluster.Location.Name != "" && kbom.Cluster.Location.Name != "unknown" {
clusterProperties = append(clusterProperties, cyclonedx.Property{
Name: KSOCPrefix + "k8s:cluster:location:name",
Name: RADPrefix + "k8s:cluster:location:name",
Value: kbom.Cluster.Location.Name,
})
}

if kbom.Cluster.Location.Region != "" {
clusterProperties = append(clusterProperties, cyclonedx.Property{
Name: KSOCPrefix + "k8s:cluster:location:region",
Name: RADPrefix + "k8s:cluster:location:region",
Value: kbom.Cluster.Location.Region,
})
}

if kbom.Cluster.Location.Zone != "" {
clusterProperties = append(clusterProperties, cyclonedx.Property{
Name: KSOCPrefix + "k8s:cluster:location:zone",
Name: RADPrefix + "k8s:cluster:location:zone",
Value: kbom.Cluster.Location.Zone,
})
}
Expand Down Expand Up @@ -103,79 +104,79 @@ func transformToCycloneDXBOM(kbom *model.KBOM) *cyclonedx.BOM { //nolint:funlen
Value: n.Name,
},
{
Name: KSOCPrefix + "k8s:node:osImage",
Name: RADPrefix + "k8s:node:osImage",
Value: n.OsImage,
},
{
Name: KSOCPrefix + "k8s:node:arch",
Name: RADPrefix + "k8s:node:arch",
Value: n.Architecture,
},
{
Name: KSOCPrefix + "k8s:node:kernel",
Name: RADPrefix + "k8s:node:kernel",
Value: n.KernelVersion,
},
{
Name: KSOCPrefix + "k8s:node:bootId",
Name: RADPrefix + "k8s:node:bootId",
Value: n.BootID,
},
{
Name: KSOCPrefix + "k8s:node:type",
Name: RADPrefix + "k8s:node:type",
Value: n.Type,
},
{
Name: KSOCPrefix + "k8s:node:operatingSystem",
Name: RADPrefix + "k8s:node:operatingSystem",
Value: n.OperatingSystem,
},
{
Name: KSOCPrefix + "k8s:node:machineId",
Name: RADPrefix + "k8s:node:machineId",
Value: n.MachineID,
},
{
Name: KSOCPrefix + "k8s:node:hostname",
Name: RADPrefix + "k8s:node:hostname",
Value: n.Hostname,
},
{
Name: KSOCPrefix + "k8s:node:containerRuntimeVersion",
Name: RADPrefix + "k8s:node:containerRuntimeVersion",
Value: n.ContainerRuntimeVersion,
},
{
Name: KSOCPrefix + "k8s:node:kubeletVersion",
Name: RADPrefix + "k8s:node:kubeletVersion",
Value: n.KubeletVersion,
},
{
Name: KSOCPrefix + "k8s:node:kubeProxyVersion",
Name: RADPrefix + "k8s:node:kubeProxyVersion",
Value: n.KubeProxyVersion,
},
{
Name: KSOCPrefix + "k8s:node:capacity:cpu",
Name: RADPrefix + "k8s:node:capacity:cpu",
Value: n.Capacity.CPU,
},
{
Name: KSOCPrefix + "k8s:node:capacity:memory",
Name: RADPrefix + "k8s:node:capacity:memory",
Value: n.Capacity.Memory,
},
{
Name: KSOCPrefix + "k8s:node:capacity:pods",
Name: RADPrefix + "k8s:node:capacity:pods",
Value: n.Capacity.Pods,
},
{
Name: KSOCPrefix + "k8s:node:capacity:ephemeralStorage",
Name: RADPrefix + "k8s:node:capacity:ephemeralStorage",
Value: n.Capacity.EphemeralStorage,
},
{
Name: KSOCPrefix + "k8s:node:allocatable:cpu",
Name: RADPrefix + "k8s:node:allocatable:cpu",
Value: n.Allocatable.CPU,
},
{
Name: KSOCPrefix + "k8s:node:allocatable:memory",
Name: RADPrefix + "k8s:node:allocatable:memory",
Value: n.Allocatable.Memory,
},
{
Name: KSOCPrefix + "k8s:node:allocatable:pods",
Name: RADPrefix + "k8s:node:allocatable:pods",
Value: n.Allocatable.Pods,
},
{
Name: KSOCPrefix + "k8s:node:allocatable:ephemeralStorage",
Name: RADPrefix + "k8s:node:allocatable:ephemeralStorage",
Value: n.Allocatable.EphemeralStorage,
},
},
Expand All @@ -201,19 +202,19 @@ func transformToCycloneDXBOM(kbom *model.KBOM) *cyclonedx.BOM { //nolint:funlen
Value: img.Name,
},
{
Name: KSOCPrefix + "pkg:type",
Name: RADPrefix + "pkg:type",
Value: "oci",
},
{
Name: KSOCPrefix + "pkg:name",
Name: RADPrefix + "pkg:name",
Value: img.Name,
},
{
Name: KSOCPrefix + "pkg:version",
Name: RADPrefix + "pkg:version",
Value: img.Version,
},
{
Name: KSOCPrefix + "pkg:digest",
Name: RADPrefix + "pkg:digest",
Value: img.Digest,
},
},
Expand All @@ -238,14 +239,14 @@ func transformToCycloneDXBOM(kbom *model.KBOM) *cyclonedx.BOM { //nolint:funlen
Value: res.Name,
},
{
Name: KSOCPrefix + "k8s:component:apiVersion",
Name: RADPrefix + "k8s:component:apiVersion",
Value: resList.APIVersion,
},
}

if resList.Namespaced {
properties = append(properties, cyclonedx.Property{
Name: KSOCPrefix + "k8s:component:namespace",
Name: RADPrefix + "k8s:component:namespace",
Value: res.Namespace,
})
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

const (
KSOCCompany = "RAD Security"
Company = "RAD Security"
BOMFormat = "rad"
SpecVersion = "0.3"

Expand Down Expand Up @@ -108,7 +108,7 @@ func generateKBOM(k8sClient kube.K8sClient) error {
SpecVersion: SpecVersion,
GeneratedAt: generatedAt,
GeneratedBy: model.Tool{
Vendor: KSOCCompany,
Vendor: Company,
BuildTime: config.BuildTime,
Name: config.AppName,
Version: config.AppVersion,
Expand Down
3 changes: 2 additions & 1 deletion cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/rad-security/kbom/internal/kube"
"github.com/rad-security/kbom/internal/model"
"github.com/stretchr/testify/assert"
)

func TestGenerateKBOM(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

const (
confDir = ".config/ksoc"
confDir = ".config/rad"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"encoding/json"

"github.com/invopop/jsonschema"
"github.com/rad-security/kbom/internal/model"
"github.com/spf13/cobra"

"github.com/rad-security/kbom/internal/model"
)

var schemaCmd = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cmd
import (
"fmt"

"github.com/rad-security/kbom/internal/config"
"github.com/spf13/cobra"

"github.com/rad-security/kbom/internal/config"
)

var versionCmd = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"bytes"
"testing"

"github.com/rad-security/kbom/internal/config"
"github.com/stretchr/testify/assert"

"github.com/rad-security/kbom/internal/config"
)

func TestVersion(t *testing.T) {
Expand Down
70 changes: 35 additions & 35 deletions docs/taxonomy.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
# Custom KSOC KBOM Taxonomy
# Custom RAD KBOM Taxonomy

This is the KSOC KBOM CycloneDX property namespace and name taxonomy. All of the namespaces are prefixed with `ksoc:kbom:`.
This is the RAD KBOM CycloneDX property namespace and name taxonomy. All of the namespaces are prefixed with `rad:kbom:`.

Following Taxonomy is used by the `KBOM` tool as extension to: [https://github.com/CycloneDX/cyclonedx-property-taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy).

## `ksoc:kbom:k8s:component` Namespace Taxonomy
## `rad:kbom:k8s:component` Namespace Taxonomy

| Namespace | Description |
| ------------------------------------ | ----------------------------------------------------------------- |
| `ksoc:kbom:k8s:component:apiVersion` | API Version of the Kubernetes component. |
| `ksoc:kbom:k8s:component:namespace` | Namespace of the Kubernetes component. |
| `rad:kbom:k8s:component:apiVersion` | API Version of the Kubernetes component. |
| `rad:kbom:k8s:component:namespace` | Namespace of the Kubernetes component. |

## `ksoc:kbom:k8s:cluster` Namespace Taxonomy
## `rad:kbom:k8s:cluster` Namespace Taxonomy

| Property | Description |
| ----------------------------------------- | ------------------------------ |
| `ksoc:kbom:k8s:cluster:location:name` | Name of the location. |
| `ksoc:kbom:k8s:cluster:location:region` | Region of the cluster. |
| `ksoc:kbom:k8s:cluster:location:zone` | Zone where cluster is located. |
| `rad:kbom:k8s:cluster:location:name` | Name of the location. |
| `rad:kbom:k8s:cluster:location:region` | Region of the cluster. |
| `rad:kbom:k8s:cluster:location:zone` | Zone where cluster is located. |

## `ksoc:kbom:k8s:node` Namespace Taxonomy
## `rad:kbom:k8s:node` Namespace Taxonomy

| Property | Description |
| -------------------------------------------------- | ------------------------------------ |
| `ksoc:kbom:k8s:node:osImage` | Node's operating system image |
| `ksoc:kbom:k8s:node:arch` | Node's architecture |
| `ksoc:kbom:k8s:node:kernel` | Node's kernel version |
| `ksoc:kbom:k8s:node:bootId` | Node's Boot identifier |
| `ksoc:kbom:k8s:node:type` | Node's type |
| `ksoc:kbom:k8s:node:operatingSystem` | Node's operating system |
| `ksoc:kbom:k8s:node:machineId` | Node's machine identifier |
| `ksoc:kbom:k8s:node:hostname` | Node's hostname |
| `ksoc:kbom:k8s:node:containerRuntimeVersion` | Node's container runtime version |
| `ksoc:kbom:k8s:node:kubeletVersion` | Node's kubelet version |
| `ksoc:kbom:k8s:node:kubeProxyVersion` | Node's kube proxy version |
| `ksoc:kbom:k8s:node:capacity:cpu` | Node's CPU capacity |
| `ksoc:kbom:k8s:node:capacity:memory` | Node's Memory capacity |
| `ksoc:kbom:k8s:node:capacity:pods` | Node's Pods capacity |
| `ksoc:kbom:k8s:node:capacity:ephemeralStorage` | Node's ephemeral storage capacity |
| `ksoc:kbom:k8s:node:allocatable:cpu` | Node's allocatable CPU |
| `ksoc:kbom:k8s:node:allocatable:memory` | Node's allocatable Memory |
| `ksoc:kbom:k8s:node:allocatable:pods` | Node's allocatable Pods |
| `ksoc:kbom:k8s:node:allocatable:ephemeralStorage` | Node's allocatable ephemeral storage |

## `ksoc:kbom:pkg` Namespace Taxonomy
| `rad:kbom:k8s:node:osImage` | Node's operating system image |
| `rad:kbom:k8s:node:arch` | Node's architecture |
| `rad:kbom:k8s:node:kernel` | Node's kernel version |
| `rad:kbom:k8s:node:bootId` | Node's Boot identifier |
| `rad:kbom:k8s:node:type` | Node's type |
| `rad:kbom:k8s:node:operatingSystem` | Node's operating system |
| `rad:kbom:k8s:node:machineId` | Node's machine identifier |
| `rad:kbom:k8s:node:hostname` | Node's hostname |
| `rad:kbom:k8s:node:containerRuntimeVersion` | Node's container runtime version |
| `rad:kbom:k8s:node:kubeletVersion` | Node's kubelet version |
| `rad:kbom:k8s:node:kubeProxyVersion` | Node's kube proxy version |
| `rad:kbom:k8s:node:capacity:cpu` | Node's CPU capacity |
| `rad:kbom:k8s:node:capacity:memory` | Node's Memory capacity |
| `rad:kbom:k8s:node:capacity:pods` | Node's Pods capacity |
| `rad:kbom:k8s:node:capacity:ephemeralStorage` | Node's ephemeral storage capacity |
| `rad:kbom:k8s:node:allocatable:cpu` | Node's allocatable CPU |
| `rad:kbom:k8s:node:allocatable:memory` | Node's allocatable Memory |
| `rad:kbom:k8s:node:allocatable:pods` | Node's allocatable Pods |
| `rad:kbom:k8s:node:allocatable:ephemeralStorage` | Node's allocatable ephemeral storage |

## `rad:kbom:pkg` Namespace Taxonomy

| Property | Description |
| --------------------------------- | -------------------------------------------------- |
| `ksoc:kbom:pkg:type` | Type of the package. |
| `ksoc:kbom:pkg:name` | Name of the package. |
| `ksoc:kbom:pkg:version` | Version of the package. |
| `ksoc:kbom:pkg:digest` | Digest of the package. |
| `rad:kbom:pkg:type` | Type of the package. |
| `rad:kbom:pkg:name` | Name of the package. |
| `rad:kbom:pkg:version` | Version of the package. |
| `rad:kbom:pkg:digest` | Digest of the package. |

0 comments on commit 47f7176

Please sign in to comment.