python / python/cpython

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

Aperta
#153,840 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib topic-profiling type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, python
Ambito
data-visualization, security
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.