From 71f771df51e0ceaf6f0f6dee88bf1a1931727a09 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 12 Jun 2026 12:20:13 +1000 Subject: [PATCH] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- eng/pr-risk-scan.mjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eng/pr-risk-scan.mjs b/eng/pr-risk-scan.mjs index a1fc4ee0..04464472 100644 --- a/eng/pr-risk-scan.mjs +++ b/eng/pr-risk-scan.mjs @@ -270,15 +270,20 @@ function toMarkdownReport(findings, scannedFiles, skippedFiles) { : finding.severity === severityLevels.medium ? "🟠" : "ℹ️"; - const match = finding.match + const matchText = finding.match .replace(/\\/g, "\\\\") - .replace(/`/g, "\\`") .replace(//g, ">") .replace(/\|/g, "\\|") .replace(/@/g, "@\u200b"); + const backtickRuns = matchText.match(/`+/g); + const fenceLength = backtickRuns + ? Math.max(...backtickRuns.map((run) => run.length)) + 1 + : 1; + const fence = "`".repeat(fenceLength); + const match = `${fence}${matchText}${fence}`; summary.push( - `| ${severity} | \`${finding.rule_id}\` | \`${finding.file}\` | ${finding.line} | \`${match}\` |` + `| ${severity} | \`${finding.rule_id}\` | \`${finding.file}\` | ${finding.line} | ${match} |` ); }