XStream を使ってみたところ、
XML読込みをしたら、読込みは成功するものの、標準エラー出力、System.err で
Security framework of XStream not initialized, XStream is probably vulnerable.
が出力された。
使ったバージョンは、1.4.10
public static void setupDefaultSecurity(final XStream xstream) というメソッドが、XStream にあって
ここに説明が書いてあるのだが、2017-06-02 時点、まだ、1.5.x は出てない。
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.
それで、このメソッドを呼べばいいのかと試したら、、com.thoughtworks.xstream.security.ForbiddenClassException に
なってしまう。
仕方ないので、インスタンス生成時に実行されている protected void setupSecurity() をオーバーライドして
セキュリティパーミッションを検査する起因のフラグがONにならないようにしてやる。
XStream stream = new XStream(){ @Override protected void setupSecurity() { addPermission(AnyTypePermission.ANY); } };
こうすると警告は出ない。