Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
kube-linter — KubeLinter 是一款静态分析工具,可检查 Kubernetes YAML 文件和 Helm charts,以确保其中描述的应用遵循最佳实践。 | Kitploit
工具/GitHubGitHub/stackrox/kube-linter
静态分析容器安全配置审计云安全DevSecOps错误配置
GitHubstackrox/kube-linter

kube-linter

KubeLinter 是一款静态分析工具,可检查 Kubernetes YAML 文件和 Helm charts,以确保其中描述的应用遵循最佳实践。

查看仓库
3.5k2733天前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
网站

Kubernetes 静态分析

Go Report Card

什么是 KubeLinter?

KubeLinter 分析 Kubernetes YAML 文件、Helm Chart 和 Kustomize 清单,并根据各种最佳实践(重点关注生产就绪性和安全性)对其进行检查。

KubeLinter 运行合理的默认检查,旨在为你提供有关 Kubernetes YAML 文件、Helm Chart 和 Kustomize 清单的有用信息。这有助于团队尽早且频繁地检查安全错误配置和 DevOps 最佳实践。一些常见的示例包括以非 root 用户运行容器、强制最小权限原则,以及仅将敏感信息存储在 Secret 中。

KubeLinter 是可配置的,因此你可以根据组织内要遵循的策略,启用和禁用检查,以及创建自己的自定义检查。

当 lint 检查失败时,KubeLinter 会报告如何解决任何潜在问题的建议,并返回非零退出码。

文档

请访问 https://docs.kubelinter.io 获取有关安装、使用和配置 KubeLinter 的详细文档。

安装 KubeLinter

Kube-linter 二进制文件可在此处找到:https://github.com/stackrox/kube-linter/releases/latest

使用 Go

要使用 Go 进行安装,请运行以下命令:

root@kitploit:~
go install golang.stackrox.io/kube-linter/cmd/kube-linter@latest

或者,从 Releases 下载最新二进制文件,并将其添加到你的 PATH 中。

在 macOS 上使用 Homebrew 或在 Linux 上使用 LinuxBrew

要使用 Homebrew 或 LinuxBrew 进行安装,请运行以下命令:

root@kitploit:~
brew install kube-linter

使用 nix-shell

root@kitploit:~
nix-shell -p kube-linter

使用 docker

root@kitploit:~
docker pull stackrox/kube-linter:latest

开发

前提条件

  • 确保在从源码构建之前,你已经安装了 Go。

构建 KubeLinter

从源码安装 KubeLinter 只需遵循以下步骤:

  1. 首先,克隆 KubeLinter 仓库。

    root@kitploit:~
    git clone [email protected]:stackrox/kube-linter.git
    
  2. 然后,编译源代码。这将会为每个平台创建 kube-linter 二进制文件,并将它们放置在 .gobin 目录中。

    root@kitploit:~
    make build
    
  3. 最后,你就可以开始使用 KubeLinter 了。验证你的版本,以确保你已成功安装 KubeLinter。

    root@kitploit:~
    .gobin/kube-linter version
    

测试 KubeLinter

KubeLinter 的测试分为多个层次,每一层都应通过。

  1. go 单元测试:

    root@kitploit:~
    make test
    
  2. 端到端集成测试:

    root@kitploit:~
    make e2e-test
    
  3. 最后,使用 bats-core 进行端到端集成测试:

    root@kitploit:~
    make e2e-bats
    

验证 KubeLinter 镜像

KubeLinter 镜像由 cosign 签名。我们建议在使用镜像前进行验证。

安装 cosign 后,你可以使用 KubeLinter 公钥 通过以下命令验证 KubeLinter 镜像:

root@kitploit:~
cat kubelinter-cosign.pub
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEl0HCkCRzYv0qH5QiazoXeXe2qwFX
DmAszeH26g1s3OSsG/focPWkN88wEKQ5eiE95v+Z2snUQPl/mjPdvqpyjA==
-----END PUBLIC KEY-----


cosign verify --key kubelinter-cosign $IMAGE_NAME

KubeLinter 还提供 cosign 无密钥签名。

你可以使用以下命令验证 KubeLinter 镜像:

root@kitploit:~
# NOTE: Keyless signatures are NOT PRODUCTION ready.

COSIGN_EXPERIMENTAL=1 cosign verify $IMAGE_NAME

使用 KubeLinter

本地 YAML 检查

在最基本的形式下,使用 KubeLinter 检查(Lint)你的 YAML 文件只需两个步骤。

  1. 找到你想要测试其安全性和生产就绪最佳实践的 YAML 文件:

  2. 运行以下命令:

    root@kitploit:~
    kube-linter lint /path/to/your/yaml.yaml
    

示例

请考虑以下示例 Pod 规范文件 pod.yaml。该文件存在两个生产就绪问题和 一个安全问题:

安全问题:

  1. 此 Pod 中的容器未以只读文件系统运行,这可能导致它写入根文件系统。

生产就绪问题:

  1. 未设置容器的内存限制,这可能导致它消耗过多内存。

    root@kitploit:~
    apiVersion: v1
    kind: Pod
    metadata:
      name: security-context-demo
    spec:
      securityContext:
        runAsUser: 1000
        runAsGroup: 3000
        fsGroup: 2000
      volumes:
      - name: sec-ctx-vol
        emptyDir: {}
      containers:
      - name: sec-ctx-demo
        image: busybox
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
        command: [ "sh", "-c", "sleep 1h" ]
        volumeMounts:
        - name: sec-ctx-vol
          mountPath: /data/demo
        securityContext:
          allowPrivilegeEscalation: false
    
  2. 将上面的 YAML 复制到 pod.yaml 文件中,并通过运行以下命令对该文件进行 lint 检查:

    root@kitploit:~
    kube-linter lint pod.yaml
    
  3. KubeLinter 会运行其默认检查并报告建议。以下是上述命令的输出。

    root@kitploit:~
    pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) The container "sec-ctx-demo" is using an invalid container image, "busybox". Please use images that are not blocked by the `BlockList` criteria : [".*:(latest)$" "^[^:]*$" "(.*/[^:]+)$"] (check: latest-tag, remediation: Use a container image with a specific tag other than latest.)
    
    pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in the container securityContext.)
    
    pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" has memory limit 0 (check: unset-memory-requirements, remediation: Set memory limits for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)
    
    Error: found 3 lint errors
    

多种输出格式

KubeLinter 支持在单次运行中生成多种输出格式。这对于同时生成人类可读和机器可读的报告非常有用:

root@kitploit:~
kube-linter lint \
  --format sarif --output kube-linter.sarif \
  --format json --output kube-linter.json \
  --config .kube-linter.yaml \
  pod.yaml

此命令将会:

  • 在 kube-linter.sarif 中生成 SARIF 格式的报告
  • 在 kube-linter.json 中生成 JSON 格式的报告
  • 只处理一次文件,从而提高效率

注意: 多种格式需要显式指定 --output 标志。若要将单一格式输出到 stdout,只需使用一个 --format 标志,无需 --output。

有关使用多种输出格式的更多详细信息,请参阅文档。

要了解更多关于使用和配置 KubeLinter 的信息,请访问文档页面。

相关推荐/教程

以下是用户撰写的关于 KubeLinter 的教程。如果你有想添加到这个列表的内容,请提交 PR!

  • 使用 KubeLinter 确保 YAML 最佳实践,发布于 civo.com,作者 Saiyam Pathak。
  • 使用 KubeLinter 分析 Kubernetes 文件中的错误,发布于 opensource.com,作者 Jessica Cherry。
  • 如何在 KubeLinter 中添加新的检查?,作者 Priyanka Saggu。
  • 扩展 kube-linter 以构建自定义模板,作者 Gareth Healy。

许可证

KubeLinter 根据 Apache License 2.0 获得许可。

社区

如果你想与 KubeLinter 社区(包括维护者和其他用户)互动,可以在此加入 Slack 工作区。

未来命令用法、标志和配置文件格式可能会有破坏性变更。不过,我们鼓励你使用 KubeLinter 测试你的环境 YAML 文件,看看哪里会出问题,并贡献代码。

提醒一下,所有参与 KubeLinter 社区的行为都受我们的行为准则约束。


KubeLinter 由 StackRox 以 ❤️ 创建,现在由 Red Hat 提供支持。

下载工具