You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/08/05 21:49:29 UTC

[1/3] git commit: ACCUMULO-3043 Limit to valid and sensitive properties pulled from CredentialProviders

Repository: accumulo
Updated Branches:
  refs/heads/1.6.1-SNAPSHOT 16f14bd1d -> 0b892921b
  refs/heads/master 440281b87 -> f5984b35a


ACCUMULO-3043 Limit to valid and sensitive properties pulled from CredentialProviders

We only check CredentialProviders for Sensitive Property's, as such,
when we list out all Property's, we should also adhere to that same
practice.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0b892921
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0b892921
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0b892921

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 0b892921b281a10690311ab5b08b1fa739b48835
Parents: 16f14bd
Author: Josh Elser <el...@apache.org>
Authored: Tue Aug 5 15:45:21 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Aug 5 15:47:45 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/conf/SiteConfiguration.java   |  11 ++-
 .../core/conf/SiteConfigurationTest.java        |  74 +++++++++++++++++++
 .../accumulo-credentialprovider-site.xml        |  26 +++++++
 core/src/test/resources/site-cfg.jceks          | Bin 0 -> 1441 bytes
 4 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index a5e14af..f5cfb2b 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -36,8 +36,11 @@ public class SiteConfiguration extends AccumuloConfiguration {
   private static SiteConfiguration instance = null;
   
   private static Configuration xmlConfig;
-  
-  private SiteConfiguration(AccumuloConfiguration parent) {
+
+  /**
+   * Not for consumers. Call {@link SiteConfiguration#getInstance(AccumuloConfiguration)} instead
+   */
+  SiteConfiguration(AccumuloConfiguration parent) {
     SiteConfiguration.parent = parent;
   }
   
@@ -103,6 +106,10 @@ public class SiteConfiguration extends AccumuloConfiguration {
     if (null != hadoopConf) {
       try {
         for (String key : CredentialProviderFactoryShim.getKeys(hadoopConf)) {
+          if (!Property.isValidPropertyKey(key) || !Property.isSensitive(key)) { 
+            continue;
+          }
+
           if (filter.accept(key)) {
             char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf, key);
             if (null != value) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
new file mode 100644
index 0000000..822e09a
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.accumulo.core.conf;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
+import org.apache.hadoop.conf.Configuration;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SiteConfigurationTest {
+  private static boolean isCredentialProviderAvailable;
+
+
+  @BeforeClass
+  public static void checkCredentialProviderAvailable() {
+    try {
+      Class.forName(CredentialProviderFactoryShim.HADOOP_CRED_PROVIDER_CLASS_NAME);
+      isCredentialProviderAvailable = true;
+    } catch (Exception e) {
+      isCredentialProviderAvailable = false;
+    }
+  }
+
+  @Test
+  public void testOnlySensitivePropertiesExtractedFromCredetialProvider() throws SecurityException, NoSuchMethodException {
+    if (!isCredentialProviderAvailable) {
+      return;
+    }
+
+    SiteConfiguration siteCfg = EasyMock.createMockBuilder(SiteConfiguration.class).addMockedMethod("getHadoopConfiguration")
+        .withConstructor(AccumuloConfiguration.class).withArgs(DefaultConfiguration.getInstance()).createMock();
+    
+    // site-cfg.jceks={'ignored.property'=>'ignored', 'instance.secret'=>'mysecret', 'general.rpc.timeout'=>'timeout'}
+    URL keystore = SiteConfigurationTest.class.getResource("/site-cfg.jceks");
+    Assert.assertNotNull(keystore);
+    String keystorePath = new File(keystore.getFile()).getAbsolutePath();
+    
+    Configuration hadoopConf = new Configuration();
+    hadoopConf.set(CredentialProviderFactoryShim.CREDENTIAL_PROVIDER_PATH, "jceks://file" + keystorePath);
+    
+    EasyMock.expect(siteCfg.getHadoopConfiguration()).andReturn(hadoopConf).once();
+
+    EasyMock.replay(siteCfg);
+    
+    Map<String,String> props = new HashMap<String,String>();
+    siteCfg.getProperties(props, new AllFilter());
+    
+    Assert.assertEquals("mysecret", props.get(Property.INSTANCE_SECRET.getKey()));
+    Assert.assertEquals(null, props.get("ignored.property"));
+    Assert.assertEquals(Property.GENERAL_RPC_TIMEOUT.getDefaultValue(), props.get(Property.GENERAL_RPC_TIMEOUT.getKey()));
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/resources/accumulo-credentialprovider-site.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/accumulo-credentialprovider-site.xml b/core/src/test/resources/accumulo-credentialprovider-site.xml
new file mode 100644
index 0000000..a88ef27
--- /dev/null
+++ b/core/src/test/resources/accumulo-credentialprovider-site.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<configuration>
+  <property>
+    <name>general.security.credential.provider.paths</name>
+    <value>file:///</value>
+  </property>
+    
+</configuration>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/resources/site-cfg.jceks
----------------------------------------------------------------------
diff --git a/core/src/test/resources/site-cfg.jceks b/core/src/test/resources/site-cfg.jceks
new file mode 100755
index 0000000..ea56ed1
Binary files /dev/null and b/core/src/test/resources/site-cfg.jceks differ


[3/3] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f5984b35
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f5984b35
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f5984b35

Branch: refs/heads/master
Commit: f5984b35abf87541d1f3410b4d837d244de756f0
Parents: 440281b 0b89292
Author: Josh Elser <el...@apache.org>
Authored: Tue Aug 5 15:47:55 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Aug 5 15:47:55 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/conf/SiteConfiguration.java   |  11 ++-
 .../core/conf/SiteConfigurationTest.java        |  74 +++++++++++++++++++
 .../accumulo-credentialprovider-site.xml        |  26 +++++++
 core/src/test/resources/site-cfg.jceks          | Bin 0 -> 1441 bytes
 4 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f5984b35/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------


[2/3] git commit: ACCUMULO-3043 Limit to valid and sensitive properties pulled from CredentialProviders

Posted by el...@apache.org.
ACCUMULO-3043 Limit to valid and sensitive properties pulled from CredentialProviders

We only check CredentialProviders for Sensitive Property's, as such,
when we list out all Property's, we should also adhere to that same
practice.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0b892921
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0b892921
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0b892921

Branch: refs/heads/master
Commit: 0b892921b281a10690311ab5b08b1fa739b48835
Parents: 16f14bd
Author: Josh Elser <el...@apache.org>
Authored: Tue Aug 5 15:45:21 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Aug 5 15:47:45 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/conf/SiteConfiguration.java   |  11 ++-
 .../core/conf/SiteConfigurationTest.java        |  74 +++++++++++++++++++
 .../accumulo-credentialprovider-site.xml        |  26 +++++++
 core/src/test/resources/site-cfg.jceks          | Bin 0 -> 1441 bytes
 4 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index a5e14af..f5cfb2b 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -36,8 +36,11 @@ public class SiteConfiguration extends AccumuloConfiguration {
   private static SiteConfiguration instance = null;
   
   private static Configuration xmlConfig;
-  
-  private SiteConfiguration(AccumuloConfiguration parent) {
+
+  /**
+   * Not for consumers. Call {@link SiteConfiguration#getInstance(AccumuloConfiguration)} instead
+   */
+  SiteConfiguration(AccumuloConfiguration parent) {
     SiteConfiguration.parent = parent;
   }
   
@@ -103,6 +106,10 @@ public class SiteConfiguration extends AccumuloConfiguration {
     if (null != hadoopConf) {
       try {
         for (String key : CredentialProviderFactoryShim.getKeys(hadoopConf)) {
+          if (!Property.isValidPropertyKey(key) || !Property.isSensitive(key)) { 
+            continue;
+          }
+
           if (filter.accept(key)) {
             char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf, key);
             if (null != value) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
new file mode 100644
index 0000000..822e09a
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.accumulo.core.conf;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
+import org.apache.hadoop.conf.Configuration;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SiteConfigurationTest {
+  private static boolean isCredentialProviderAvailable;
+
+
+  @BeforeClass
+  public static void checkCredentialProviderAvailable() {
+    try {
+      Class.forName(CredentialProviderFactoryShim.HADOOP_CRED_PROVIDER_CLASS_NAME);
+      isCredentialProviderAvailable = true;
+    } catch (Exception e) {
+      isCredentialProviderAvailable = false;
+    }
+  }
+
+  @Test
+  public void testOnlySensitivePropertiesExtractedFromCredetialProvider() throws SecurityException, NoSuchMethodException {
+    if (!isCredentialProviderAvailable) {
+      return;
+    }
+
+    SiteConfiguration siteCfg = EasyMock.createMockBuilder(SiteConfiguration.class).addMockedMethod("getHadoopConfiguration")
+        .withConstructor(AccumuloConfiguration.class).withArgs(DefaultConfiguration.getInstance()).createMock();
+    
+    // site-cfg.jceks={'ignored.property'=>'ignored', 'instance.secret'=>'mysecret', 'general.rpc.timeout'=>'timeout'}
+    URL keystore = SiteConfigurationTest.class.getResource("/site-cfg.jceks");
+    Assert.assertNotNull(keystore);
+    String keystorePath = new File(keystore.getFile()).getAbsolutePath();
+    
+    Configuration hadoopConf = new Configuration();
+    hadoopConf.set(CredentialProviderFactoryShim.CREDENTIAL_PROVIDER_PATH, "jceks://file" + keystorePath);
+    
+    EasyMock.expect(siteCfg.getHadoopConfiguration()).andReturn(hadoopConf).once();
+
+    EasyMock.replay(siteCfg);
+    
+    Map<String,String> props = new HashMap<String,String>();
+    siteCfg.getProperties(props, new AllFilter());
+    
+    Assert.assertEquals("mysecret", props.get(Property.INSTANCE_SECRET.getKey()));
+    Assert.assertEquals(null, props.get("ignored.property"));
+    Assert.assertEquals(Property.GENERAL_RPC_TIMEOUT.getDefaultValue(), props.get(Property.GENERAL_RPC_TIMEOUT.getKey()));
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/resources/accumulo-credentialprovider-site.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/accumulo-credentialprovider-site.xml b/core/src/test/resources/accumulo-credentialprovider-site.xml
new file mode 100644
index 0000000..a88ef27
--- /dev/null
+++ b/core/src/test/resources/accumulo-credentialprovider-site.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<configuration>
+  <property>
+    <name>general.security.credential.provider.paths</name>
+    <value>file:///</value>
+  </property>
+    
+</configuration>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0b892921/core/src/test/resources/site-cfg.jceks
----------------------------------------------------------------------
diff --git a/core/src/test/resources/site-cfg.jceks b/core/src/test/resources/site-cfg.jceks
new file mode 100755
index 0000000..ea56ed1
Binary files /dev/null and b/core/src/test/resources/site-cfg.jceks differ