ChristopherSchultz commented on code in PR #681:
URL: https://github.com/apache/tomcat/pull/681#discussion_r1432856054


##########
java/org/apache/catalina/filters/CsrfPreventionFilter.java:
##########
@@ -53,6 +58,25 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
 
     private String nonceRequestParameterName = 
Constants.CSRF_NONCE_REQUEST_PARAM;
 
+    private boolean enforce = true;
+
+    private Collection<Predicate<String>> noNoncePatterns = 
DEFAULT_NO_NONCE_URL_PATTERNS;
+
+    private static final Collection<Predicate<String>> 
DEFAULT_NO_NONCE_URL_PATTERNS;
+
+    static {
+        ArrayList<Predicate<String>> defaultNoNonceURLPatterns = new 
ArrayList<>();
+
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".css"));
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".js"));
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".gif"));
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".png"));
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".jpg"));
+        defaultNoNonceURLPatterns.add(new SuffixPredicate(".svg"));
+
+        DEFAULT_NO_NONCE_URL_PATTERNS = 
Collections.unmodifiableList(defaultNoNonceURLPatterns);

Review Comment:
   @michael-o All of this stuff can be configured-around by the user. We are 
just talking about the defaults, here. If you want to serve static content from 
`/static/*.jpg` but dynamic files from `/dynamic/*.jpg` which need protection, 
then you can set up a regular-expression-based check.
   
   An out-of-the-box default should work for "a great many environments" not 
"every single conceivable environment".



-- 
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: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to