cbomkit/cbomkit-theia
GitHub: cbomkit/cbomkit-theia
一款用于检测容器镜像及目录中的加密资产并生成或丰富加密物料清单(CBOM)的工具。
Stars: 34 | Forks: 13
# CBOMkit-theia
[](https://opensource.org/licenses/Apache-2.0)
此仓库包含 CBOMkit-theia:一个用于检测容器镜像和目录中的加密资产并生成 [CBOM](https://cyclonedx.org/capabilities/cbom/) 的工具。
```
██████╗██████╗ ██████╗ ███╗ ███╗██╗ ██╗██╗████████╗████████╗██╗ ██╗███████╗██╗ █████╗
██╔════╝██╔══██╗██╔═══██╗████╗ ████║██║ ██╔╝██║╚══██╔══╝╚══██╔══╝██║ ██║██╔════╝██║██╔══██╗
██║ ██████╔╝██║ ██║██╔████╔██║█████╔╝ ██║ ██║█████╗██║ ███████║█████╗ ██║███████║
██║ ██╔══██╗██║ ██║██║╚██╔╝██║██╔═██╗ ██║ ██║╚════╝██║ ██╔══██║██╔══╝ ██║██╔══██║
╚██████╗██████╔╝╚██████╔╝██║ ╚═╝ ██║██║ ██╗██║ ██║ ██║ ██║ ██║███████╗██║██║ ██║
╚═════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═╝ by IBM Research
CBOMkit-theia analyzes cryptographic assets in a container image or directory.
It is part of cbomkit (https://github.com/cbomkit/cbomkit) donated to PQCA by IBM Research.
--> Disclaimer: CBOMkit-theia does *not* perform source code scanning <--
--> Use https://github.com/cbomkit/sonar-cryptography for source code scanning <--
Features
- Find certificates in your image/directory
- Find keys in your image/directory
- Find secrets in your image/directory
- Verify the executability of cryptographic assets in a CBOM (requires --bom to be set)
- Output: Enriched CBOM to stdout/console
Supported image/filesystem sources:
- local directory
- local application with dockerfile (ready to be build)
- local docker image from docker daemon
- local docker image as TAR archive
- local OCI image as directory
- local OCI image as TAR archive
- OCI image from OCI registry
- docker image
- image from singularity
Supported BOM formats (input & output):
- CycloneDXv1.6
Examples:
cbomkit-theia dir my/cool/directory
cbomkit-theia image nginx
Plugin Explanations:
> "certificates": Certificate File Plugin
Find x.509 certificates
> "javasecurity": java.security Plugin
Verify the executability of cryptographic assets from Java code
Adds a confidence level (0-1) to the CBOM components to show how likely it is that this component is actually executable
> "secrets": Secret Detection Plugin
Find secrets & keys (private, public and secret keys)
> "opensslconf": OpenSSL Configuration Plugin
Reads OpenSSL configuration files and adds tls protocol and cipher suites to CBOM
Usage:
cbomkit-theia [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
dir Analyze cryptographic assets in a directory
help Help about any command
image Analyze cryptographic assets in a container image
Flags:
-b, --bom string BOM file to be verified and enriched
--config string config file (default is $HOME/.cbomkit-theia.yaml)
-h, --help help for cbomkit-theia
--ignore strings file path patterns to ignore during scanning (glob syntax, e.g. 'testdata/,*.tmp')
-p, --plugins strings list of plugins to use (default [certificates,javasecurity,secrets,opensslconf,keys,vex])
--schema string BOM schema to validate the given BOM (default "provider/cyclonedx/bom-1.6.schema.json")
Use "cbomkit-theia [command] --help" for more information about a command.
```
## 前置条件
- Go
- 版本:`1.25` 或更高
- Docker(或类似的容器运行时)
- 推荐:设置 `DOCKER_HOST` 环境变量(默认:`unix:///var/run/docker.sock`)
## 运行
### Docker
```
docker build -t cbomkit-theia .
# CLI
docker run cbomkit-theia [command] > enriched_CBOM.json
```
### 编译
```
go mod download
go build
./cbomkit-theia [command] > enriched_CBOM.json
```
## 配置
CBOMkit-theia 从 `$HOME/.cbomkit-theia/config.yaml` 读取其配置。该文件会在首次运行时自动创建。
### 插件
默认情况下,所有可用插件均已启用:
- certificates
- javasecurity
- secrets(私钥、公钥和密钥)
- opensslconf
**重要提示:** 应用程序配置为确保所有插件始终可用。如果您手动编辑配置文件以排除特定插件,CBOMkit-theia 将检测到这一点,并在下次运行时自动将所有插件恢复为默认启用状态。如果您需要在特定运行中禁用特定插件,请使用 `-p` 标志而不是修改配置文件:
```
# 仅使用特定插件运行
./cbomkit-theia image nginx -p certificates -p secrets
```
### 忽略文件
要在扫描期间跳过某些文件(例如测试固件或开发产物),您可以使用 glob 语法指定忽略模式。模式可以通过三个来源提供,它们将被合并:
**1. `.cbomkitignore` 文件**(放置在扫描目录的根目录,采用 gitignore 风格):
```
# 跳过测试固件
testdata/
*_test_cert.pem
# 跳过 vendor/dependency 目录
vendor/
node_modules/
# 跳过开发机密
.env
*.key.dev
```
**2. 配置文件**(`$HOME/.cbomkit-theia/config.yaml`):
```
ignore:
- testdata/
- "*.tmp"
- vendor/
```
**3. CLI 标志**(`--ignore`):
```
cbomkit-theia dir ./myproject --ignore "testdata/,*.tmp,vendor/"
```
模式支持 [doublestar](https://github.com/bmatcuk/doublestar) glob 语法(例如 `**/*.pdf`、`*.tmp`、`dir/`)。以 `#` 开头的行被视为注释。末尾的 `/` 匹配任何具有该目录前缀的路径。
## 开发
### 插件
- `java.security` 配置插件:
- 在文件系统中搜索 `java.security` 文件并读取配置
- 读取 `jdk.tls.disabledAlgorithms` 属性并检查给定 CBOM 中是否使用了任何这些算法
- 根据结果,为 CBOM 中受限制(或未受限制)的算法分配一个置信度(`confidence_level`)
- 更高的置信度意味着组件更有可能是可执行的
- OpenSSL 配置插件:
- 在文件系统中搜索 OpenSSL 配置文件(例如 `openssl.cnf`)
- 当检测到 `openssl.cnf` 文件时,将对其进行扫描并创建一个文件组件作为 CBOM 的一部分
- 提取 OpenSSL 配置中配置的 TLS 协议版本和密码套件,并将其添加到 CBOM 中
- X.509 证书插件:
- 在文件系统中搜索 X.509 证书
- 将证书、签名算法、公钥和公钥算法添加到 CBOM 中
- 密钥插件:
- 利用 [gitleaks](https://github.com/gitleaks/gitleaks) 在数据源中查找密钥和钥匙
- 将密钥和钥匙(私钥、公钥和秘密密钥)添加到 CBOM 中
可以通过实现 [`cbomkit-theia/scanner/plugins`](./scanner/plugins/plugin.go#L41) 中的 `Plugin` 接口并将插件构造函数添加到 [`cbomkit-theia/scanner/scanner.go`](./scanner/scanner.go#L58) 的 `GetAllPluginConstructors` 函数中来添加更多插件:
## 安全免责声明
CBOMkit-theia 根据用户输入执行多次文件系统读取,并可能将这些文件的内容打印到 stderr 控制台。请勿在不受信任的输入上使用此工具或将输出提供给不受信任的方。
## 贡献指南
如果您想为 CBOMkit-theia 做出贡献,请查看我们的[贡献指南](CONTRIBUTING.md)。参与意味着您承诺遵守我们的[行为准则](CODE_OF_CONDUCT.md)。
我们使用 [GitHub issues](https://github.com/cbomkit/cbomkit-theia/issues) 来跟踪请求和错误。如有疑问,请使用 [GitHub Discussions](https://github.com/cbomkit/cbomkit-theia/discussions) 发起讨论。
## 许可证
[Apache License 2.0](LICENSE)
标签:CBOM, CycloneDX, DevSecOps, EVTX分析, IBM Research, PQCA, Web截图, 上游代理, 云安全监控, 前端正则化, 加密资产检测, 容器安全, 容器镜像分析, 密码学, 手动系统调用, 日志审计, 请求拦截, 跌倒检测, 软件物料清单, 静态分析