python / python/cpython

profiling.sampling flamegraph does not escape function names in HTML output

未关闭
#153,840 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib topic-profiling type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug description

The flamegraph exporter in profiling.sampling embeds profile strings into the generated HTML without escaping:

  1. _create_flamegraph_html writes json.dumps(data) into an inline <script> block. A function name containing </script> breaks out of the script element.

  2. flamegraph.js interpolates 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 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

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。