theluckystrike/crx-permission-analyzer
GitHub: theluckystrike/crx-permission-analyzer
一个用于分析Chrome扩展权限并计算隐私风险评分的命令行工具与TypeScript库。
Stars: 0 | Forks: 0
# @zovo/crx-permission-analyzer
[](https://npmjs.com/package/@zovo/crx-permission-analyzer)
[](https://github.com/theluckystrike/crx-permission-analyzer/actions)
[](https://opensource.org/licenses/MIT)
[](https://www.typescriptlang.org/)
[](https://discord.gg/zovo)
[](https://zovo.one)
隶属于隐私优先的 Chrome 扩展开发者工具 [Zovo](https://zovo.one) 系列。
## 安装
```
npm install @zovo/crx-permission-analyzer
```
## 快速开始
### CLI
```
npx @zovo/crx-permission-analyzer manifest.json
# JSON 输出
npx @zovo/crx-permission-analyzer manifest.json --json
# Exclude optional permissions
npx @zovo/crx-permission-analyzer manifest.json --no-optional
```
当风险等级为 `high` 或 `critical` 时,CLI 将以退出码 1 退出,这使其适用于 CI 流水线。
### 库
```
import { analyze, analyzePermissions, formatHuman, formatJson } from '@zovo/crx-permission-analyzer';
// Analyze from a manifest file
const result = await analyze('./manifest.json');
console.log(`Risk: ${result.riskLevel} (score: ${result.riskScore})`);
console.log(formatHuman(result));
// Analyze raw permission arrays
const result2 = analyzePermissions(
['tabs', 'cookies'],
['bookmarks'],
['https://*/*']
);
console.log(formatJson(result2));
```
## API
### `analyze(manifestPath, options?)`
读取 `manifest.json` 文件并返回完整的权限分析。
| 参数 | 类型 | 描述 |
|-----------|------|-------------|
| `manifestPath` | `string` | manifest.json 的路径 |
| `options.outputFormat` | `'json' \| 'human'` | 输出格式 (默认: `'human'`) |
| `options.includeOptional` | `boolean` | 是否包含可选权限 (默认: `true`) |
返回 `Promise`。
### `analyzePermissions(permissions, optionalPermissions?, hostPermissions?)`
分析原始权限数组,无需读取文件。返回 `PermissionAnalysis`。
### `parseManifest(manifestPath)`
从 manifest 文件中提取 `permissions`、`optionalPermissions` 和 `hostPermissions` 数组。
### `formatHuman(analysis)` / `formatJson(analysis)`
将 `PermissionAnalysis` 结果格式化为人类可读文本或 JSON 字符串。
## 风险等级
| 等级 | 分值 | 示例 |
|-------|-------|---------|
| LOW | 1 | `storage`, `alarms`, `activeTab`, `notifications` |
| MEDIUM | 2 | `bookmarks`, `downloads`, `webNavigation`, `identity` |
| HIGH | 5 | `cookies`, `tabs`, `scripting`, `history`, `geolocation` |
| CRITICAL | 10 | ``, `debugger`, `proxy`, `nativeMessaging` |
危险组合(例如 `` + `cookies`)会给分数增加额外的点数。
## 相关资源
### 相关 Zovo 仓库
- [crx-manifest-validator](https://github.com/theluckystrike/crx-manifest-validator) - 验证 manifest.json 文件
- [crx-extension-size-analyzer](https://github.com/theluckystrike/crx-extension-size-analyzer) - 分析扩展包体积
- [chrome-extension-starter-mv3](https://github.com/theluckystrike/chrome-extension-starter-mv3) - 生产级 MV3 起始模板
- [chrome-storage-plus](https://github.com/theluckystrike/chrome-storage-plus) - 类型安全的存储封装
### Zovo Chrome 扩展
- [Zovo Tab Manager](https://chrome.google.com/webstore/detail/zovo-tab-manager) - 高效管理标签页
- [Zovo Focus](https://chrome.google.com/webstore/detail/zovo-focus) - 屏蔽干扰内容
- [Zovo Permissions Scanner](https://chrome.google.com/webstore/detail/zovo-permissions-scanner) - 检查扩展隐私等级
访问 [zovo.one](https://zovo.one) 了解更多信息。
## 许可证
MIT — [Zovo](https://zovo.one)
*由开发者构建,为开发者服务。在隐私问题上绝不妥协。*
标签:Chrome 扩展, CI/CD 集成, DevSecOps, Java RMI, manifest.json, MITM代理, npm 包, TypeScript 库, Zovo, 上游代理, 云安全监控, 权限分析, 网络安全, 自动化攻击, 自动化攻击, 隐私保护, 静态分析