uschindler commented on code in PR #16138: URL: https://github.com/apache/lucene/pull/16138#discussion_r3328590204
########## lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestSerializableObjectClassFilter.java: ########## @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.spatial3d.geom; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import org.apache.lucene.tests.util.LuceneTestCase; + +public class TestSerializableObjectClassFilter extends LuceneTestCase { + + static volatile boolean nonSerializableConstructed = false; + + /** A SerializableObject that is not registered in {@link StandardObjects}. */ + public static class CustomShape implements SerializableObject { + final int value; + + public CustomShape(int value) { + this.value = value; + } + + public CustomShape(InputStream inputStream) throws IOException { + this.value = SerializableObject.readInt(inputStream); + } + + @Override + public void write(OutputStream outputStream) throws IOException { + SerializableObject.writeInt(outputStream, value); + } + } + + /** Not a SerializableObject, but instantiable from an InputStream. */ + public static class NotASerializableObject { Review Comment: it should no only make sure it is constructed, it should have a static initializer to make sure the stati initializer is not executed (which is the biggest security issue here): ```java static { nonSerializableInitialized = true; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
