tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] spmallette closed pull request #1034: Mask security secret or password
Date Wed, 09 Jan 2019 18:39:53 GMT
spmallette closed pull request #1034: Mask security secret or password
URL: https://github.com/apache/tinkerpop/pull/1034
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/kryoshim/KryoShimServiceLoader.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/kryoshim/KryoShimServiceLoader.java
index 70be7ad5b2..9340d0f5ba 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/kryoshim/KryoShimServiceLoader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/kryoshim/KryoShimServiceLoader.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim;
 
+import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationUtils;
 import org.apache.tinkerpop.gremlin.util.SystemUtil;
@@ -26,10 +27,7 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.ServiceLoader;
+import java.util.*;
 
 /**
  * Loads the highest-priority or user-selected {@link KryoShimService}.
@@ -38,6 +36,7 @@
 
     private static volatile KryoShimService cachedShimService;
     private static volatile Configuration configuration;
+    private static String maskedProperties = ".+\\.(password|keyStorePassword|trustStorePassword)|spark.authenticate.secret";
 
     private static final Logger log = LoggerFactory.getLogger(KryoShimServiceLoader.class);
 
@@ -127,11 +126,24 @@ private static KryoShimService load(final boolean forceReload) {
         // once the shim service is defined, configure it
         log.info("Configuring KryoShimService {} with the following configuration:\n#######START########\n{}\n########END#########",
                 cachedShimService.getClass().getCanonicalName(),
-                ConfigurationUtils.toString(configuration));
+                ConfigurationUtils.toString(maskedConfiguration(configuration)));
         cachedShimService.applyConfiguration(configuration);
         return cachedShimService;
     }
 
+    private static Configuration maskedConfiguration(Configuration configuration) {
+        Configuration maskedConfiguration = new BaseConfiguration();
+        Iterator keys = configuration.getKeys();
+        while(keys.hasNext()) {
+            String key = (String)keys.next();
+            if (key.matches(maskedProperties))
+                maskedConfiguration.setProperty(key, "******");
+            else
+                maskedConfiguration.setProperty(key, configuration.getProperty(key));
+        }
+        return maskedConfiguration;
+    }
+
     /**
      * A loose abstraction of {@link org.apache.tinkerpop.shaded.kryo.Kryo#writeClassAndObject},
      * where the {@code output} parameter is an internally-created {@link ByteArrayOutputStream}.
 Returns


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message