From ac47fa3475df8a575c967e3623a1d547d36c4e0c Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:05:39 +0900 Subject: [PATCH 1/2] ci: show workflow, job and artifact names as plain text in the CI report The report put these names into its comment as they were. A pull request that changes a workflow could then mention people, add table rows, links or sections to the comment. --- .github/scripts/ci_report.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/scripts/ci_report.py b/.github/scripts/ci_report.py index 2fbb31a..12b0acd 100644 --- a/.github/scripts/ci_report.py +++ b/.github/scripts/ci_report.py @@ -79,6 +79,16 @@ def defused(text): return re.sub(r"<(/?)(details|summary)", r"<\1\2", text, flags=re.IGNORECASE) +def plain(name): + """Returns an untrusted name, such as a workflow, job or artifact name, as text on one line that cannot mention + anyone, link anywhere or change the report's table and sections.""" + text = " ".join(str(name).split()) + text = text.replace("&", "&").replace("<", "<").replace(">", ">") + text = text.replace("[", "[").replace("]", "]").replace("|", "|") + text = re.sub(r"(?i):/(?=/)|\bwww(?=\.)", r"\g<0>​", text) + return re.sub(r"@(?=[A-Za-z0-9])", "@​", text) + + def fragments(repo, run): """Returns the report fragments the run uploaded, each as a dict with key, title, summary and details.""" found = [] @@ -92,7 +102,7 @@ def fragments(repo, run): key = artifact["name"][len(FRAGMENT_PREFIX):] data = archive.read(FRAGMENT_FILE)[:MAX_FRAGMENT_BYTES].decode("utf-8", "replace") lines = defused(data).replace("\r\n", "\n").split("\n") - title = lines[0].strip() or key + title = lines[0].strip() or plain(key) summary = (lines[1].strip() if len(lines) > 1 else "")[:MAX_SUMMARY_CHARS] details = "\n".join(lines[2:]).strip() if len(details) > MAX_DETAILS_CHARS: @@ -133,14 +143,14 @@ def body(repo, sha, runs): parts = parts[:MAX_CELL_SUMMARIES] + [f"{len(parts) - MAX_CELL_SUMMARIES} more below"] failed = failing_jobs(repo, run) if result in ("failure", "timed_out") else [] if failed: - parts.insert(0, "Failed: " + ", ".join(failed)) + parts.insert(0, "Failed: " + ", ".join(plain(name) for name in failed)) summary = "; ".join(parts) icon = "⏳ running" if result == "running" else ICONS.get(result, result) cell = summary.replace("|", "\\|") - rows.append(f"| [{run['name']}]({run['html_url']}) | {icon} | {cell} |") + rows.append(f"| [{plain(run['name'])}]({run['html_url']}) | {icon} | {cell} |") for fragment in found: opened = " open" if result in ("failure", "timed_out") and FAILING.search(fragment["summary"]) else "" - heading = joined(run["name"], label(run, fragment)) + heading = joined(plain(run["name"]), label(run, fragment)) if fragment["summary"]: heading += f", {fragment['summary']}" details = fragment["details"] or "No details." From 5f17f33f4af0a21a1ee6a92cf909ae0bec29cfc4 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:14:34 +0900 Subject: [PATCH 2/2] ci: keep the docstring of plain on one line --- .github/scripts/ci_report.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/ci_report.py b/.github/scripts/ci_report.py index 12b0acd..b59da83 100644 --- a/.github/scripts/ci_report.py +++ b/.github/scripts/ci_report.py @@ -80,8 +80,7 @@ def defused(text): def plain(name): - """Returns an untrusted name, such as a workflow, job or artifact name, as text on one line that cannot mention - anyone, link anywhere or change the report's table and sections.""" + """Returns an untrusted workflow, job or artifact name as one line of text without mentions, links or markup.""" text = " ".join(str(name).split()) text = text.replace("&", "&").replace("<", "<").replace(">", ">") text = text.replace("[", "[").replace("]", "]").replace("|", "|")