Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: shade com.alibaba.* #534

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public boolean isMatch(RuntimeMXBean paramRuntimeMXBean, ClassLoader loader) {
} catch (Throwable ignored) {
}
try {
loader.loadClass("com.alibaba.dubbo.monitor.support.MonitorFilter");
loader.loadClass(" com.alibaba.dubbo.monitor.support.MonitorFilter".substring(1));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the same class is being loaded here. What is the benefit of writing it this way?

return true;
} catch (Throwable ignored) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

public class FastjsonCheck implements SinkSafeChecker {
public static List<String> FASTJSON_SINK_METHODS = Arrays.asList(
"com.alibaba.fastjson.JSON.parseObject(java.lang.String)",
"com.alibaba.fastjson.JSON.parse(java.lang.String,int)",
"com.alibaba.fastjson.JSON.parse(java.lang.String)"
" com.alibaba.fastjson.JSON.parseObject(java.lang.String)".substring(1),
" com.alibaba.fastjson.JSON.parse(java.lang.String,int)".substring(1),
" com.alibaba.fastjson.JSON.parse(java.lang.String)".substring(1)
);

private String policySignature;
Expand All @@ -36,9 +36,9 @@ public boolean isSafe(MethodEvent event, SinkNode sinkNode) {
try {
Class<?> cls;
if (JSON_CLASS_LOADER == null) {
cls = Class.forName("com.alibaba.fastjson.JSON");
cls = Class.forName(" com.alibaba.fastjson.JSON".substring(1));
} else {
cls = Class.forName("com.alibaba.fastjson.JSON", false, JSON_CLASS_LOADER);
cls = Class.forName(" com.alibaba.fastjson.JSON".substring(1), false, JSON_CLASS_LOADER);
}
Field f = cls.getDeclaredField("VERSION");
Class<?> t = f.getType();
Expand All @@ -61,9 +61,9 @@ public boolean isSafe(MethodEvent event, SinkNode sinkNode) {
// https://github.com/alibaba/fastjson/wiki/fastjson_safemode
Class<?> cfgClass;
if (PARSE_CONFIG_CLASS_LOADER == null) {
cfgClass = Class.forName("com.alibaba.fastjson.parser.ParserConfig");
cfgClass = Class.forName(" com.alibaba.fastjson.parser.ParserConfig".substring(1));
} else {
cfgClass = Class.forName("com.alibaba.fastjson.parser.ParserConfig", false, PARSE_CONFIG_CLASS_LOADER);
cfgClass = Class.forName(" com.alibaba.fastjson.parser.ParserConfig".substring(1), false, PARSE_CONFIG_CLASS_LOADER);
}
Object cfg = cfgClass.getMethod("getGlobalInstance").invoke(null);
Object isSafeMode = cfg.getClass().getMethod("isSafeMode").invoke(cfg);
Expand Down