You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(comment): prevent markdown injection from IaC tag values (#22)
* fix(comment): prevent markdown injection from IaC tag values
escapeAndFormatCode wrapped values in backticks without escaping. Tag
keys/values and attribute names come from user-controlled IaC and are
rendered as Markdown in PR comments, so a crafted value (e.g. a backtick
followed by a [link](...)) could close the code span and inject live
Markdown. All 29 tag/governance render sites route through this helper
(directly or via joinEscapedCode), so make it emit an injection-safe
code span: fence longer than any backtick run, newlines stripped. Output
is unchanged for ordinary values.
* fix(comment): escape user-controlled template leaf values
text/template applies no escaping, so template interpolations of
user-controlled values bypassed escapeAndFormatCode entirely: project
name/module path/workspace (cost table), project error name/output, and
the fixed-issues tag label were emitted raw into the HTML-flavoured
Markdown comment.
Escape them at the template boundary: values inside raw-HTML blocks
(<td>, <b>, <pre>) use the built-in `html` function (Markdown is not
processed there, so HTML escaping is the correct and sufficient guard);
the fixed-issues label, shown as inline code in a Markdown context, uses
the new mdCode template function (escapeAndFormatCode). Error output
stays in its <pre> code block with escaped content.
0 commit comments