A template is compiled from a string built with values, so those values can inject template code

tx0/ts:template-compiled-from-variablerecommendedwarningsecurity/injectiondepth fastsecurity

What it finds

Template engines run the expressions in a template's text. A template string built by concatenation or substitution makes the inserted values part of that code, so a value from a user can read data or run code on the server. Values belong in the data passed when the template is rendered.

Reported are compile, template, render and renderString calls of Handlebars, Lodash, EJS, Pug, Nunjucks and Mustache whose template argument is a template literal with substitutions or a concatenation with values.

From the rule's source, template_compiled_from_variable.rs.

Example from the rule's tests
declare const Handlebars: any;export function greet(name: string) {  return Handlebars.compile(`<p>Hello ${name}</p>`)({});tx0 reports: this template is built from values}export const page = Handlebars.compile("<p>Hello {{name}}</p>");
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:template-compiled-from-variable" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:template-compiled-from-variable] reason="..."

tx0 explain tx0/ts:template-compiled-from-variable shows the same in the terminal. Found a false positive? Report it.