# manmathbh/kubescape architecture

> Architecture diagram of the GitHub repository manmathbh/kubescape, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manmathbh/kubescape
- Repository: https://github.com/manmathbh/kubescape

## Overview

Kubescape is a Kubernetes security platform: users invoke the CLI to scan clusters, manifests, repositories, or images, then inspect or export posture and vulnerability findings. The scan engine gathers resources, evaluates policies, prioritizes results, and supports remediation, image patching, admission-policy management, runtime monitoring, and MCP-based AI integration. The graph follows relationships visible in the excerpts, SOURCE INDEX, or README; several documented capabilities have no sampled implementation links, so those links are marked unverified.

Main entry points: [`core/core/scan.go`](https://github.com/manmathbh/kubescape/blob/master/core/core/scan.go) (Scan orchestration), [`cmd/scan/scan.go`](https://github.com/manmathbh/kubescape/blob/master/cmd/scan/scan.go) (Scan command), [`core/core/image_scan.go`](https://github.com/manmathbh/kubescape/blob/master/core/core/image_scan.go) (Image vulnerability scan), [`cmd/root.go`](https://github.com/manmathbh/kubescape/blob/master/cmd/root.go) (Kubescape CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and API"]
  node_cli["Kubescape CLI<br/>[root.go]"]
  node_scan_command["Scan command<br/>[scan.go]"]
  node_http_api["HTTP scan API<br/>[requestshandler.go]"]
end

subgraph group_scanning["Scan inputs"]
  node_scan_engine["Scan orchestration<br/>[scan.go]"]
  node_resource_collection["Resource collection"]
  node_cluster_scan["Cluster scanning<br/>[scan.go]"]
  node_manifest_scan["Manifest and repo scans<br/>[local_input.go]"]
  node_image_scan["Image vulnerability scan<br/>[image_scan.go]"]
end

subgraph group_analysis["Security analysis"]
  node_policy_engine["OPA policy evaluation"]
  node_prioritization["Finding prioritization"]
  node_network_analysis["Network exposure analysis<br/>[reachability.go]"]
  node_rbac_analysis["RBAC escalation analysis<br/>[escalation.go]"]
  node_vulnerability_exposure["Vulnerability exposure<br/>[correlate.go]"]
end

subgraph group_response["Results and remediation"]
  node_result_handling["Result handling<br/>[results.go]"]
  node_result_printers["Report exporters<br/>[printresults.go]"]
  node_remediation["Manifest remediation<br/>[fixhandler.go]"]
  node_image_patching["Image patching<br/>[patch.go]"]
end

subgraph group_platform["Platform integrations"]
  node_admission_policies["Admission policies<br/>[vap.go]"]
  node_runtime_monitoring["Runtime monitoring<br/>[tracer.go]"]
  node_mcp_server["AI MCP server<br/>[mcpserver.go]"]
end

node_user(("User"))
node_kubernetes[("Kubernetes cluster")]
node_image_registry[("Image registry")]

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_scan_command
node_scan_command -->|"starts scan"| node_scan_engine
node_scan_engine -->|"collects resources"| node_resource_collection
node_scan_engine -->|"evaluates policies"| node_policy_engine
node_scan_engine -->|"prioritizes findings"| node_prioritization
node_scan_engine -->|"scans images"| node_image_scan
node_policy_engine -.->|"produces findings"| node_result_handling
node_result_handling -.->|"formats reports"| node_result_printers
node_scan_command -->|"supports cluster"| node_cluster_scan
node_scan_command -->|"supports files"| node_manifest_scan
node_scan_command -->|"supports images"| node_image_scan
node_user -.->|"submits scans"| node_http_api
node_http_api -->|"runs scan"| node_scan_engine
node_kubernetes -.->|"provides resources"| node_resource_collection
node_image_registry -.->|"provides images"| node_image_scan
node_user -->|"requests fixes"| node_remediation
node_user -->|"requests patches"| node_image_patching
node_user -->|"manages policies"| node_admission_policies
node_user -->|"uses runtime security"| node_runtime_monitoring
node_user -->|"uses AI integration"| node_mcp_server
node_scan_engine -.->|"assesses exposure"| node_network_analysis
node_scan_engine -.->|"assesses escalation"| node_rbac_analysis
node_scan_engine -.->|"correlates exposure"| node_vulnerability_exposure

click node_cli "https://github.com/manmathbh/kubescape/blob/master/cmd/root.go"
click node_scan_command "https://github.com/manmathbh/kubescape/blob/master/cmd/scan/scan.go"
click node_http_api "https://github.com/manmathbh/kubescape/blob/master/httphandler/handlerequests/v1/requestshandler.go"
click node_scan_engine "https://github.com/manmathbh/kubescape/blob/master/core/core/scan.go"
click node_resource_collection "https://github.com/manmathbh/kubescape/tree/master/core/pkg/resourcehandler"
click node_cluster_scan "https://github.com/manmathbh/kubescape/blob/master/cmd/scan/scan.go"
click node_manifest_scan "https://github.com/manmathbh/kubescape/blob/master/cmd/scan/local_input.go"
click node_image_scan "https://github.com/manmathbh/kubescape/blob/master/core/core/image_scan.go"
click node_policy_engine "https://github.com/manmathbh/kubescape/blob/master/core/pkg/opaprocessor/processorhandler.go"
click node_prioritization "https://github.com/manmathbh/kubescape/blob/master/core/pkg/resourcesprioritization/prioritizationhandler.go"
click node_network_analysis "https://github.com/manmathbh/kubescape/blob/master/core/pkg/networkpolicy/reachability.go"
click node_rbac_analysis "https://github.com/manmathbh/kubescape/blob/master/core/pkg/rbacgraph/escalation.go"
click node_vulnerability_exposure "https://github.com/manmathbh/kubescape/blob/master/core/pkg/vulnexposure/correlate.go"
click node_result_handling "https://github.com/manmathbh/kubescape/blob/master/core/pkg/resultshandling/results.go"
click node_result_printers "https://github.com/manmathbh/kubescape/blob/master/core/pkg/resultshandling/printer/v2/printresults.go"
click node_remediation "https://github.com/manmathbh/kubescape/blob/master/core/pkg/fixhandler/fixhandler.go"
click node_image_patching "https://github.com/manmathbh/kubescape/blob/master/cmd/patch/patch.go"
click node_admission_policies "https://github.com/manmathbh/kubescape/blob/master/cmd/vap/vap.go"
click node_runtime_monitoring "https://github.com/manmathbh/kubescape/blob/master/core/pkg/hostsensorutils/ebpf/tracer.go"
click node_mcp_server "https://github.com/manmathbh/kubescape/blob/master/cmd/mcpserver/mcpserver.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_scan_command,node_http_api,node_user toneBlue
class node_scan_engine,node_resource_collection,node_cluster_scan,node_manifest_scan,node_image_scan,node_kubernetes,node_image_registry toneAmber
class node_policy_engine,node_prioritization,node_network_analysis,node_rbac_analysis,node_vulnerability_exposure toneMint
class node_result_handling,node_result_printers,node_remediation,node_image_patching toneRose
class node_admission_policies,node_runtime_monitoring,node_mcp_server toneIndigo
```

## Components

### CLI and API

- [Kubescape CLI](https://github.com/manmathbh/kubescape/blob/master/cmd/root.go): `cmd/root.go`
- [Scan command](https://github.com/manmathbh/kubescape/blob/master/cmd/scan/scan.go): `cmd/scan/scan.go`
- [HTTP scan API](https://github.com/manmathbh/kubescape/blob/master/httphandler/handlerequests/v1/requestshandler.go): `httphandler/handlerequests/v1/requestshandler.go`

### Scan inputs

- [Scan orchestration](https://github.com/manmathbh/kubescape/blob/master/core/core/scan.go): `core/core/scan.go`
- [Resource collection](https://github.com/manmathbh/kubescape/tree/master/core/pkg/resourcehandler): `core/pkg/resourcehandler`
- [Cluster scanning](https://github.com/manmathbh/kubescape/blob/master/cmd/scan/scan.go): `cmd/scan/scan.go`
- [Manifest and repo scans](https://github.com/manmathbh/kubescape/blob/master/cmd/scan/local_input.go): `cmd/scan/local_input.go`
- [Image vulnerability scan](https://github.com/manmathbh/kubescape/blob/master/core/core/image_scan.go): `core/core/image_scan.go`

### Security analysis

- [OPA policy evaluation](https://github.com/manmathbh/kubescape/blob/master/core/pkg/opaprocessor/processorhandler.go): `core/pkg/opaprocessor/processorhandler.go`
- [Finding prioritization](https://github.com/manmathbh/kubescape/blob/master/core/pkg/resourcesprioritization/prioritizationhandler.go): `core/pkg/resourcesprioritization/prioritizationhandler.go`
- [Network exposure analysis](https://github.com/manmathbh/kubescape/blob/master/core/pkg/networkpolicy/reachability.go): `core/pkg/networkpolicy/reachability.go`
- [RBAC escalation analysis](https://github.com/manmathbh/kubescape/blob/master/core/pkg/rbacgraph/escalation.go): `core/pkg/rbacgraph/escalation.go`
- [Vulnerability exposure](https://github.com/manmathbh/kubescape/blob/master/core/pkg/vulnexposure/correlate.go): `core/pkg/vulnexposure/correlate.go`

### Results and remediation

- [Result handling](https://github.com/manmathbh/kubescape/blob/master/core/pkg/resultshandling/results.go): `core/pkg/resultshandling/results.go`
- [Report exporters](https://github.com/manmathbh/kubescape/blob/master/core/pkg/resultshandling/printer/v2/printresults.go): `core/pkg/resultshandling/printer/v2/printresults.go`
- [Manifest remediation](https://github.com/manmathbh/kubescape/blob/master/core/pkg/fixhandler/fixhandler.go): `core/pkg/fixhandler/fixhandler.go`
- [Image patching](https://github.com/manmathbh/kubescape/blob/master/cmd/patch/patch.go): `cmd/patch/patch.go`

### Platform integrations

- [Admission policies](https://github.com/manmathbh/kubescape/blob/master/cmd/vap/vap.go): `cmd/vap/vap.go`
- [Runtime monitoring](https://github.com/manmathbh/kubescape/blob/master/core/pkg/hostsensorutils/ebpf/tracer.go): `core/pkg/hostsensorutils/ebpf/tracer.go`
- [AI MCP server](https://github.com/manmathbh/kubescape/blob/master/cmd/mcpserver/mcpserver.go): `cmd/mcpserver/mcpserver.go`

### Other components

- **User**
- **Kubernetes cluster**
- **Image registry**

## Connections

- User → Kubescape CLI: invokes (evidence: `cmd/root.go`)
- Kubescape CLI → Scan command: dispatches (evidence: `cmd/root.go`)
- Scan command → Scan orchestration: starts scan (evidence: `cmd/scan/scan.go`)
- Scan orchestration → Resource collection: collects resources (evidence: `core/core/scan.go`)
- Scan orchestration → OPA policy evaluation: evaluates policies (evidence: `core/core/scan.go`)
- Scan orchestration → Finding prioritization: prioritizes findings (evidence: `core/core/scan.go`)
- Scan orchestration → Image vulnerability scan: scans images (evidence: `core/core/scan.go`)
- OPA policy evaluation → Result handling: produces findings
- Result handling → Report exporters: formats reports
- Scan command → Cluster scanning: supports cluster (evidence: `README.md`)
- Scan command → Manifest and repo scans: supports files (evidence: `README.md`)
- Scan command → Image vulnerability scan: supports images (evidence: `README.md`)
- User → HTTP scan API: submits scans
- HTTP scan API → Scan orchestration: runs scan
- Kubernetes cluster → Resource collection: provides resources
- Image registry → Image vulnerability scan: provides images
- User → Manifest remediation: requests fixes (evidence: `README.md`)
- User → Image patching: requests patches (evidence: `README.md`)
- User → Admission policies: manages policies (evidence: `README.md`)
- User → Runtime monitoring: uses runtime security (evidence: `README.md`)
- User → AI MCP server: uses AI integration (evidence: `README.md`)
- Scan orchestration → Network exposure analysis: assesses exposure
- Scan orchestration → RBAC escalation analysis: assesses escalation
- Scan orchestration → Vulnerability exposure: correlates exposure
