profiling.sampling heatmap reads non-regular and oversized files
未关闭
还没有人认领这个 Issue。
stdlib
topic-profiling
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug description
The heatmap exporter in profiling.sampling reads source files named in a profile unconditionally via Path(filename).read_text(). It does not check whether the path is a regular file or whether the file size is reasonable.
When replaying a binary profile, a filename pointing to a device file (e.g. /dev/zero) causes unbounded memory growth. An oversized file has the same effect.
The fix adds an is_file() guard and a 10 MB size cap before reading, consistent with the binary reader hardening in gh-152718.
CPython versions tested on
main
Operating systems tested on
macOS
Linked PRs
- gh-153839
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 profiling.sampling 热图导出器开始,该导出器使用 Path(filename).read_text() 读取源路径,并参考 gh-152718 中对二进制读取器的加固方式进行比较。完成的标准是:不读取非普通路径和超过 10 MB 的文件;gh-153839 已作为拟议工作链接。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- performance
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100