Skip to content

fix: 修复 VulnGym 数据中的代码片段定位偏差#64

Open
ii76 wants to merge 1 commit into
Tencent:mainfrom
ii76:main
Open

fix: 修复 VulnGym 数据中的代码片段定位偏差#64
ii76 wants to merge 1 commit into
Tencent:mainfrom
ii76:main

Conversation

@ii76

@ii76 ii76 commented Jul 22, 2026

Copy link
Copy Markdown

任务说明

完成 #4 要求的 VulnGym 代码片段定位偏差自动修复脚本。

实现内容

  • 检查 entry_pointcritical_operationtrace[*] 节点
  • 在原始行号上下 5 行搜索代码片段
  • 在原文件全文搜索代码片段
  • 在整个仓库搜索代码片段
  • 支持多行代码以及 tab/空格差异
  • 仅在唯一命中时自动修复
  • 无法确定的节点写入 needs_human.csv
  • 使用本地缓存,避免重复下载仓库和 commit
  • 输出前检查 SCHEMA.md 基础约束
  • 文件位置变化时同步检查 desc 中的文件路径

运行方式

python3 scripts/fix_code_locations.py --verbose

全量运行结果

processed_entries=408
automatic_fixes=109
needs_human=56

自动修复策略统计:

修复策略 数量
原行号上下 5 行唯一命中(nearby_line 107
原文件全文唯一命中(same_file 2
合计 109

人工复核原因统计:

原因 数量
代码片段未找到(code_not_found 55
缺少代码字段(missing_code 1
仓库或 commit 下载失败(repo_unavailable 0
合计 56

人工复核项涉及 15 个 entry。所有无法唯一确定的节点均保持原值,并记录在 needs_human.csv,未进行强制修复。

输出文件

  • entries.fixed.jsonl:修复后的完整数据集
  • fix_diff.csv:109 处自动修复的修改记录
  • needs_human.csv:56 个需要人工复核的节点
  • scripts/fix_code_locations.py:自动修复脚本
  • scripts/README.md:依赖、运行方式、修复策略及限制说明

检查结果

使用官方数据加载脚本检查修复后的结果:

python3 examples/load_dataset.py

检查输出:

[stdlib] 184 reports / 408 entries
[stdlib] human-audited: 393 entries / 178 advisories (verify == 1)
[stdlib] biggest report: GHSA-2X8M-83VC-6WV4

官方脚本正常退出,修复后的 408 条 JSONL 数据均可正常解析和加载。

pandas 和 HuggingFace datasets 属于可选依赖,未安装时会跳过,不影响标准库加载检查。

Closes #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【2026犀牛鸟】修复 VulnGym 数据中的代码片段定位偏差

1 participant