从PostgreSQL数据库读取CVE信息,使用GitHub API提取CVE披露时间前后半年内的所有commits。
注意:本工具只提取commits,不进行匹配和评分。
pip install -r requirements.txt- 数据库密码: 已配置
- GitHub API Token: 已配置
bash run.shpython main.py{
"metadata": {
"timestamp": "2025-11-12T18:00:00",
"total_cves": 100,
"processed_cves": 100,
"total_commits": 5000,
"repo_not_found": 5,
"api_errors": 2
},
"results": [
{
"cve_id": "CVE-2020-7221",
"published_date": "2020-02-04T17:15Z",
"repo_url": "https://github.com/MariaDB/server",
"status": "success",
"message": "成功提取 50 个commits",
"time_range": {
"since": "2019-08-04T17:15:00Z",
"until": "2020-08-04T17:15:00Z"
},
"commits": [
{
"sha": "9d18b6246755472c8324bf3e20e234e08ac45618",
"message": "Fix privilege escalation in mysql_install_db",
"author": "Developer Name",
"author_email": "dev@example.com",
"date": "2020-02-05T10:30:00Z",
"committer": "Committer Name",
"committer_date": "2020-02-05T10:30:00Z",
"html_url": "https://github.com/MariaDB/server/commit/9d18b624..."
}
]
}
]
}- 默认: CVE披露前6个月 ~ CVE披露后6个月
- 可配置: 编辑
config.py中的TIME_RANGE_CONFIG
- 处理速度: 2-5秒/CVE
- API限制: 5000次/小时(已认证)
- 100个CVE: 约5-10分钟
database.py- 数据库操作(只读)github_api.py- GitHub API交互time_utils.py- 时间处理main.py- 主程序
- 文件:
cve_commit_matching.log - 级别: INFO
编辑 main.py 最后一行:
# 处理5个CVE
extractor.process_cves(limit=5)
# 处理100个CVE
extractor.process_cves(limit=100)
# 处理所有CVE
extractor.process_cves()
# 从第100个开始处理50个
extractor.process_cves(limit=50, offset=100)- 检查config.py中的数据库配置
- 检查API Token是否有效
- 查看速率限制状态
- 检查CVE披露时间是否正确
- 尝试扩大时间范围(修改config.py)
- 只读操作: 不会修改数据库中的任何表
- API限制: 程序会自动处理速率限制
- 仓库状态: 某些仓库可能已删除或设为私有(正常现象)
- 结果保存: 每处理10个CVE自动保存一次中间结果