diff --git a/internal/config/allowlist/allowed_ext_test.go b/internal/config/allowlist/allowed_ext_test.go index 79b9891a..0d128468 100644 --- a/internal/config/allowlist/allowed_ext_test.go +++ b/internal/config/allowlist/allowed_ext_test.go @@ -22,6 +22,12 @@ func TestIsAllowedExt(t *testing.T) { {".ETS", true}, {".json5", true}, {".JSON5", true}, + {".ftl", true}, + {".FTL", true}, + {".ftlh", true}, + {".FTLH", true}, + {".ftlx", true}, + {".FTLX", true}, {".txt", false}, {".md", false}, {".png", false}, diff --git a/internal/config/allowlist/supported_file_types.json b/internal/config/allowlist/supported_file_types.json index 2c75bded..69b9b416 100644 --- a/internal/config/allowlist/supported_file_types.json +++ b/internal/config/allowlist/supported_file_types.json @@ -43,6 +43,9 @@ ".less", ".html", ".htm", + ".ftl", + ".ftlh", + ".ftlx", ".astro", ".vue", ".svelte", diff --git a/internal/config/rules/rule_docs/freemarker.md b/internal/config/rules/rule_docs/freemarker.md new file mode 100644 index 00000000..07e1d040 --- /dev/null +++ b/internal/config/rules/rule_docs/freemarker.md @@ -0,0 +1,36 @@ +#### Obvious Typos or Spelling Errors +- Spelling errors in macro names, assigned variable names, or user-facing text at their declaration sites; do not report at reference sites +- Typos in `<#assign>`/`<#macro>`/`<#function>` names that surface only at render time (`InvalidReferenceException` / macro not found), or that are silently masked by `!` defaults and `??` guards + +#### Output Escaping and XSS +- Interpolations (`${...}`) that reach HTML without escaping: flag only when auto-escaping is not already active — i.e. the template lacks `<#ftl output_format="HTML">` (FreeMarker 2.3.24+) AND does not use the `.ftlh`/`.ftlx` extension (which auto-activate HTML/XML escaping via `recognize_standard_file_extensions`, on by default since 2.3.24) — and the value is not passed through `?html`/`?url`/`?js_string` appropriate to its sink (HTML body, attribute, URL, JS, CSS) +- Explicit `?no_esc` or `<#noautoesc>` on values that carry user-controlled data — treat as a high-risk escape hatch; flag unless the source is clearly trusted or already sanitized +- Escaping with the wrong context builtin (e.g. `?html` for a value placed inside a URL or inline `