chen-keinan/kube-beacon

GitHub: chen-keinan/kube-beacon

kube-beacon 是一个基于 CIS Kubernetes Benchmark 规范的开源运行时安全审计扫描器,用于自动检查 K8s 集群的安全合规性并输出报告。

Stars: 69 | Forks: 8

[![Go 报告卡](https://goreportcard.com/badge/github.com/chen-keinan/beacon)](https://goreportcard.com/report/github.com/chen-keinan/beacon) [![许可证](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/chen-keinan/beacon/blob/main/LICENSE) [![构建状态](https://travis-ci.com/chen-keinan/kube-beacon.svg?branch=main)](https://travis-ci.com/chen-keinan/kube-beacon) [![覆盖率状态](https://coveralls.io/repos/github/chen-keinan/kube-beacon/badge.svg?branch=main)](https://coveralls.io/github/chen-keinan/kube-beacon?branch=main) [![Gitter](https://badges.gitter.im/kube-beacon/community.svg)](https://gitter.im/kube-beacon/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
kube-beacon 徽标
# Kube-Beacon 项目 ### 扫描您的 Kubernetes 运行时! Kube-Beacon 是一个开源审计扫描器,可对已部署的 Kubernetes 集群执行审计检查并输出安全报告。 审计测试是 [CIS Kubernetes Benchmark 规范](https://www.cisecurity.org/benchmark/kubernetes/) 的完整实现
新功能!!审计结果现在可以通过用户插件(使用 go plugin)作为 webhook 使用。 #### 审计检查在主节点和工作节点上执行,输出的审计报告包括: * 安全问题的根本原因 * 针对安全问题的建议补救措施 #### Kubernetes 集群审计扫描输出: ![k8s 审计](https://raw.githubusercontent.com/chen-keinan/kube-beacon/main/pkg/images/beacon.gif) * [安装](#installation) * [快速开始](#quick-start) * [Kube-beacon 作为 Docker 镜像](#Kube-beacon-as-Docker) * [Kube-beacon 作为 k8s 中的 Pod](#Kube-beacon-as-pod-in-k8s) * [用户插件用法](#user-plugin-usage) * [后续步骤](#Next-steps) ## 安装 ``` git clone https://github.com/chen-keinan/kube-beacon cd kube-beacon make build ``` - 注意:kube-beacon 需要以 root 用户身份执行 ## 快速开始 不带任何标志执行 kube-beacon,运行所有测试 ``` ./kube-beacon ``` 带标志执行 kube-beacon,按需运行测试 ``` Usage: kube-Beacon [--version] [--help] [] Available commands are: -r , --report : run audit tests and generate failure report -i , --include: execute only specific audit test, example -i=1.2.3,1.4.5 -e , --exclude: ignore specific audit tests, example -e=1.2.3,1.4.5 -n , --node: execute audit tests on specific node, example -n=master,-n=worker -s , --spec: execute specific audit tests spec, example -s=gke, default=k8s -v , --version: execute specific audit tests spec version, example -v=1.1.0,default=1.6.0 ``` 执行测试并生成失败测试报告 ``` ./kube-beacon -r ``` ## Kube-beacon 作为 k8s 中的 Pod - 在 k8s 集群中将 kube beacon 作为 Pod 执行 - 添加集群角色绑定,角色为 cluster-admin ``` kubectl create clusterrolebinding default-admin --clusterrole cluster-admin --serviceaccount=default:default ``` ``` cd jobs ``` - 简单的 k8s 集群运行以下 Job ``` kubectl apply -f k8s.yaml ``` - GKE 集群运行以下 Job ``` kubectl apply -f gke.yaml ``` - 检查 k8s Pod 状态 ``` kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default kube-beacon-sc8g9 0/1 Completed 0 111s kube-system event-exporter-gke-8489df9489-skcvv 2/2 Running 0 7m24s kube-system fluentd-gke-7d5sl 2/2 Running 0 7m6s kube-system fluentd-gke-f6q5d 2/2 Running 0 6m59s ``` - 检查 k8s Pod 审计输出 ``` kubectl logs kube-beacon-sc8g9 ``` - 清理(删除角色和 Pod) ``` kubectl delete clusterrolebinding default-admin ``` ``` kubectl delete -f k8s.yaml ``` ## 用户插件用法 Kube-Beacon 为用户插件提供钩子 [示例](https://github.com/chen-keinan/kube-beacon/tree/master/examples/plugins): - **K8sBenchAuditResultHook** - 此钩子接受审计报告中找到的审计基准测试结果 ##### 编译用户插件 ``` go build -buildmode=plugin -o=~//bench_plugin.so //bench_plugin.go ``` ##### 将插件复制到文件夹(.beacon 文件夹在首次启动时创建) ``` cp //bench_plugin.so ~/.beacon/plugins/compile/bench_plugin.so ``` 注意:插件和可执行文件必须在相同的 Linux 环境下编译 ## 后续步骤 - 添加对 Amazon EKS 扫描的支持
标签:Anthropic, Chrome Headless, CIS基准, Docker, EVTX分析, Go语言, Kubernetes安全, Webhook插件, Web截图, 二进制发布, 子域名突变, 安全报告, 安全防御评估, 容器安全, 开源工具, 日志审计, 程序破解, 请求拦截, 运行时扫描