bb1nfosec/bheeshma
GitHub: bb1nfosec/bheeshma
一个 Node.js 运行时依赖行为监控器,用于捕获静态分析遗漏的供应链攻击。
Stars: 1 | Forks: 2
# BHEESHMA
**Node.js 运行时依赖行为监控器**
*npm 软件包的 strace。*
[](https://www.npmjs.com/package/bheeshma)
[](https://opensource.org/licenses/Apache-2.0)
[](https://nodejs.org/)
[](https://github.com/bb1nfosec/bheeshma/actions/workflows/ci.yml)
[]()
[](https://bb1nfosec.github.io/bheeshma/)
[]()
[](CONTRIBUTING.md)
*捕捉静态分析错过的供应链攻击。*
[快速开始](#-30-second-quick-start) | [GitHub Actions](#-github-actions-integration) | [npm install 监视器](#-npm-install-monitor) | [耻辱墙](#-wall-of-shame-dashboard) | [CLI](#cli-usage) | [配置](#configuration)
## 为什么选择 BHEESHMA?
在 2025-2026 年,npm 生态系统遭受了一波供应链攻击:
| 攻击 | 时间 | 影响 |
|--------|------|--------|
| **Shai-Hulud 蠕虫** | 2025年9月 | 200+ 个软件包,自动化 CI/CD 劫持 |
| **axios 妥协事件** | 2026年初 | 窃取 npm 凭据,影响 10K+ 系统,传播 RAT 恶意软件 |
| **Mini Shai-Hulud** | 2026年5月 | 84 个 TanStack 软件包被攻陷 |
| **CanisterWorm** | 2026年 | 自我传播,数据窃取 + 持久化 |
**每一个主要工具 — Socket.dev, Snyk, Dependabot, npm audit — 都是安装前的静态分析。** 它们在代码*运行前*扫描。它们无法看到软件包在*运行时*实际做了什么。
BHEESHMA 不同。它**监控运行时行为** — 你的依赖项在执行时实际做了什么。它能捕捉:
- 恶意的 `postinstall` 脚本窃取 CI 密钥
- 软件包向数据窃取端点建立出站连接
- 在运行时执行的混淆代码
- 凭据窃取、加密货币挖矿程序、数据窃取
- 假冒流行库的 typosquat 软件包
- 绕过 HTTP 级别监控的 DNS 隧道
**零依赖。零配置。零遥测。**
## 30 秒快速开始
### GitHub Actions(推荐)
添加到你的 CI 管道 — 一行 YAML:
```
# .github/workflows/ci.yml
- uses: bb1nfosec/bheeshma/.github/actions/bheeshma@main
with:
command: 'npm test'
fail-level: 'critical'
```
现在每个 PR 都会在 GitHub 差异视图中直接显示来自 bheeshma 的**运行时行为注释**。
### npm install 监视器
观察软件包在安装期间做了什么:
```
npx bheeshma install
```
### 基础监控
```
npx bheeshma -- node app.js
```
## GitHub Actions 集成
BHEESHMA 输出 **SARIF v2.1.0** — GitHub 代码扫描的标准格式。结果作为内联注释出现在每个 PR 上。
### 基础设置
```
name: CI
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- uses: bb1nfosec/bheeshma/.github/actions/bheeshma@main
with:
command: 'npm test'
fail-level: 'critical' # fail on CRITICAL (default)
upload-sarif: 'true' # upload to Code Scanning
```
### 所有选项
| 输入 | 默认值 | 描述 |
|-------|---------|-------------|
| `command` | _(必需)_ | 要在监控下运行的命令 |
| `fail-level` | `critical` | 构建失败的最低风险等级 (`critical`, `high`, `medium`, `low`) |
| `config` | `''` | `.bheeshmarc.json` 文件路径 |
| `sarif-output` | `bheeshma-results.sarif` | SARIF 输出文件路径 |
| `skip-low` | `true` | 在 SARIF 中跳过 LOW 风险信号(减少噪音) |
| `upload-sarif` | `true` | 将 SARIF 上传到 GitHub 代码扫描 |
### 高级:多个命令
```
- name: Monitor npm install
uses: bb1nfosec/bheeshma/.github/actions/bheeshma@main
with:
command: 'npm ci'
fail-level: 'high'
- name: Monitor tests
uses: bb1nfosec/bheeshma/.github/actions/bheeshma@main
with:
command: 'npm test'
fail-level: 'critical'
sarif-output: 'bheeshma-test-results.sarif'
```
## npm install 监视器
2025-2026 年**首要攻击向量**是恶意软件包在 `npm install` 期间窃取 CI 密钥。BHEESHMA 监视每个软件包在安装时的行为:
```
# 监控 npm install
npx bheeshma install
# 监控 npm ci (lockfile-strict)
npx bheeshma install ci
# 监控安装特定包
npx bheeshma install -- --save-dev some-package
# 为 CI 输出 SARIF
npx bheeshma install -- --sarif --output install-results.sarif
```
它能捕捉:
- 运行 shell 命令的 `postinstall` 脚本
- 读取 `.npmrc`, `.env` 或凭据文件的软件包
- 安装期间的出站网络连接
- 在 `node_modules/` 之外的文件写入
## CLI 用法
### 监控任何命令
```
# 监控 Node.js 应用
bheeshma -- node app.js
# 监控测试套件
bheeshma -- npm test
# 监控特定脚本
bheeshma -- node scripts/build.js
```
### 输出格式
```
# CLI (默认, 色彩编码终端输出)
bheeshma -- node app.js
# JSON (机器可读, 适用于流水线)
bheeshma --format json --output report.json -- npm test
# HTML (自包含深色主题报告)
bheeshma --format html --output report.html -- node app.js
# SARIF (GitHub Code Scanning 集成)
bheeshma --format sarif --output results.sarif -- npm test
```
### 强制模式
```
# 若任何包为 CRITICAL 则退出码为 1
bheeshma --enforce -- npm test
# 遇到 HIGH 或更高级别时失败
bheeshma-ci --fail-level high -- npm test
# JSON 输出 + 策略强制执行
bheeshma --enforce --format json --output report.json -- npm test
```
### CI 优化模式
```
# bheeshma-ci 是针对 CI 流水线优化的轻量封装
# - 无 ANSI 颜色,无 HTML
# - 默认输出 SARIF
# - 支持策略执行的退出码
# - GitHub Actions ::error 标注
bheeshma-ci -- npm test
bheeshma-ci --fail-level high --output results.sarif -- npm test
```
### 子命令
```
bheeshma install # Monitor npm install
bheeshma ci --
[](https://www.npmjs.com/package/bheeshma)
[](https://opensource.org/licenses/Apache-2.0)
[](https://nodejs.org/)
[](https://github.com/bb1nfosec/bheeshma/actions/workflows/ci.yml)
[]()
[](https://bb1nfosec.github.io/bheeshma/)
[]()
[](CONTRIBUTING.md)
*捕捉静态分析错过的供应链攻击。*
[快速开始](#-30-second-quick-start) | [GitHub Actions](#-github-actions-integration) | [npm install 监视器](#-npm-install-monitor) | [耻辱墙](#-wall-of-shame-dashboard) | [CLI](#cli-usage) | [配置](#configuration)
标签:CI/CD管道保护, GitHub Action, JavaScript安全, LNA, MITM代理, Node.js安全, npm安全, SARIF输出, 供应链攻击防护, 依赖管理, 开源安全项目, 恶意包检测, 漏洞扫描工具, 自定义脚本, 运行时监控, 运行时行为分析, 零依赖工具, 静态分析对比