profiling.sampling flamegraph does not escape function names in HTML output
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug description
The flamegraph exporter in profiling.sampling embeds profile strings into the generated HTML without escaping:
-
_create_flamegraph_htmlwritesjson.dumps(data)into an inline<script>block. A function name containing</script>breaks out of the script element. -
flamegraph.jsinterpolates the raw function name into a tooltip via.html()(innerHTML).
The sibling heatmap exporter already escapes its embedded data (html.escape(json.dumps(...))), and flamegraph.js already defines and uses escapeHtml() for displayName and source lines -- the function name was missed.
As a bonus, <lambda>, <module>, <genexpr> currently render as empty tooltip titles because the browser drops them as unknown tags. Escaping fixes this.
CPython versions tested on
main
Operating systems tested on
macOS
Linked PRs
- gh-153841
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
Start at _create_flamegraph_html in profiling.sampling and inspect how json.dumps(data) is embedded in the inline script, then review the function-name tooltip path in flamegraph.js. Compare the existing heatmap escaping and escapeHtml() uses. Done means function names cannot break the script or be interpreted as HTML, and names such as render correctly.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, python
- 领域
- data-visualization, security
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100