You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/08/18 22:38:33 UTC
[GitHub] [geode] kirklund commented on a change in pull request #6746: DRAFT: GEODE-9486: Fix validate-serializable-objects
kirklund commented on a change in pull request #6746:
URL: https://github.com/apache/geode/pull/6746#discussion_r691634284
##########
File path: geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java
##########
@@ -81,25 +81,6 @@ public ObjectInputStreamFilterWrapper(String serializationFilterSpec,
}
}
- try {
- URL sanctionedSerializables = ClassPathLoader.getLatest()
- .getResource(InternalDataSerializer.class, "sanctioned-geode-core-serializables.txt");
- Collection<String> coreClassNames =
- InternalDataSerializer.loadClassNames(sanctionedSerializables);
-
- URL sanctionedManagementSerializables = ClassPathLoader.getLatest()
- .getResource(InternalDataSerializer.class,
- "sanctioned-geode-management-serializables.txt");
- Collection<String> managmentClassNames =
- InternalDataSerializer.loadClassNames(sanctionedManagementSerializables);
-
- sanctionedClasses.addAll(coreClassNames);
- sanctionedClasses.addAll(managmentClassNames);
- } catch (IOException e) {
- throw new InternalGemFireException(
- "unable to read sanctionedSerializables.txt to form a serialization acceptlist", e);
- }
-
Review comment:
Note: This special-case section is no longer needed.
CoreSanctionedSerializablesService now exists in geode-core so that the above for-loop loads "sanctioned-geode-core-serializables.txt".
ManagementSanctionedSerializablesService now exists in geode-management so that the above for-loop loads "sanctioned-geode-management-serializables.txt".
##########
File path: geode-core/src/main/java/org/apache/geode/internal/io/CoreSanctionedSerializablesService.java
##########
@@ -12,20 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal.io;
+import java.net.URL;
-import org.apache.geode.internal.memcached.GeodeMemcachedService;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-public class AnalyzeMemcachedSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class CoreSanctionedSerializablesService implements SanctionedSerializablesService {
Review comment:
Note: github diff is confused and the code is correct.
AnalyzeMemcachedSerializablesJUnitTest was renamed to AnalyzeMemcachedSerializablesIntegrationTest and still exists in geode-memcached.
CoreSanctionedSerializablesService is a new class which is completely unrelated.
##########
File path: geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
##########
@@ -198,16 +201,23 @@
+ ";org.apache.shiro.*;org.apache.shiro.authz.*;org.apache.shiro.authc.*"
// export logs
- + ";org.apache.logging.log4j.Level" + ";org.apache.logging.log4j.spi.StandardLevel"
+ + ";org.apache.logging.log4j.Level"
+ + ";org.apache.logging.log4j.spi.StandardLevel"
// jar deployment
- + ";com.sun.proxy.$Proxy*" + ";com.healthmarketscience.rmiio.RemoteInputStream"
- + ";javax.rmi.ssl.SslRMIClientSocketFactory" + ";javax.net.ssl.SSLHandshakeException"
+ + ";com.sun.proxy.$Proxy*"
+ + ";com.healthmarketscience.rmiio.RemoteInputStream"
+ + ";javax.rmi.ssl.SslRMIClientSocketFactory"
+ + ";javax.net.ssl.SSLHandshakeException"
+ ";javax.net.ssl.SSLException;sun.security.validator.ValidatorException"
+ ";sun.security.provider.certpath.SunCertPathBuilderException"
// geode-modules
- + ";org.apache.geode.modules.util.SessionCustomExpiry" + ";";
+ + ";org.apache.geode.modules.util.SessionCustomExpiry"
+
+ // springframework
+ + ";org.springframework.**"
Review comment:
Please notice this addition! If validate-serializable-objects is turned on in the Locator, Pulse will require some number of springframework classes. We should probably try to narrow this down to specific .jars or packages, but because of transitive dependencies, I don't know a good way to create a comprehensive list.
##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
##########
@@ -192,11 +189,6 @@
private final GrantorRequestProcessor.GrantorRequestContext grc;
- /**
- * services provided by other modules
- */
- private Map<Class, DistributedSystemService> services = new HashMap<>();
-
Review comment:
Note: This Map was written to but never read. It was unused.
##########
File path: geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesIntegrationTest.java
##########
@@ -25,7 +28,7 @@ protected String getModuleName() {
}
@Override
- protected Class getModuleClass() {
- return GeodeRedisService.class;
+ protected Class<?> getModuleClass() {
+ return RedisSanctionedSerializablesService.class;
Review comment:
Note: Use class that implements SanctionedSerializablesService instead of unrelated GeodeRedisService.
##########
File path: geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCoreSerializablesIntegrationTest.java
##########
@@ -16,19 +16,19 @@
import org.junit.experimental.categories.Category;
-import org.apache.geode.connectors.jdbc.internal.ConnectorsDistributedSystemService;
+import org.apache.geode.internal.io.CoreSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeConnectorsSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeCoreSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
Review comment:
Note: github diff is confused... the code is correct.
AnalyzeConnectorsSerializablesJUnitTest was renamed to AnalyzeConnectorsSerializablesIntegrationTest which still exists in geode-connectors.
AnalyzeCoreSerializablesIntegrationTest is an unrelated new class in geode-core.
##########
File path: geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
##########
@@ -397,30 +427,6 @@ private static void clearSerializationFilter() {
serializationFilter = defaultSerializationFilter;
}
- /**
- * {@link DistributedSystemService}s that need to acceptlist Serializable objects can use this to
- * read them from a file and then return them via
- * {@link DistributedSystemService#getSerializationAcceptlist}
- */
- public static Collection<String> loadClassNames(URL sanctionedSerializables) throws IOException {
- ArrayList<String> result = new ArrayList<>(1000);
- try (InputStream inputStream = sanctionedSerializables.openStream();
- InputStreamReader reader = new InputStreamReader(inputStream);
- BufferedReader in = new BufferedReader(reader)) {
- String line;
- while ((line = in.readLine()) != null) {
- line = line.trim();
- if (!(line.startsWith("#") || line.startsWith("//"))) {
- line = line.replaceAll("/", ".");
- result.add(line.substring(0, line.indexOf(',')));
- }
- }
- }
- // logger.info("loaded {} class names from {}", result.size(), sanctionedSerializables);
- return result;
-
- }
-
Review comment:
Note: Moved to SanctionedSerializables in geode-serialization.
##########
File path: geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
##########
@@ -374,10 +393,21 @@ public static String processOutgoingClassName(final String nameArg, DataOutput o
* DistributionConfig
*
* @param distributionConfig the DistributedSystem configuration
- * @param services DistributedSystem services that might have classes to acceptlist
*/
- public static void initialize(DistributionConfig distributionConfig,
- Collection<DistributedSystemService> services) {
+ public static void initializeSerializationFilter(DistributionConfig distributionConfig) {
+ initializeSerializationFilter(distributionConfig, loadSanctionedSerializablesServices());
+ }
Review comment:
Note: loadSanctionedSerializablesServices() is in SanctionedSerializables in geode-serialization.
##########
File path: geode-dunit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeDUnitSerializablesIntegrationTest.java
##########
@@ -16,13 +16,19 @@
import org.junit.experimental.categories.Category;
+import org.apache.geode.test.dunit.internal.DUnitSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeCoreSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeDUnitSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
Review comment:
Note: github diff is confused... code is correct.
AnalyzeDUnitSerializablesIntegrationTest is a new test in geode-dunit.
AnalyzeCoreSerializablesJUnitTest was renamed to AnalyzeCoreSerializablesIntegrationTest which still exists in geode-core.
##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
##########
@@ -657,20 +649,6 @@ public MemoryAllocator getOffHeapStore() {
return offHeapStore;
}
- /**
- * Initialize any services that provided as extensions to the cache using the service loader
- * mechanism.
- */
- private void initializeServices() {
- ServiceLoader<DistributedSystemService> loader =
- ServiceLoader.load(DistributedSystemService.class);
- for (DistributedSystemService service : loader) {
- service.init(this);
- services.put(service.getInterface(), service);
- }
- }
-
-
Review comment:
Note: Moved to SanctionedSerializables class in geode-serialization.
##########
File path: geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java
##########
@@ -12,17 +12,23 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.gfsh.internal.management.GfshSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeGfshSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
Review comment:
Note: github diff is confused... the code is correct.
AnalyzeGfshSerializablesIntegrationTest is an unrelated new test in geode-gfsh.
AnalyzeManagementSerializablesJUnitTest was renamed to AnalyzeManagementSerializablesIntegrationTest which still exists in geode-management.
##########
File path: geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
##########
@@ -305,6 +297,10 @@ private void serializeAndDeserializeSanctionedObject(Object object) throws Excep
BufferDataOutputStream outputStream = new BufferDataOutputStream(KnownVersion.CURRENT);
try {
serializeObject(object, outputStream);
+ } catch (RemoteException e) {
+ System.out.println(object.getClass().getName() +
+ " is a java.rmi.server.RemoteObject which is not supported by AnalyzeSerializables");
+ return;
Review comment:
Note: geode-dunit uses RMI. Now that geode-dunit uses sanctioned serializables, a couple RMI classes are fed into this test. Supporting java.rmi.server.RemoteObject would require extra finesse that this test doesn't do and it's not worth implementing it for a test framework.
##########
File path: geode-memcached/build.gradle
##########
@@ -1,31 +1,30 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.
*/
apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"
apply from: "${project.projectDir}/../gradle/publish-java.gradle"
dependencies {
- compileOnly(platform(project(':boms:geode-all-bom')))
- compileOnly('com.github.stephenc.findbugs:findbugs-annotations')
+ api(platform(project(':boms:geode-all-bom')))
+ api('com.github.stephenc.findbugs:findbugs-annotations')
Review comment:
Question: for gradle experts... is this correct?
##########
File path: geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java
##########
@@ -12,20 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal.memcached;
+import java.net.URL;
-import org.apache.geode.gfsh.internal.management.GfshDistributedSystemService;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-public class AnalyzeGfshSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class MemcachedSanctionedSerializablesService implements SanctionedSerializablesService {
Review comment:
Note: github diffs are confused... the code is correct.
AnalyzeGfshSerializablesJUnitTest was renamed to AnalyzeGfshSerializablesIntegrationTest which still exists in geode-gfsh.
MemcachedDistributedSystemService was renamed to MemcachedSanctionedSerializablesService which still exists in geode-memcached.
##########
File path: geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java
##########
@@ -14,30 +14,36 @@
*/
package org.apache.geode.internal.memcached;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.InternalDataSerializer;
-import org.apache.geode.internal.classloader.ClassPathLoader;
+import org.junit.Test;
-public class MemcachedDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
- }
+public class MemcachedSanctionedSerializablesServiceIntegrationTest {
Review comment:
Note: github diffs are confused... the code is correct.
MemcachedDistributedSystemService was renamed to MemcachedSanctionedSerializablesService and still exists in geode-memcached.
MemcachedSanctionedSerializablesServiceIntegrationTest is a new test that was created to help debug it when I hit a problem adding the service.
##########
File path: geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java
##########
@@ -12,15 +12,14 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.distributed.internal;
+package org.apache.geode.internal.serialization;
-import java.io.IOException;
-import java.util.Collection;
+import java.net.URL;
-public interface DistributedSystemService {
- void init(InternalDistributedSystem internalDistributedSystem);
+public class SerializationSanctionedSerializablesService implements SanctionedSerializablesService {
Review comment:
Note: github diffs are confused... the code is correct.
DistributedSystemService was renamed to SanctionedSerializablesService and moved to geode-serialization.
SerializationSanctionedSerializablesService is a new class that implements SanctionedSerializablesService and also lives within geode-serialization.
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org