From 6c88ed0ab9cdca75d08502e756367a0d253d4d99 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Thu, 5 Jan 2017 11:29:26 +0000 Subject: [PATCH] Implemented: Create and use an OWASP PolicyFactory for content sanitization in ContentWorker for Birt Report Builder (OFBIZ-9166) This is still an incomplete feature because I did not find yet a way to complete the BIRT_REPORT_BUILDER_USAGE_POLICY and had to bypass the sanitization for this case, WIP... This commit has no effect on OFBiz yet. I need to commit this now to continue to work on the main task: OFBIZ-6919 "New implementation of Birt. Easier user possibility of report creation". git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1777451 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/content/content/ContentWorker.java | 22 +++--- .../order/order/OrderContentWrapper.java | 2 +- .../party/content/PartyContentWrapper.java | 6 +- .../category/CategoryContentWrapper.java | 2 +- .../ProductConfigItemContentWrapper.java | 6 +- .../product/ProductContentWrapper.java | 6 +- .../product/ProductPromoContentWrapper.java | 6 +- .../content/WorkEffortContentWrapper.java | 6 +- .../org/apache/ofbiz/base/util/UtilCodec.java | 74 ++++++++++++++++++- 9 files changed, 100 insertions(+), 30 deletions(-) diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java index 049e6eba77..f891e014cb 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java @@ -335,18 +335,22 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor String mimeTypeId, boolean cache) throws GeneralException, IOException { Writer writer = new StringWriter(); renderContentAsText(dispatcher, contentId, writer, templateContext, locale, mimeTypeId, null, null, cache); + GenericValue content = EntityQuery.use(dispatcher.getDelegator()).from("Content").where("contentId", contentId).queryOne(); + String contentTypeId = content.getString("contentTypeId"); String rendered = writer.toString(); // According to https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#XSS_Prevention_Rules_Summary // Normally head is protected by X-XSS-Protection Response Header by default - if (rendered.contains("