Yashesh10/CWE-Threat-Intelligence-Dashboard
GitHub: Yashesh10/CWE-Threat-Intelligence-Dashboard
基于 Python/Flask 的 Web 应用,加载并可视化分析 MITRE CWE 数据集,提供弱点分布、后果影响与缓解策略的交互式仪表板。
Stars: 0 | Forks: 0
# Cw-2_CWE pro
# CWE 威胁情报仪表板
一个使用 Python/Flask 构建的 Web 应用程序,能够加载 MITRE CWE 数据集,并通过交互式仪表板提供聚合的安全分析。
## 环境要求
- Python 3.10 或更高版本
- pip (Python 包管理器)
## 设置说明
### 步骤 1 — 下载 CWE 数据文件
前往:**https://cwe.mitre.org/data/downloads.html**
下载标记为 **CWE List (XML)** 的文件。它将是一个类似于 `cwec_latest.xml.zip` 的 ZIP 文件。
将其放置在项目目录下名为 `data/` 的文件夹中:
```
cwe-analyser/
├── app.py
├── cwe_parser.py
├── analysis.py
├── requirements.txt
├── data/
│ └── cwec_latest.xml.zip ← place the file here
├── static/
│ ├── main.js
│ └── style.css
├── templates/
│ ├── index.html
│ └── detail.html
└── tests/
└── test_app.py
```
如果 `data/` 文件夹不存在,请在添加文件之前手动创建它。
### 步骤 2 — 安装依赖项
打开终端,导航到项目文件夹,然后运行:
```
pip install -r requirements.txt
```
这将安装 Flask 和 defusedxml —— 这是该项目仅需要的两个库。
如果遇到权限错误,请尝试:
```
pip install --user -r requirements.txt
```
### 步骤 3 — 运行应用程序
```
python app.py
```
您应该会看到类似于以下内容的输出:
```
INFO:cwe_parser:Extracting CWE XML from zip...
INFO:cwe_parser:Loaded 933 CWE entries.
INFO:app:CWE dataset loaded successfully.
* Running on http://127.0.0.1:5000
```
### 步骤 4 — 打开仪表板
打开浏览器并访问:
```
http://127.0.0.1:5000
```
仪表板将会加载所有的图表和搜索面板。
## 功能
| 功能 | 描述 |
|---|---|
| 抽象级别分布 | 整个目录中 Pillar / Class / Base / Variant 条目的详细分类 |
| CIA 后果频率 | 在所有 CWE 中,机密性、完整性和可用性受到威胁的频率 |
| 可能性分布 | 每个利用可能性级别(高 / 中 / 低 / 未知)的 CWE 数量统计 |
| 缓解阶段分析 | 大多数 CWE 建议在哪些 SDLC 阶段解决弱点 |
| 按 CVE 示例排名前 15 | 根据真实世界 CVE 示例数量排名的 CWE |
| 高风险综合视图 | 既具有高可能性又在真实世界 CVE 中得到广泛证明的 CWE |
| 搜索 | 按 CWE ID(例如 `79` 或 `CWE-79`)、名称或关键字进行搜索 —— 结果按 CVE 数量排序 |
| 详情页面 | 点击任意 CWE 以查看其描述、后果、缓解措施、CVE 示例和相关弱点 |
## 运行测试
首先安装测试依赖项:
```
pip install pytest pytest-flask
```
然后运行:
```
pytest tests/ -v
```
## 运行安全检查(可选)
要在本地运行与 CI/CD pipeline 中相同的安全扫描:
```
pip install bandit pip-audit
```
**静态安全扫描 (Bandit):**
```
bandit -r . -x ./tests -ll
```
**依赖项漏洞扫描 (pip-audit):**
```
pip-audit --requirement requirements.txt
```
## 故障排除
**应用程序启动,但仪表板未显示数据**
确保 `cwec_latest.xml.zip` 位于 `data/` 文件夹内。应用程序在启动时会查找此文件 —— 如果缺少该文件,将无法加载任何数据。
**`ModuleNotFoundError: No module named 'flask'`**
再次运行 `pip install -r requirements.txt`,并确保您使用的是与启动应用程序时相同的 Python 环境。
**安装包时出现 `Permission denied`**
在安装命令中添加 `--user`:`pip install --user -r requirements.txt`
**端口 5000 已被占用**
另一个应用程序正在使用端口 5000。请停止该应用程序,或者更改 `app.py` 最后一行中的端口:
```
app.run(debug=False, host="127.0.0.1", port=5001)
```
然后在浏览器中打开 `http://127.0.0.1:5001`。
## 项目结构
```
cwe-analyser/
├── app.py # Flask application — routes, validation, security headers
├── cwe_parser.py # Loads and parses the CWE XML file securely
├── analysis.py # Produces the six analytical views from the loaded data
├── requirements.txt # Project dependencies (flask, defusedxml)
├── .gitlab-ci.yml # CI/CD pipeline definition (lint, SAST, dependency scan, test, build)
├── data/ # Place cwec_latest.xml.zip here (not included in repository)
├── static/
│ ├── main.js # Chart.js charts and search interaction
│ └── style.css # Dashboard styling
├── templates/
│ ├── index.html # Main dashboard page
│ └── detail.html # Individual CWE detail page
└── tests/
└── test_app.py # Unit tests covering security headers, input validation, and API responses
```
=======
# CWE-Threat-Intelligence-Dashboard
标签:CWE分析, Flask, Python, XSS, 仪表盘, 安全规则引擎, 无后门, 漏洞情报, 逆向工具