andresark/trendai-vision-one-code-security-showcase
GitHub: andresark/trendai-vision-one-code-security-showcase
一个展示 Trend Vision One Artifact Scanner 多能力的安全演示仓库,包含故意引入的漏洞与密钥。
Stars: 0 | Forks: 0
# TrendAI Vision One — 代码安全展示
## 你将看到的内容
本仓库包含一个**故意存在漏洞**的应用程序和容器镜像。
当 GitHub Actions 工作流运行时,它会生成 **5 个独立的扫描任务**,每个
展示 TMAS 的不同能力:
| # | 任务 | 发现内容 | 扫描类型 |
|---|------|----------|----------|
| 1 | **漏洞扫描 — 源代码** | npm、pip 和 Go 依赖中的 CVE | `tmas scan -V dir:.` |
| 2 | **密钥检测 — 源代码** | 硬编码的 API 密钥、密码、私钥 | `tmas scan -S dir:.` |
| 3 | **漏洞扫描 — 容器镜像** | 操作系统包 CVE + 镜像内应用依赖 CVE | `tmas scan -V -S docker:image` |
| 4 | **恶意软件检测 — 容器镜像** | 嵌入镜像层的 EICAR 测试恶意软件 | `tmas scan -M docker:image` |
| 5 | **策略评估 — 安全门禁** | 根据你的 Vision One 策略评估所有发现 | `tmas scan -V -S --evaluatePolicy dir:.` |
每个任务都会向 GitHub Actions UI 写入一个详细的**摘要卡片**,说明其作用、重要性以及如何解读结果。
## 快速开始(5 分钟)
### 前置条件
- 一个 [Trend Vision One](https://www.trendmicro.com/en_us/business/products/one-platform.html) 账户(可免费试用)
- 具有 **Artifact Scanner** 权限的 Vision One API 密钥
### 步骤 1 — Fork 或克隆本仓库
```
gh repo fork andresark/trendai-vision-one-code-security-showcase --clone
```
### 步骤 2 — 添加你的 API 密钥
前往你的 Fork 的 **Settings > Secrets and variables > Actions**,并创建
一个仓库密钥:
| 名称 | 值 |
|------|-------|
| `TMAS_API_KEY` | 你的 Vision One API 密钥 |
### 步骤 3 — 运行工作流
前往 **Actions > TMAS Security Scan Showcase > Run workflow**,然后点击
**Run workflow**。你也可以从下拉菜单中选择你的 Vision One 区域。
### 步骤 4 — 探索结果
工作流完成后,你将在侧边栏看到 5 个任务。点击每个任务以查看:
- **步骤日志** — 包含所有发现的完整 JSON 扫描报告
- **任务摘要** — 格式丰富的卡片,解释扫描了什么以及原因
- **工件** — 可下载的 CycloneDX 格式 SBOM
## 内容介绍
```
.
├── .github/workflows/
│ └── tmas-showcase.yml # The showcase workflow (5 scan jobs)
├── app/
│ ├── package.json # Node.js deps with known CVEs
│ ├── requirements.txt # Python deps with known CVEs
│ ├── go.mod # Go deps with known CVEs
│ └── server.js # App with planted secrets
├── overrides/
│ └── tmas_overrides.yml # Example: suppress specific findings
├── Dockerfile # Vulnerable base + EICAR malware
└── README.md # You are here
```
### 故意植入的漏洞依赖
| 生态系统 | 包名 | 版本 | 已知 CVE |
|----------|------|------|----------|
| npm | `lodash` | 4.17.20 | 原型污染 |
| npm | `axios` | 0.21.1 | 通过重定向的 SSRF |
| npm | `jsonwebtoken` | 8.5.1 | 算法混淆 |
| npm | `node-forge` | 0.10.0 | 签名验证绕过 |
| npm | `tar` | 4.4.13 | 任意文件覆盖 |
| pip | `cryptography` | 3.3.2 | 多个 OpenSSL CVE |
| pip | `urllib3` | 1.26.4 | CRLF 注入 |
| pip | `Pillow` | 8.2.0 | 缓冲区溢出 |
| pip | `PyYAML` | 5.4 | 任意代码执行 |
| Go | `golang.org/x/net` | 0.0.0-2022... | HTTP/2 快速重置 |
| Go | `golang.org/x/crypto` | 0.0.0-2022... | 多个 CVE |
### 植入的密钥
| 类型 | 匹配模式 | 文件 |
|------|----------|------|
| GitHub 个人访问令牌 | `ghp_...` | `app/server.js` |
| AWS 访问密钥 ID | `AKIA...` | `app/server.js` |
| AWS 秘密访问密钥 | `wJalrX...` | `app/server.js` |
| RSA 私钥 | `-----BEGIN RSA PRIVATE KEY-----` | `app/server.js` |
| Slack Webhook URL | `https://hooks.slack.com/...` | `app/server.js` |
| 数据库密码 | `SuperSecret123!` | `app/server.js` |
### 容器镜像
| 层 | 内容 | 发现类型 |
|----|------|----------|
| 基础镜像:`alpine:3.16` | 已停止维护的 Alpine,包含未修复的 OpenSSL、busybox、zlib | 漏洞 |
| `RUN echo ... > /tmp/.env` | Stripe 密钥、SendGrid 密钥、数据库 URL 硬编码在层中 | 密钥 |
| `RUN wget ... eicar.com` | EICAR 反恶意软件测试文件 | 恶意软件 |
## TMAS 能力参考
### 扫描类型
| 标志 | 扫描器 | 适用对象 |
|------|--------|----------|
| `-V` / `--vulnerabilities` | CVE / 开源漏洞检测 | 所有工件类型 |
| `-M` / `--malware` | 恶意软件检测(Trend Micro 引擎) | 仅容器镜像 |
| `-S` / `--secrets` | 凭证 / 密钥泄露检测 | 所有工件类型 |
### 支持的工件类型
| 前缀 | 描述 | `-V` | `-M` | `-S` |
|------|------|------|------|------|
| `dir:` | 磁盘上的目录 | ✓ | ✗ | ✓ |
| `file:` | 磁盘上的单个文件 | ✓ | ✗ | ✓ |
| `docker:` | 本地 Docker 守护进程中的镜像 | ✓ | ✓ | ✓ |
| `registry:` | 远程注册表中的镜像 | ✓ | ✓ | ✓ |
| `docker-archive:` | `docker save` 导出的 tar 包 | ✓ | ✓ | ✓ |
| `oci-archive:` | OCI 归档 tar 包 | ✓ | ✓ | ✓ |
| `oci-dir:` | OCI 布局目录 | ✓ | ✓ | ✓ |
| `podman:` | 本地 Podman 守护进程中的镜像 | ✓ | ✗ | ✓ |
| `singularity:` | Singularity `.sif` 容器 | ✓ | ✗ | ✓ |
### 退出代码
| 代码 | 含义 |
|------|------|
| `0` | 扫描完成 — 无策略违规 |
| `1` | 扫描错误 |
| `2` | 扫描完成 — **策略违规** |
### 关键标志
| 标志 | 功能 |
|------|------|
| `--evaluatePolicy` | 检查发现是否符合 Vision One 安全策略 |
| `--saveSBOM` | 保存软件物料清单(SBOM),格式为 CycloneDX |
| `--redacted` | 在 CLI 输出中屏蔽密钥值 |
| `--override ` | 忽略特定发现(参见 `overrides/tmas_overrides.yml`) |
| `--platform ` | 针对多架构镜像的目标平台 |
| `--region ` | Vision One 区域(默认:`us-east-1`) |
## 忽略发现结果
并非每个发现都需要处理。可使用覆盖文件记录可接受的风险:
```
# overrides/tmas_overrides.yml
vulnerabilities:
exceptions:
- id: CVE-2022-37434
reason: "Accepted risk — not exploitable in our context"
secrets:
exceptions:
- id: "generic-api-key"
path: "app/server.js"
reason: "Intentional demo credential"
```
将其传递给扫描命令:
```
tmas scan -V -S --override overrides/tmas_overrides.yml dir:.
```
## 通过策略评估阻止 PR 合并
结合 `--evaluatePolicy` 与 GitHub 分支保护规则,可创建阻止不安全代码合并的安全门禁:
1. 在 [Vision One 控制台](https://portal.xdr.trendmicro.com/) 的 **Code Security > Policies** 中配置策略
2. 为 TMAS 扫描添加 `--evaluatePolicy`(已在 Job 5 中完成)
3. 在 GitHub 中要求状态检查:**Settings > Branches > Branch protection > Require status checks** — 添加策略评估任务
当 TMAS 发现违规时,任务将以退出代码 `2` 结束状态检查变为红色,合并按钮将被禁用。
## 本地运行(CLI)
```
# 安装 TMAS
curl -sL "https://ast-cli.xdr.trendmicro.com/tmas-cli/latest/tmas-cli_$(uname -s)_$(uname -m | sed 's/x86_64/x86_64/;s/aarch64/arm64/').tar.gz" \
| tar xz -C /usr/local/bin tmas
# 设置您的 API 密钥
export TMAS_API_KEY="your-vision-one-api-key"
# 扫描源代码
tmas scan -V -S --region us-east-1 dir:.
# 构建并扫描容器镜像
docker build -t tmas-showcase:scan .
tmas scan -V -M -S --region us-east-1 docker:tmas-showcase:scan
# 生成 SBOM
tmas scan -V --saveSBOM --region us-east-1 dir:.
```
## 资源
- [TMAS 文档](https://docs.trendmicro.com/en-us/documentation/article/trend-vision-one-integrating-tmas-ci-cd-pipeline)
- [TMAS CLI 参考](https://docs.trendmicro.com/en-us/documentation/article/trend-vision-one-artifactscannerclire)
- [GitHub Action — `trendmicro/tmas-scan-action`](https://github.com/trendmicro/tmas-scan-action)
- [Trend Vision One — 免费试用](https://www.trendmicro.com/en_us/business/products/one-platform.html)
- [EICAR 测试文件](https://www.eicar.org/download-anti-malware-testfile/)
## 许可证
本仓库仅作为教育和演示用途提供。
故意包含的漏洞代码和容器镜像**绝不应**部署到生产环境。
标签:API密钥, Artifact Scanner, CI/CD安全, CVE, DevSecOps, EICAR, GitHub Actions, Llama, LLM防护, MITM代理, SBOM, TMAS, Trend Vision One, 上游代理, 代码安全, 安全展示, 安全演示, 安全门禁, 容器镜像扫描, 数字签名, 日志审计, 源码审计, 漏洞枚举, 硬件无关, 硬编码密钥, 策略评估, 自动笔记, 自定义DNS解析器, 请求拦截, 逆向工具