Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
app(security): Hessian's serializer factory with black class list
Browse files Browse the repository at this point in the history
  • Loading branch information
linux-china committed Mar 17, 2024
1 parent 3b178db commit 04ca8d6
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.alibaba.rsocket.encoding.impl;

import com.alibaba.rsocket.observability.RsocketErrorCode;
import com.caucho.hessian.io.Deserializer;
import com.caucho.hessian.io.HessianProtocolException;
import com.caucho.hessian.io.SerializerFactory;

import java.util.HashSet;
import java.util.Set;

/**
* Hessian's serializer factory with black class list
*
* @author linux_china
*/
public class HessianSerializerFactoryWithBlackList extends SerializerFactory {
public static final Set<String> BLACK_CLASSES = new HashSet<>();

static {
BLACK_CLASSES.add("org.springframework.context.support.ClassPathXmlApplicationContext");
BLACK_CLASSES.add("javax.swing.UIDefaults$ProxyLazyValue");
}

@Override
public Deserializer getObjectDeserializer(String type, Class cl) throws HessianProtocolException {
if (BLACK_CLASSES.contains(type)) {
throw new HessianProtocolException(RsocketErrorCode.message("RST-700401", type));
}
return super.getObjectDeserializer(type, cl);
}
}

0 comments on commit 04ca8d6

Please sign in to comment.