# kubei
**Repository Path**: IMGet/kubei
## Basic Information
- **Project Name**: kubei
- **Description**: Kubei 是一个灵活的 Kubernetes 运行时扫描程序,扫描工作节点和 Kubernetes 节点的图像,提供准确的漏洞评估 Kubei 是一个漏洞扫描和 CIS Dock
- **Primary Language**: HTML/CSS
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: https://www.oschina.net/p/kubei
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2022-04-01
- **Last Updated**: 2022-04-01
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# KubeClarity

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.
## 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
* Automatic detection of target namespaces
* Scan progress and result navigation per affected element (applications, resources, packages, vulnerabilities)
* 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/cisco-open/kubei/blob/master/api/swagger.yaml)
## High level architecture

## Getting started
### Integration with 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)
KubeClarity vulnerability scanner integrates with the following scanners:
* [Grype](https://github.com/anchore/grype)
* [Dependency-Track](https://github.com/DependencyTrack/dependency-track)
The integrations with the SBOM generators can be found here [here](https://github.com/cisco-open/kubei/tree/master/shared/pkg/analyzer), and the integrations with the vulnerability scanners can be found here [here](https://github.com/cisco-open/kubei/tree/master/shared/pkg/scanner).
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.
Contributions of integrations with additional tools are more than welcome!
### Install KubeClarity in a K8s cluster using Helm:
1. Check the configuration in `charts/kubeclarity/values.yaml` and update the required values if needed.
2. Deploy KubeClarity with Helm:
```shell
helm install --values charts/kubeclarity/values.yaml --create-namespace kubeclarity charts/kubeclarity -n kubeclarity
```
3. Port forward to KubeClarity UI:
```shell
kubectl port-forward -n kubeclarity svc/kubeclarity-kubeclarity 9999:8080
```
4. Open KubeClarity UI in the browser:
### Required K8s permissions
1. Read secrets in cluster scope. This is required for getting image pull secrets for scanning private image repositories.
2. Read config maps in cluster scope. This is required for getting the configured template of the scanner job.
3. List pods in cluster scope. This is required for calculating the target pods that need to be scanned.
4. List namespaces. This is required for fetching the target namespaces to scan in K8s runtime scan UI.
5. Create & delete jobs in cluster scope. This is required for managing the jobs that will scan the target pods in their namespaces.
### 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_DATA=true -e ENABLE_DB_INFO_LOGS=true -e DATABASE_DRIVER=LOCAL ghcr.io/kubeclarity/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
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.
### Compilation
```
make cli
```
### SBOM generation using multiple integrated content analyzers
```
# A list of the content analyzers to use can be configured using the ANALYZER_LIST env variable seperated by a space (e.g ANALYZER_LIST="syft gomod")
./cli/bin/cli analyze --input-type -o