[struts] branch WW-5327-non-java-beans updated: Extends exclusion list
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5327-non-java-beans in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-5327-non-java-beans by this push: new ce4015739 Extends exclusion list ce4015739 is described below commit ce4015739a1bc7458048ded66445d44adeb32f7e Author: Lukasz Lenart AuthorDate: Mon Jul 31 10:39:02 2023 +0200 Extends exclusion list --- .../com/opensymphony/xwork2/ognl/OgnlUtil.java | 2 +- .../src/main/resources/struts-excluded-classes.xml | 4 +-- .../com/opensymphony/xwork2/ognl/OgnlUtilTest.java | 37 +++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java index ecd226d39..8c1790229 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java +++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java @@ -194,7 +194,7 @@ public class OgnlUtil { try { classes.add(Class.forName(className)); } catch (ClassNotFoundException e) { -LOG.warn("Class: {} doesn't exist, ignoring it!", className); +throw new ConfigurationException("Cannot load class for exclusion/exemption configuration: " + className, e); } } diff --git a/core/src/main/resources/struts-excluded-classes.xml b/core/src/main/resources/struts-excluded-classes.xml index 2c8c6cdb5..294e2399b 100644 --- a/core/src/main/resources/struts-excluded-classes.xml +++ b/core/src/main/resources/struts-excluded-classes.xml @@ -38,8 +38,8 @@ java.lang.Thread, sun.misc.Unsafe, com.opensymphony.xwork2.ActionContext, -org.apache.commons.collections.BeanMap, -org.apache.commons.beanutils.BeanMap"/> +com.opensymphony.xwork2.ognl.SecurityMemberAccess, +com.opensymphony.xwork2.ognl.OgnlValueStack"/> context = ognlUtil.createDefaultContext(foo); + +String expression = "%{\n" + +"(#request.a=#@org.apache.commons.collections.BeanMap@{}) +\n" + +"(#request.a.setBean(#request.get('struts.valueStack')) == true) +\n" + +"(#request.b=#@org.apache.commons.collections.BeanMap@{}) +\n" + +"(#request.b.setBean(#request.get('a').get('context'))) +\n" + +"(#request.c=#@org.apache.commons.collections.BeanMap@{}) +\n" + +"(#request.c.setBean(#request.get('b').get('memberAccess'))) +\n" + + "(#request.get('c').put('excluded'+'PackageNames',#@org.apache.commons.collections.BeanMap@{}.keySet())) +\n" + + "(#request.get('c').put('excludedClasses',#@org.apache.commons.collections.BeanMap@{}.keySet()))\n" + +"}"; + +ognlUtil.setValue("title", context, foo, expression); + +assertEquals(foo.getTitle(), expression); + +SecurityMemberAccess sma = (SecurityMemberAccess) ((OgnlContext) context).getMemberAccess(); +assertTrue(sma.isClassExcluded(SecurityMemberAccess.class)); +} + public void testNullProperties() { Foo foo = new Foo(); foo.setALong(88); @@ -1834,19 +1861,19 @@ public class OgnlUtilTest extends XWorkTestCase { defaultOgnlCacheFactory.setUseLRUCache("false"); ognlCache = defaultOgnlCacheFactory.buildOgnlCache(); assertNotNull("No param build method result null ?", ognlCache); -assertEquals("Eviction limit for cache mismatches limit for factory ?", 12, ognlCache.getEvictionLimit() ); +assertEquals("Eviction limit for cache mismatches limit for factory ?", 12, ognlCache.getEvictionLimit()); ognlCache = defaultOgnlCacheFactory.buildOgnlCache(6, 6, 0.75f, false); assertNotNull("No param build method result null ?", ognlCache); -assertEquals("Eviction limit for cache mismatches limit for factory ?", 6, ognlCache.getEvictionLimit() ); +assertEquals("Eviction limit for cache mismatches limit for factory ?", 6, ognlCache.getEvictionLimit()); // LRU cache defaultOgnlCacheFactory.setCacheMaxSize("30"); defaultOgnlCacheFactory.setUseLRUCache("true"); ognlCache = defaultOgnlCacheFactory.buildOgnlCache(); assertNotNull("No param build method result null ?", ognlCache); -assertEquals("Eviction limit for cache mismatches limit for factory ?", 30, ognlCache.getEvictionLimit() ); +assertEquals("Eviction limit for cache mismatches limit for factory ?", 30, ognlCache.getEvictionLimit()); ognlCache = defaultOgnlCacheFactory.buildOgnlCache(15, 15, 0.75f, false); assertNotNull("No param build method result null ?", ognlCache); -assertEquals("Eviction limit for cache mismatches limit for factory ?", 15,
[struts] branch WW-5327-non-java-beans updated: WW-5327 Makes deprecated setters operational
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5327-non-java-beans in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-5327-non-java-beans by this push: new f6737841f WW-5327 Makes deprecated setters operational f6737841f is described below commit f6737841f82de643ce334feec1bf23238ac0a1fe Author: Lukasz Lenart AuthorDate: Mon Jul 31 10:51:22 2023 +0200 WW-5327 Makes deprecated setters operational --- .../com/opensymphony/xwork2/ognl/SecurityMemberAccess.java | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java b/core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java index 4abbc1998..18acc675c 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java +++ b/core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java @@ -304,7 +304,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setExcludeProperties(Set excludeProperties) { -throw new UnsupportedOperationException("Please use #useExcludeProperties() instead!"); +this.excludeProperties = excludeProperties; } public void useExcludeProperties(Set excludeProperties) { @@ -316,7 +316,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setAcceptProperties(Set acceptedProperties) { -throw new UnsupportedOperationException("Please use #useAcceptProperties() instead!"); +this.acceptProperties = acceptedProperties; } public void useAcceptProperties(Set acceptedProperties) { @@ -328,7 +328,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setExcludedClasses(Set> excludedClasses) { -throw new UnsupportedOperationException("Please use #useExcludedClasses() instead!"); +this.excludedClasses = excludedClasses; } public void useExcludedClasses(Set> excludedClasses) { @@ -340,7 +340,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setExcludedPackageNamePatterns(Set excludedPackageNamePatterns) { -throw new UnsupportedOperationException("Please use #useExcludedPackageNamePatterns() instead!"); +this.excludedPackageNamePatterns = excludedPackageNamePatterns; } public void useExcludedPackageNamePatterns(Set excludedPackageNamePatterns) { @@ -352,7 +352,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setExcludedPackageNames(Set excludedPackageNames) { -throw new UnsupportedOperationException("Please use #useExcludedPackageNames() instead!"); +this.excludedPackageNames = excludedPackageNames; } public void useExcludedPackageNames(Set excludedPackageNames) { @@ -364,7 +364,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setExcludedPackageExemptClasses(Set> excludedPackageExemptClasses) { -throw new UnsupportedOperationException("Please use #useExcludedPackageExemptClasses() instead!"); +this.excludedPackageExemptClasses = excludedPackageExemptClasses; } public void useExcludedPackageExemptClasses(Set> excludedPackageExemptClasses) { @@ -376,7 +376,7 @@ public class SecurityMemberAccess implements MemberAccess { */ @Deprecated public void setDisallowProxyMemberAccess(boolean disallowProxyMemberAccess) { -throw new UnsupportedOperationException("Please use #disallowProxyMemberAccess() instead!"); +this.disallowProxyMemberAccess = disallowProxyMemberAccess; } public void disallowProxyMemberAccess(boolean disallowProxyMemberAccess) {
[struts] branch WW-5327-non-java-beans updated: WW-5327 Makes deprecated setters operational
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5327-non-java-beans in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-5327-non-java-beans by this push: new c7d88bea6 WW-5327 Makes deprecated setters operational c7d88bea6 is described below commit c7d88bea6f1f6be4d7ce76ec1bdd5310cd4e6176 Author: Lukasz Lenart AuthorDate: Mon Jul 31 10:52:42 2023 +0200 WW-5327 Makes deprecated setters operational --- core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java index 34fe3ae77..336312c89 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java +++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java @@ -484,7 +484,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS @Deprecated public void setAcceptProperties(Set acceptedProperties) { -throw new UnsupportedOperationException("Please use #useAcceptProperties instead!"); +securityMemberAccess.useAcceptProperties(acceptedProperties); } public void useAcceptProperties(Set acceptedProperties) { @@ -493,7 +493,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS @Deprecated public void setExcludeProperties(Set excludeProperties) { -throw new UnsupportedOperationException("Please use #useExcludeProperties instead!"); +securityMemberAccess.useExcludeProperties(excludeProperties); } public void useExcludeProperties(Set excludeProperties) {