"Applied fix from trunk for revision: 1850015 "
------------------------------------------------------------------------ r1850015 | jleroux | 2018-12-31 07:38:36 +0100 (lun. 31 déc. 2018) | 16 lignes Improved: Prepare the migration to XStream 1.5 (OFBIZ-10756) Fixes CVE-2018-17200 We currently use the UnsupportedClassConverter method in UtilXml class. When the 1.5 version of XStream will be available another way to handle this kind of things will be available and used by default. It's already possible to use the same with the 1.4 version of XStream with its setupDefaultSecurity method. So this replaces the UnsupportedClassConverter in UtilXml class by XStream::setupDefaultSecurity method. It's an improvement but better to backport it as much as possible The UtilXmlTests class and its use is removed and the UnsupportedClassConverter method deprecated (no use OOTB) ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1850016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -91,7 +91,15 @@ public final class UtilXml {
|
||||
|
||||
private static XStream createXStream() {
|
||||
XStream xstream = new XStream();
|
||||
xstream.registerConverter(new UnsupportedClassConverter());
|
||||
/* This method is a pure helper method for XStream 1.4.x.
|
||||
* It initializes an XStream instance with a white list of well-known and simply types of the Java runtime
|
||||
* as it is done in XStream 1.5.x by default. This method will do therefore nothing in XStream 1.5
|
||||
* and could be removed them
|
||||
*/
|
||||
XStream.setupDefaultSecurity(xstream);
|
||||
/* You may want to enhance the white list created by XStream::setupDefaultSecurity (or by default with XStream 1.5)
|
||||
* using xstream::allowTypesByWildcard with your own classes
|
||||
*/
|
||||
return xstream;
|
||||
}
|
||||
|
||||
@@ -1167,6 +1175,11 @@ public final class UtilXml {
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is now useless
|
||||
* Enhance rather the white list created by XStream::setupDefaultSecurity
|
||||
* using xstream::allowTypesByWildcard with your own classes
|
||||
*/
|
||||
@Deprecated
|
||||
private static class UnsupportedClassConverter implements Converter {
|
||||
|
||||
@Override
|
||||
@@ -1191,7 +1204,7 @@ public final class UtilXml {
|
||||
/**
|
||||
* get node name without any prefix
|
||||
* @param node
|
||||
* @return
|
||||
* @return nodeName
|
||||
*/
|
||||
public static String getNodeNameIgnorePrefix(Node node){
|
||||
if (node==null) {
|
||||
@@ -1208,8 +1221,8 @@ public final class UtilXml {
|
||||
/**
|
||||
* get tag name without any prefix
|
||||
* @param element
|
||||
* @return
|
||||
*/
|
||||
* @return tagName
|
||||
*/
|
||||
public static String getTagNameIgnorePrefix(Element element){
|
||||
if (element==null) {
|
||||
return null;
|
||||
@@ -1225,7 +1238,7 @@ public final class UtilXml {
|
||||
/**
|
||||
* get attribute value ignoring prefix in attribute name
|
||||
* @param element
|
||||
* @return
|
||||
* @return The value of the node, depending on its type; see the table Node class
|
||||
*/
|
||||
public static String getAttributeValueIgnorePrefix(Element element, String attributeName){
|
||||
if (element==null) {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.ofbiz.base.util.test;
|
||||
|
||||
import org.apache.ofbiz.base.test.GenericTestCaseBase;
|
||||
import org.apache.ofbiz.base.util.UtilXml;
|
||||
|
||||
public class UtilXmlTests extends GenericTestCaseBase {
|
||||
|
||||
public UtilXmlTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testUnsupportedClassConverter() throws Exception {
|
||||
String unsupportedClassInXml =
|
||||
"<handler class=\"java.beans.EventHandler\">" +
|
||||
" <target class=\"java.lang.ProcessBuilder\">" +
|
||||
" <command>" +
|
||||
" <string>open</string>" +
|
||||
" <string>.</string>" +
|
||||
" </command>" +
|
||||
" </target>" +
|
||||
" <action>start</action>" +
|
||||
"</handler>";
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
Object unsupportedObject = UtilXml.fromXml(unsupportedClassInXml);
|
||||
fail("Unsupported class in XML");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user