widhiputri/har-security-scan

GitHub: widhiputri/har-security-scan

一个纯 Node.js 的轻量级 HAR 文件安全扫描工具,自动检测常见安全问题并生成含修复指南的 HTML 报告。

Stars: 0 | Forks: 0

# har-security-scan [![npm version](https://img.shields.io/npm/v/har-security-scan)](https://www.npmjs.com/package/har-security-scan) [![node](https://img.shields.io/badge/node-%3E%3D16-brightgreen)](https://nodejs.org) [![license](https://img.shields.io/npm/l/har-security-scan)](LICENSE) 扫描 HAR 文件以查找常见安全问题,并生成一个干净、独立的 HTML 报告。 无外部依赖。纯 Node.js。 ## 安装 ``` npm install -g har-security-scan ``` 或者无需安装直接运行: ``` npx har-security-scan capture.har ``` ## 用法 ``` har-security-scan [options] Options: --output, -o Output file path (default: auto-generated) --fail-on Exit code 1 if findings exist at this severity or above (high|medium|low) --help, -h Show this help ``` ### 基础扫描 ``` har-security-scan capture.har ``` 在当前目录下生成一个名为 `--har-security-scan.html` 的报告。 ### 自定义输出路径 ``` har-security-scan capture.har --output report.html ``` ### CI 拦截 ``` har-security-scan capture.har --fail-on high ``` 如果存在任何 High 级别的发现,将以代码 `1` 退出,使其非常适合 CI 流水线。 ## 检查内容 | 检查项 | 严重级别 | |---|---| | URL 中包含敏感参数(API key、token、password) | High | | 纯 HTTP 请求(非 HTTPS) | High | | 详细的错误响应(stack trace、SQL error) | High | | 响应体中包含 JWT token | High | | URL 中包含个人数据(email、NRIC、phone) | High | | 混合内容(HTTPS 页面上加载 HTTP 资源) | Medium | | Cookie 缺少 Secure 标志 | Medium | | Cookie 缺少 HttpOnly 标志 | Medium | | 缺少 Content-Security-Policy header | Medium | | 缺少 Strict-Transport-Security header | Medium | | 缺少 X-Content-Type-Options header | Medium | | 缺少 X-Frame-Options header | Medium | | Cookie 缺少 SameSite 属性 | Low | 每项发现都包含描述、证据(确切的 URL 和值),以及内联的修复指南(附带 Express.js、Nginx、Django 和 Spring Boot 的代码示例)。 ## 如何导出 HAR 文件 **Chrome / Edge:** DevTools (F12) > Network 标签页 > 右键点击任意请求 > Save all as HAR **Firefox:** DevTools > Network 标签页 > 设置图标 > Save all as HAR **Burp Suite:** Proxy > HTTP history > 选择请求 > 右键点击 > Save as HAR ## 报告 该报告是一个独立的 HTML 文件,没有外部依赖。它包含: - 按严重级别统计发现数量的摘要 - 每项发现的描述、证据列表和修复指南 - 可折叠的“More detail”,包含针对特定框架的代码示例 - 适配 CI 的 `--fail-on` 退出代码 请参阅 [`examples/sample-report.html`](examples/sample-report.html) 查看示例。 ## 示例 `examples/` 目录包含: - `sample.har` - 一个会触发所有检查的真实 HAR 文件 - `sample-report.html` - 由 `sample.har` 生成的报告 自己运行试试: ``` har-security-scan examples/sample.har --output my-report.html ``` ## 许可证 MIT。详情请参阅 [LICENSE](LICENSE)
标签:GNU通用公共许可证, HAR分析, MITM代理, Node.js, Web安全, 云安全监控, 文档结构分析, 暗色界面, 自定义脚本, 蓝队分析, 静态分析