struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [struts] salcho commented on a change in pull request #430: WW-5084: Add Content Security Policy support to Struts
Date Thu, 20 Aug 2020 08:10:56 GMT

salcho commented on a change in pull request #430:
URL: https://github.com/apache/struts/pull/430#discussion_r473743634



##########
File path: core/src/main/java/org/apache/struts2/action/DefaultCspReportAction.java
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.action;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * The default implementation of {@link CspReportAction} that simply logs the JSON object
+ * that contains the details of the CSP violation.
+ *
+ * @see CspReportAction
+ */
+public class DefaultCspReportAction extends CspReportAction {
+
+    protected static final Logger LOG = LogManager.getLogger(DefaultCspReportAction.class);
+
+    @Override
+    void processReport(String jsonCspReport) {

Review comment:
       The `CspReportAction` ensures that reports sent to the reporting endpoint are correct
(e.g. use the right HTTP method, have the right Content-Type, etc.) and that responses to
them are correct too (they always return a 204). 
   
   After `CspReportAction` receives a valid request extracts its JSON body, it will call `processReport`
so that that report gets processed _somehow_ (i.e. dump to disk, extract a few keys from it
and log it, de-duplicate it with other reports, log it, etc.). 
   
   I believe there is value in keeping `CspReportAction`, here's what I'd propose: let's turn
`CspReportAction` into a concrete class (not abstract anymore) and remove `DefaultCspReportAction`
(which only logs the report anyway). `CspReportAction` would just log the report by default
(at DEBUG, perhaps?) and we could let devs override this class if they wanted to customize
the processing of the report.
   
   Does this sound reasonable?




----------------------------------------------------------------
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.

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



Mime
View raw message