The vulnerability described is a classic stored Cross-Site Scripting (XSS) issue within the HTML report generation feature of PySpector. The core of the problem lies in the failure to sanitize data that is extracted from a scanned Python file before embedding it into the final HTML report. An attacker could craft a Python file with malicious JavaScript payloads in strings, which, when scanned, would be included raw in the report. When a user opens this report, the browser executes the malicious script.
To pinpoint the exact vulnerable function, I first identified the repository and the patched version from the advisory. By comparing the git tags for the last vulnerable version (v0.1.6-beta) and the first patched version (v0.1.7-beta), I located the specific commit that addressed the vulnerability. The commit 6b4979fb6383193f5f3d3e30bab4ef62a3375981 with the message "Fix: Added HTML module escaping" clearly indicates the nature of the fix.
Analyzing the diff of this commit reveals that the file src/pyspector/reporting.py was modified. Inside this file, the to_html method of the Report class was changed to wrap several variables (issue.file_path, issue.severity, issue.description, and issue.code) with html_module.escape(). This is the standard Python defense against XSS, confirming that this function was the source of the vulnerability. Therefore, pyspector.reporting.Report.to_html is the vulnerable function that would appear in a runtime profile during the generation of a malicious report.