public final class ContentSecurityPolicyNonceInjectionPass extends CompilerFilePass
<script> and <style> tags.
This makes it easy for applications using soy to set unsafe-inline Content security policy setting.
For example, given this soy template.
<script>var x = 'foo'</script>
We 'know' that this script is safe because it was written by the author (rather than an attacker), so Soy will rewrite it to look like:
<script{if $ij.csp_nonce} nonce="{$ij.csp_nonce}{/if}>var x = 'foo'</script>
Then if the user configures a csp_nonce in their CSP settings and as an input to
rendering, all author controlled scripts and styles will be authorized.
This pass should:
| Modifier and Type | Field and Description |
|---|---|
static String |
CSP_NONCE_VARIABLE_NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
run(SoyFileNode file,
IdGenerator nodeIdGen) |
name, toStringpublic static final String CSP_NONCE_VARIABLE_NAME
public void run(SoyFileNode file, IdGenerator nodeIdGen)
run in class CompilerFilePass