> [!IMPORTANT]
> KubeClarity has been deprecated and succeeded by [openclarity/openclarity](https://github.com/openclarity/openclarity).
>
> Check the [release statement](https://github.com/orgs/openclarity/discussions/882) for more information.
>
> **This project does not receive updates. We encourage you to migrate.**
KubeClarity is a tool for detection and management of Software Bill Of Materials (SBOM) and vulnerabilities of container images and filesystems. It scans both runtime K8s clusters and CI/CD pipelines for enhanced software supply chain security.

# Table of Contents
- [Why?](#why)
- [SBOM & Vulnerability detection challenges](#sbom--vulnerability-detection-challenges)
- [Solution](#solution)
- [Features](#features)
- [Integrated SBOM generators and vulnerability scanners](#integrated-sbom-generators-and-vulnerability-scanners)
- [Architecture](#architecture)
- [Getting Started](#getting-started)
- [KubeClarity Backend](#kubeclarity-backend)
- [Install using Helm](#install-using-helm)
- [Uninstall using Helm](#uninstall-using-helm)
- [Build and Run Locally with Demo Data](#build-and-run-locally-with-demo-data)
- [CLI](#cli)
- [Installation](#installation)
- [SBOM Generation](#sbom-generation)
- [Vulnerability Scanning](#vulnerability-scanning)
- [Exporting results to KubeClarity Backend](#exporting-results-to-kubeclarity-backend)
- [Advanced Configuration](#advanced-configuration)
- [SBOM generation using local docker image as input](#sbom-generation-using-local-docker-image-as-input)
- [Vulnerability scanning using local docker image as input](#vulnerability-scanning-using-local-docker-image-as-input)
- [Private Registry Support For CLI](#private-registry-support-for-cli)
- [Private Registry Support For K8s Runtime Scan](#private-registries-support-for-k8s-runtime-scan)
- [Merging of SBOM and vulnerabilities across different CI/CD stages](#merging-of-sbom-and-vulnerabilities-across-different-cicd-stages)
- [Output Different SBOM Formats](#output-different-sbom-formats)
- [Remote Scanner Servers For CLI](#remote-scanner-servers-for-cli)
- [Limitations](#limitations)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)
# Why?
## SBOM & Vulnerability Detection Challenges
* Effective vulnerability scanning requires an accurate Software Bill Of Materials (SBOM) detection:
* Various programming languages and package managers
* Various OS distributions
* Package dependency information is usually stripped upon build
* Which one is the best scanner/SBOM analyzer?
* What should we scan: Git repos, builds, container images or runtime?
* Each scanner/analyzer has its own format - how to compare the results?
* How to manage the discovered SBOM and vulnerabilities?
* How are my applications affected by a newly discovered vulnerability?
## Solution
* Separate vulnerability scanning into 2 phases:
* Content analysis to generate SBOM
* Scan the SBOM for vulnerabilities
* Create a pluggable infrastructure to:
* Run several content analyzers in parallel
* Run several vulnerability scanners in parallel
* Scan and merge results between different CI stages using KubeClarity CLI
* Runtime K8s scan to detect vulnerabilities discovered post-deployment
* Group scanned resources (images/directories) under defined applications to navigate the object tree dependencies (applications, resources, packages, vulnerabilities)
# Features
* Dashboard
* Fixable vulnerabilities per severity
* Top 5 vulnerable elements (applications, resources, packages)
* New vulnerabilities trends
* Package count per license type
* Package count per programming language
* General counters
* Applications
* Automatic application detection in K8s runtime
* Create/edit/delete applications
* Per application, navigation to related:
* Resources (images/directories)
* Packages
* Vulnerabilities
* Licenses in use by the resources
* Application Resources (images/directories)
* Per resource, navigation to related:
* Applications
* Packages
* Vulnerabilities
* Packages
* Per package, navigation to related:
* Applications
* Linkable list of resources and the detecting SBOM analyzers
* Vulnerabilities
* Vulnerabilities
* Per vulnerability, navigation to related:
* Applications
* Resources
* List of detecting scanners
* K8s Runtime scan
* On-demand or scheduled scanning
* Automatic detection of target namespaces
* Scan progress and result navigation per affected element (applications, resources, packages, vulnerabilities)
* CIS Docker benchmark
* CLI (CI/CD)
* SBOM generation using multiple integrated content analyzers (Syft, cyclonedx-gomod)
* SBOM/image/directory vulnerability scanning using multiple integrated scanners (Grype, Dependency-track)
* Merging of SBOM and vulnerabilities across different CI/CD stages
* Export results to KubeClarity backend
* API
* The API for KubeClarity can be found [here](https://github.com/openclarity/kubeclarity/blob/master/api/swagger.yaml)
## Integrated SBOM generators and vulnerability scanners
KubeClarity content analyzer integrates with the following SBOM generators:
* [Syft](https://github.com/anchore/syft)
* [Cyclonedx-gomod](https://github.com/CycloneDX/cyclonedx-gomod)
* [Trivy](https://github.com/aquasecurity/trivy)
KubeClarity vulnerability scanner integrates with the following scanners:
* [Grype](https://github.com/anchore/grype)
* [Dependency-Track](https://github.com/DependencyTrack/dependency-track)
* [Trivy](https://github.com/aquasecurity/trivy)
# Architecture

# Getting Started
## KubeClarity Backend
### Install using Helm:
1. Add Helm repo
```shell
helm repo add kubeclarity https://openclarity.github.io/kubeclarity
```
2. Save KubeClarity default chart values
```shell
helm show values kubeclarity/kubeclarity > values.yaml
```
3. Check the configuration in `values.yaml` and update the required values if
needed. To enable and configure the supported SBOM generators and
vulnerability scanners, please check the "analyzer" and "scanner" config under
the "vulnerability-scanner" section in Helm values.
4. Deploy KubeClarity with Helm
```shell
helm install --values values.yaml --create-namespace kubeclarity kubeclarity/kubeclarity -n kubeclarity
```
or for OpenShift Restricted SCC compatible install:
```shell
helm install --values values.yaml --create-namespace kubeclarity kubeclarity/kubeclarity -n kubeclarity --set global.openShiftRestricted=true \
--set kubeclarity-postgresql.securityContext.enabled=false --set kubeclarity-postgresql.containerSecurityContext.enabled=false \
--set kubeclarity-postgresql.volumePermissions.enabled=true --set kubeclarity-postgresql.volumePermissions.securityContext.runAsUser="auto" \
--set kubeclarity-postgresql.shmVolume.chmod.enabled=false
```
3. Port forward to KubeClarity UI:
```shell
kubectl port-forward -n kubeclarity svc/kubeclarity-kubeclarity 9999:8080
```
4. Open KubeClarity UI in the browser:
> **NOTE**
> KubeClarity requires these K8s permissions:
> | Permission | Reason |
> | --- | --- |
> | Read secrets in CREDS_SECRET_NAMESPACE (default: kubeclarity) | This is allow you to configure image pull secrets for scanning private image repositories. |
> | Read config maps in the KubeClarity deployment namespace. | This is required for getting the configured template of the scanner job. |
> | List pods in cluster scope. | This is required for calculating the target pods that need to be scanned. |
> | List namespaces. | This is required for fetching the target namespaces to scan in K8s runtime scan UI. |
> | Create & delete jobs in cluster scope. | This is required for managing the jobs that will scan the target pods in their namespaces. |
### Uninstall using Helm:
1. Helm uninstall
```shell
helm uninstall kubeclarity -n kubeclarity
```
2. Clean resources
By default, Helm will not remove the PVCs and PVs for the StatefulSets. Run the following command to delete them all:
```shell
kubectl delete pvc -l app.kubernetes.io/instance=kubeclarity -n kubeclarity
```
### Build and Run Locally with Demo Data
1. Build UI & backend and start the backend locally (2 options):
1. Using docker:
1. Build UI and backend (the image tag is set using VERSION):
```shell
VERSION=test make docker-backend
```
2. Run the backend using demo data:
```shell
docker run -p 8080:8080 -e FAKE_RUNTIME_SCANNER=true -e FAKE_DATA=true -e ENABLE_DB_INFO_LOGS=true -e DATABASE_DRIVER=LOCAL ghcr.io/openclarity/kubeclarity:test run
```
2. Local build:
1. Build UI and backend
```shell
make ui && make backend
```
2. Copy the built site:
```shell
cp -r ./ui/build ./site
```
3. Run the backend locally using demo data:
```shell
FAKE_RUNTIME_SCANNER=true DATABASE_DRIVER=LOCAL FAKE_DATA=true ENABLE_DB_INFO_LOGS=true ./backend/bin/backend run
```
2. Open KubeClarity UI in the browser:
## CLI
KubeClarity includes a CLI that can be run locally and especially useful for CI/CD pipelines.
It allows to analyze images and directories to generate SBOM, and scan it for vulnerabilities.
The results can be exported to KubeClarity backend.
### Installation
Binary Distribution
Download the release distribution for your OS from the
[releases page](https://github.com/openclarity/kubeclarity/releases)
Unpack the `kubeclarity-cli` binary, add it to your PATH, and you are good to go!
Docker Image
A Docker image is available at `ghcr.io/openclarity/kubeclarity-cli` with list of
available tags [here](https://github.com/openclarity/kubeclarity/pkgs/container/kubeclarity-cli/versions).
Local Compilation
```
make cli
```
Copy `./cli/bin/cli` to your PATH under `kubeclarity-cli`.