首页 > 其他分享 >kubescape的使用

kubescape的使用

时间:2023-12-17 14:23:35浏览次数:55  
标签:control kubescape scan -- io 使用 scanner

1.使用

前言:Kubescape 是一个开源的 Kubernetes 安全平台。它包括风险分析、安全合规性和错误配置扫描。它面向 DevSecOps 从业者或平台工程师,提供易于使用的 CLI 界面、灵活的输出格式和自动扫描功能。它为 Kubernetes 用户和管理员节省了宝贵的时间、精力和资源。(摘自官网)

相关链接:官网github地址CNCF地址官网

1.1.安装

curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash

注:这里需要科学访问,否则容易执行失败或者速度过慢。

1.1执行扫描

kubescape scan --enable-host-scan   --format html --output results.html  --verbose
Flag --enable-host-scan has been deprecated, To activate the host scanner capability, proceed with the installation of the kubescape operator chart found here: https://github.com/kubescape/helm-charts/tree/main/charts/kubescape-operator. The flag will be removed at 1.Dec.2023
 ℹ️   Installing host scanner
 ✅  Initialized scanner
 ✅  Loaded policies
 ✅  Loaded exceptions
 ✅  Loaded account configurations
 ✅  Accessed Kubernetes objects
 ℹ️   Requesting Host scanner data
◐ ℹ️   Host scanner version : v1.0.61
 ✅  Requested Host scanner data
Control: C-0036 100% |████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (45/45, 16 it/s)
 ✅  Done scanning. Cluster: kubernetes-admin-kubernetes
 ✅  Done aggregating results
​
​
​
Kubescape security posture overview for cluster: kubernetes-admin-kubernetes
​
In this overview, Kubescape shows you a summary of your cluster security posture, including the number of users who can perform administrative actions. For each result greater than 0, you should evaluate its need, and then define an exception to allow it. This baseline can be used to detect drift in future.
​
Control plane
┌────┬─────────────────────────────────────┬────────────────────────────────────┐
│    │ Control name                        │ Docs                               │
├────┼─────────────────────────────────────┼────────────────────────────────────┤
│ ✅ │ API server insecure port is enabled │ https://hub.armosec.io/docs/c-0005 │
│ ❌ │ Anonymous access enabled            │ https://hub.armosec.io/docs/c-0262 │
│ ⚠️  │ Audit logs enabled                  │ https://hub.armosec.io/docs/c-0067 │
│ ⚠️  │ RBAC enabled                        │ https://hub.armosec.io/docs/c-0088 │
│ ⚠️  │ Secret/etcd encryption enabled      │ https://hub.armosec.io/docs/c-0066 │
└────┴─────────────────────────────────────┴────────────────────────────────────┘
* failed to get cloud provider, cluster: kubernetes-admin-kubernetes
​
Access control
┌─────────────────────────────────────────────────┬───────────┬────────────────────────────────────┐
│ Control name                                    │ Resources │ View details                       │
├─────────────────────────────────────────────────┼───────────┼────────────────────────────────────┤
│ Cluster-admin binding                           │     3     │ $ kubescape scan control C-0035 -v │
│ Data Destruction                                │     5     │ $ kubescape scan control C-0007 -v │
│ Exec into container                             │     4     │ $ kubescape scan control C-0002 -v │
│ List Kubernetes secrets                         │     9     │ $ kubescape scan control C-0015 -v │
│ Minimize access to create pods                  │     3     │ $ kubescape scan control C-0188 -v │
│ Minimize wildcard use in Roles and ClusterRoles │     3     │ $ kubescape scan control C-0187 -v │
│ Portforwarding privileges                       │     3     │ $ kubescape scan control C-0063 -v │
│ Validate admission controller (mutating)        │     0     │ $ kubescape scan control C-0039 -v │
│ Validate admission controller (validating)      │     1     │ $ kubescape scan control C-0036 -v │
└─────────────────────────────────────────────────┴───────────┴────────────────────────────────────┘
​
Secrets
┌─────────────────────────────────────────────────┬───────────┬────────────────────────────────────┐
│ Control name                                    │ Resources │ View details                       │
├─────────────────────────────────────────────────┼───────────┼────────────────────────────────────┤
│ Applications credentials in configuration files │     5     │ $ kubescape scan control C-0012 -v │
└─────────────────────────────────────────────────┴───────────┴────────────────────────────────────┘
​
Network
┌────────────────────────┬───────────┬────────────────────────────────────┐
│ Control name           │ Resources │ View details                       │
├────────────────────────┼───────────┼────────────────────────────────────┤
│ Missing network policy │    13     │ $ kubescape scan control C-0260 -v │
└────────────────────────┴───────────┴────────────────────────────────────┘
​
Workload
┌─────────────────────────┬───────────┬────────────────────────────────────┐
│ Control name            │ Resources │ View details                       │
├─────────────────────────┼───────────┼────────────────────────────────────┤
│ Host PID/IPC privileges │     0     │ $ kubescape scan control C-0038 -v │
│ HostNetwork access      │     2     │ $ kubescape scan control C-0041 -v │
│ HostPath mount          │     2     │ $ kubescape scan control C-0048 -v │
│ Non-root containers     │     7     │ $ kubescape scan control C-0013 -v │
│ Privileged container    │     2     │ $ kubescape scan control C-0057 -v │
└─────────────────────────┴───────────┴────────────────────────────────────┘
​
​
Highest-stake workloads
───────────────────────
​
High-stakes workloads are defined as those which Kubescape estimates would have the highest impact if they were to be exploited.
​
1. namespace: ingress-nginx, name: ingress-nginx-controller, kind: DaemonSet
   '$ kubescape scan workload DaemonSet/ingress-nginx-controller --namespace ingress-nginx'
2. namespace: kube-system, name: calico-node, kind: DaemonSet
   '$ kubescape scan workload DaemonSet/calico-node --namespace kube-system'
3. namespace: kube-system, name: openebs-lvm-node, kind: DaemonSet
   '$ kubescape scan workload DaemonSet/openebs-lvm-node --namespace kube-system'
​
​
Compliance Score
────────────────
​
The compliance score is calculated by multiplying control failures by the number of failures against supported compliance frameworks. Remediate controls, or configure your cluster baseline with exceptions, to improve this score.
​
* MITRE: 77.81%
* NSA: 64.96%
​
View a full compliance report by running '$ kubescape scan framework nsa' or '$ kubescape scan framework mitre'
​
​
What now?
─────────
​
* Run one of the suggested commands to learn more about a failed control failure
* Scan a workload with '$ kubescape scan workload' to see vulnerability information
* Install Kubescape in your cluster for continuous monitoring and a full vulnerability report: https://kubescape.io/docs/install-operator/
​
 ✅  Scan results saved. filename: results.html
​
#执行扫描时会在每个节点出现以下容器.
kubectl get pod -n kubescape  -owide
NAME                 READY   STATUS    RESTARTS   AGE   IP              NODE           NOMINATED NODE   READINESS GATES
host-scanner-2fqxz   1/1     Running   0          64s   172.16.58.206   k8s-node02     <none>           <none>
host-scanner-4cz4b   1/1     Running   0          64s   172.16.85.213   k8s-node01     <none>           <none>
host-scanner-kq4ln   1/1     Running   0          64s   172.16.32.132   k8s-master01   <none>           <none>

2.helm安装

官网helm:地址地址githubhelm官网部署方式

参数:github

helm repo add kubescape https://kubescape.github.io/helm-charts/
helm repo update
helm upgrade --install kubescape kubescape/kubescape-operator -n kubescape --create-namespace --set clusterName=`kubectl config current-context` 
Release "kubescape" does not exist. Installing it now.
NAME: kubescape
LAST DEPLOYED: Sun Dec 17 13:10:44 2023
NAMESPACE: kubescape
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing kubescape-operator version 1.16.5.
View your image vulnerabilities scan summaries:
> kubectl get vulnerabilitymanifestsummaries -A
​
Detailed reports are also available:
> kubectl get vulnerabilitymanifests -A

问题描述:这里遇到了查看kubescape命名空间下pod失败的日志,本次k8s集群版本为:v1.26.5.

kubectl get pod -n  kubescape
E1217 14:00:13.997846  413148 memcache.go:287] couldn't get resource list for spdx.softwarecomposition.kubescape.io/v1beta1: the server is currently unable to handle the request
E1217 14:00:14.008416  413148 memcache.go:121] couldn't get resource list for spdx.softwarecomposition.kubescape.io/v1beta1: the server is currently unable to handle the request
E1217 14:00:14.023351  413148 memcache.go:121] couldn't get resource list for spdx.softwarecomposition.kubescape.io/v1beta1: the server is currently unable to handle the request
E1217 14:00:14.039064  413148 memcache.go:121] couldn't get resource list for spdx.softwarecomposition.kubescape.io/v1beta1: the server is currently unable to handle the request
NAME                         READY   STATUS    RESTARTS   AGE
kubescape-66f67d9ccb-jv49l   1/1     Running   0          20m
kubevuln-76f4c4c5d8-cgzs7    1/1     Running   0          20m
node-agent-7glr4             1/1     Running   0          20m
node-agent-bhn2h             1/1     Running   0          20m
operator-dfd48955c-hwpdx     1/1     Running   0          20m
storage-94f878f9b-kg26j      1/1     Running   0          20m

标签:control,kubescape,scan,--,io,使用,scanner
From: https://www.cnblogs.com/-k8s/p/17909033.html

相关文章

  • 使用分布式锁实现定时任务的精确调度
    使用分布式锁实现定时任务的精确调度在分布式系统中,实现定时任务的精确调度是一项具有挑战性的任务。由于分布式环境中存在多个节点,传统的定时任务可能会出现并发执行、重复执行或者错过执行的问题。为了解决这些问题,我们可以使用分布式锁来实现定时任务的精确调度。准备工作在......
  • CMake 基础使用
    #ThisisaCMakeLists.txt#[[ThisisaCMakeLists.txtThisisaCMakeLists.txtThisisaCMakeLists.txt*CMake生成的make文件以及一些其他的乱七八糟的文件都在终端当前对应的目录中]]cmake_minimum_required(VERSION3.15)#最低CMake版本project(CMakeLe......
  • Android中使用Gson
    Gson是一个Java库,可用于将Java对象转换为它们的JSON表示。它还可以用于将JSON字符串转换为等效的Java对象。Gson可以处理任意Java对象,包括您没有源代码的已有对象。一、简单使用1.导入在Android的build.gradle中添加依赖:dependencies{implementation'com.google.code.......
  • 使用 Prometheus 监控 Memcached 最佳实践
    监控Memcached监控Memcached的重要性无法忽视。通过监控Memcached,我们可以及时了解到系统中的缓存命中率、缓存使用量和缓存访问频率等关键指标,从而更好地优化系统性能。同时,监控Memcached还可以帮助我们发现潜在的性能问题和内存泄漏,及时采取措施进行修复,保障系统的稳定运行。在......
  • ARM64技术 —— 系统调用指令SVC、HVC和SMC的使用规则
    来源:learn_the_architecture_-_aarch64_exception_model_102412_0103_01_en.pdf即:EL0不能调用SMC或者HVC这个从HVC和SMC指令的伪码中可以看到:HVCSMC......
  • 02.环境安装与使用
    目前mobile自动化解决方案iOSAndroidCalabash-iOScalabash-AndroidFrankMonkeyTalkUIAutomationRobotiumiOS-driverUIAutomatorKeepItFunctionalSelendroidMacacaMacacaAppiumAppium 自动化工具选择工具名称被测系统脚本语言是否支......
  • 使用Docker自定义配置部署RustDesk Server
    “RustDesk是一款可以平替TeamViewer的开源软件,旨在提供安全便捷的自建方案。”这是RustDesk官网对自己的描述。作为一款使用Rust语言开发的开源软件,在为数不多的Rust开发者和数量庞大的Rust学习者中还是有相当的知名度的,并且商业化的RustDeskPro也是如火如荼。开始docker......
  • Spring Boot Actuator 使用和常用配置
    转载请注明出处:SpringBootActuator是SpringBoot提供的一个非常强大的工具,它可以帮助我们监控和管理我们的SpringBoot应用。Actuator提供了一系列的端点,我们可以通过这些端点来查看我们的应用的运行状态,例如健康状态、指标、信息、数据库连接、Redis连接等等1.配置Spring......
  • 使用LM Studio在本地运行LLM完整教程
    GPT-4被普遍认为是最好的生成式AI聊天机器人,但开源模型一直在变得越来越好,并且通过微调在某些特定领域是可以超过GPT4的。在开源类别中出于以下的原因,你可能会考虑过在本地计算机上本地运行LLM:脱机:不需要互联网连接。模型访问:在本地运行模型,可以尝试开源模型(Llama2、Vicun......
  • 使用JS和SignalR完成双向通信
    写在前面:看官网介绍,听开发者朋友的感受,SignalR对websocket等多个长连接协议进行了封装,提供了多种方法,能够适应很多场合和复杂情况。单纯论简单的web长连接,它确实没有js/nodejs版的websocket直观、简单。微软的风格,一来就高大上,不知道又会劝退多少人,会不会把自己玩死。我帮你简单......