Nexory commented on code in PR #1880:
URL: https://github.com/apache/wicket/pull/1880#discussion_r4546275443


##########
wicket-core/src/main/java/org/apache/wicket/csp/CSPHeaderConfiguration.java:
##########
@@ -169,6 +178,22 @@ public CSPHeaderConfiguration reportBackAt(String 
mountPath)
                return add(REPORT_URI, new RelativeURICSPValue(mountPath));
        }
 
+       /**
+        * Adds {@code require-trusted-types-for 'script'; trusted-types 
wicket} to the CSP, which makes
+        * the browser reject strings at script injection sinks such as {@code 
innerHTML}. Wicket's own
+        * JavaScript passes the markup and scripts of an Ajax response through 
the
+        * {@value #TRUSTED_TYPES_POLICY} policy unchanged, so the response of 
the server stays
+        * trusted as before. Other scripts on the page have to use a policy of 
their own, to be allowed
+        * with {@link #add(CSPDirective, String...)}. No preset includes these 
directives.
+        *
+        * @return {@code this} for chaining
+        * @since 12.0.0
+        */
+       public CSPHeaderConfiguration requireTrustedTypes()
+       {
+               return add(REQUIRE_TRUSTED_TYPES_FOR, 
"'script'").add(TRUSTED_TYPES, TRUSTED_TYPES_POLICY);

Review Comment:
   Fixed in afcb17a: `requireTrustedTypes()` skips values that are already 
present, covered by `requireTrustedTypesIsIdempotent` and 
`requireTrustedTypesTwice`.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to