downgrade ognl to 3.3.5. #2954, #2953

This commit is contained in:
hengyunabc 2024-11-20 17:12:37 +08:00
parent 6cee2d33f3
commit aa23a4acc9
5 changed files with 15 additions and 14 deletions

View File

@ -1,9 +1,10 @@
package com.taobao.arthas.core.command.express;
import java.util.Map;
import com.taobao.arthas.core.GlobalOptions;
import ognl.ObjectPropertyAccessor;
import ognl.OgnlContext;
import ognl.OgnlException;
/**
@ -12,7 +13,7 @@ import ognl.OgnlException;
public class ArthasObjectPropertyAccessor extends ObjectPropertyAccessor {
@Override
public Object setPossibleProperty(OgnlContext context, Object target, String name, Object value) throws OgnlException {
public Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException {
if (GlobalOptions.strict) {
throw new IllegalAccessError(GlobalOptions.STRICT_MESSAGE);
}

View File

@ -4,7 +4,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import ognl.ClassResolver;
import ognl.OgnlContext;
/**
* @author hengyunabc 2018-10-18
@ -20,9 +19,8 @@ public class ClassLoaderClassResolver implements ClassResolver {
this.classLoader = classLoader;
}
@Override
public <T> Class<T> classForName(String className, OgnlContext ognlContext) throws ClassNotFoundException {
public Class classForName(String className, Map context) throws ClassNotFoundException {
Class<?> result = null;
if ((result = classes.get(className)) == null) {
@ -39,6 +37,6 @@ public class ClassLoaderClassResolver implements ClassResolver {
}
classes.put(className, result);
}
return (Class<T>) result;
return result;
}
}

View File

@ -1,7 +1,6 @@
package com.taobao.arthas.core.command.express;
import ognl.ClassResolver;
import ognl.OgnlContext;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -21,7 +20,7 @@ public class CustomClassResolver implements ClassResolver {
}
@Override
public <T> Class<T> classForName(String className, OgnlContext ognlContext) throws ClassNotFoundException {
public Class classForName(String className, Map context) throws ClassNotFoundException {
Class<?> result = null;
if ((result = classes.get(className)) == null) {
@ -40,6 +39,6 @@ public class CustomClassResolver implements ClassResolver {
}
classes.put(className, result);
}
return (Class<T>) result;
return result;
}
}

View File

@ -1,11 +1,11 @@
package com.taobao.arthas.core.command.express;
import ognl.MemberAccess;
import ognl.OgnlContext;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.util.Map;
/**
* ognl.DefaultMemberAccess (ognl:ognl:3.1.19)
@ -58,7 +58,8 @@ public class DefaultMemberAccess implements MemberAccess {
allowPackageProtectedAccess = value;
}
public Object setup(OgnlContext context, Object target, Member member, String propertyName) {
@Override
public Object setup(Map context, Object target, Member member, String propertyName) {
Object result = null;
if (isAccessible(context, target, member, propertyName)) {
@ -72,7 +73,8 @@ public class DefaultMemberAccess implements MemberAccess {
return result;
}
public void restore(OgnlContext context, Object target, Member member, String propertyName, Object state) {
@Override
public void restore(Map context, Object target, Member member, String propertyName, Object state) {
if (state != null) {
((AccessibleObject)member).setAccessible((Boolean)state);
}
@ -88,7 +90,8 @@ public class DefaultMemberAccess implements MemberAccess {
* @param propertyName the property to test accessibility for (not used).
* @return true if the member is accessible in the context, false otherwise.
*/
public boolean isAccessible(OgnlContext context, Object target, Member member, String propertyName) {
@Override
public boolean isAccessible(Map context, Object target, Member member, String propertyName) {
int modifiers = member.getModifiers();
boolean result = Modifier.isPublic(modifiers);

View File

@ -161,7 +161,7 @@
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.4.2</version>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>