mirror of
https://github.com/apache/sqoop.git
synced 2025-05-09 18:02:27 +08:00
SQOOP-2618: Sqoop2: Mask S3 sensitive properties in HDFS configuration
(Abraham Fine via Jarek Jarcec Cecho)
This commit is contained in:
parent
1ea3db992b
commit
77be2a8f9c
@ -36,7 +36,8 @@ public class LinkConfig {
|
||||
@Input(size = 255, validators = { @Validator(DirectoryExistsValidator.class)})
|
||||
public String confDir;
|
||||
|
||||
@Input public Map<String, String> configOverrides;
|
||||
@Input(sensitiveKeyPattern = "(?i)(.*(password|key|secret).*)")
|
||||
public Map<String, String> configOverrides;
|
||||
|
||||
public LinkConfig() {
|
||||
configOverrides = new HashMap<>();
|
||||
|
@ -18,8 +18,15 @@
|
||||
package org.apache.sqoop.connector.hdfs;
|
||||
|
||||
import org.apache.sqoop.connector.hdfs.configuration.LinkConfig;
|
||||
import org.apache.sqoop.connector.hdfs.configuration.LinkConfiguration;
|
||||
import org.apache.sqoop.model.ConfigUtils;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MMapInput;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
@ -68,4 +75,39 @@ public void testInvalidURI() {
|
||||
assertFalse(validator.getStatus().canProceed(), uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSensitiveConfigOverridesKeys() {
|
||||
String nonSensitiveKey = "public";
|
||||
String valueString = "value";
|
||||
String filler = "blah";
|
||||
|
||||
String[] sensitiveWords = new String[] {"password", "key", "secret"};
|
||||
|
||||
LinkConfiguration linkConfiguration = new LinkConfiguration();
|
||||
LinkConfig config = new LinkConfig();
|
||||
linkConfiguration.linkConfig = config;
|
||||
config.configOverrides.put(nonSensitiveKey, valueString);
|
||||
for (String sensitiveWord : sensitiveWords) {
|
||||
for (String sensitiveWordWithCase : new String[] {sensitiveWord, sensitiveWord.toUpperCase()}) {
|
||||
config.configOverrides.put(filler + sensitiveWordWithCase + filler, valueString);
|
||||
config.configOverrides.put(sensitiveWordWithCase + filler, valueString);
|
||||
config.configOverrides.put(filler + sensitiveWordWithCase, valueString);
|
||||
}
|
||||
}
|
||||
|
||||
MConfig mLinkConfig = ConfigUtils.toConfigs(linkConfiguration).get(0);
|
||||
MMapInput mConfigOverrides = mLinkConfig.getMapInput("linkConfig.configOverrides");
|
||||
|
||||
Map<String, String> redactedMap = mConfigOverrides.getNonsenstiveValue();
|
||||
assertEquals(redactedMap.get(nonSensitiveKey), valueString);
|
||||
|
||||
for (String sensitiveWord : sensitiveWords) {
|
||||
for (String sensitiveWordWithCase : new String[] {sensitiveWord, sensitiveWord.toUpperCase()}) {
|
||||
assertEquals(redactedMap.get(filler + sensitiveWordWithCase + filler), MMapInput.SENSITIVE_VALUE_PLACEHOLDER);
|
||||
assertEquals(redactedMap.get(sensitiveWordWithCase + filler), MMapInput.SENSITIVE_VALUE_PLACEHOLDER);
|
||||
assertEquals(redactedMap.get(filler + sensitiveWordWithCase), MMapInput.SENSITIVE_VALUE_PLACEHOLDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user