close

關於kubeaudit

kubeaudit是一款針對Kubernetes集群安全的審計工具,該工具基於命令行實現其功能,並通過Golang包幫助廣大研究人員審計Kubernetes集群中的各種安全問題,其中包括以非root權限運行或使用只讀root文件系統等等。

工具安裝Brew
brew install kubeaudit
下載源碼
廣大研究人員還可以直接訪問該項目的【Releases頁面】下載最新的官方穩定版。
自定義構建
該項目可能隨時會進行代碼更新,如需使用最新版本的功能,你可以選擇進行自定義構建,在構建前別忘了在本地設備上安裝並配置好Go v1.17+環境,然後運行下列命令:
go get -v github.com/Shopify/kubeaudit
Docker使用
該項目還提供了一個Docker鏡像:shopify/kubeaudit,廣大研究人員也可以通過Docker鏡像來運行kubeaudit。
工具使用
kubeaudit提供了以下三種模式:
1、Manifest模式
2、本地模式
3、集群模式
Manifest模式
我們可以通過「-f/--manifest」選項來給工具提供一個Kubernetes Manifest文件,此時kubeaudit將會審計這個Manifest文件。

參考命令如下:
kubeaudit all -f "/path/to/manifest.yml"
輸出結果如下:
$ kubeaudit all -f "internal/test/fixtures/all_resources/deployment-apps-v1.yml"---------------- Results for --------------- apiVersion: apps/v1 kind: Deployment metadata: name: deployment namespace: deployment-apps-v1---------------------------------------------- [error] AppArmorAnnotationMissing Message: AppArmor annotation missing. The annotation 'container.apparmor.security.beta.kubernetes.io/container' should be added. Metadata: Container: container MissingAnnotation: container.apparmor.security.beta.kubernetes.io/container-- [error] AutomountServiceAccountTokenTrueAndDefaultSA Message: Default service account with token mounted. automountServiceAccountToken should be set to 'false' or a non-default service account should be used.-- [error] CapabilityShouldDropAll Message: Capability not set to ALL. Ideally, you should drop ALL capabilities and add the specific ones you need to the add list. Metadata: Container: container Capability: AUDIT_WRITE...
如果沒有報錯並且沒有安全問題的話,則會返回下列內容:
All checks completed. 0 high-risk vulnerabilities found
自動修復
Manifest模式還支持使用「autofix」命令自動修復所有的安全問題:
kubeaudit autofix -f "/path/to/manifest.yml"
集群模式
kubeaudit支持檢測當前環境是否是集群中的一個容器,並嘗試審計該集群中所有的Kubernetes資源:
kubeaudit all
本地模式
kubeaudit將會使用本地kubeconfig文件($HOME/.kube/config)嘗試與一個集群進行連接,可以使用「--kubeconfig」選項來指定kubeconfig路徑:
kubeaudit all --kubeconfig "/path/to/config" --context my_cluster
許可證協議
本項目的開發與發布遵循MIT開源許可證協議。
項目地址
https://github.com/Shopify/kubeaudit
參考資料
https://pkg.go.dev/github.com/Shopify/kubeaudit
https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/


精彩推薦





arrow
arrow
    全站熱搜
    創作者介紹
    創作者 鑽石舞台 的頭像
    鑽石舞台

    鑽石舞台

    鑽石舞台 發表在 痞客邦 留言(0) 人氣()