Skip to content
Permalink
Browse files
[JENKINS-23447] only mask sensible data when displayed on UI or persi…
…sted on disk
  • Loading branch information
ndeloof committed Dec 17, 2014
1 parent d50c5a5 commit d3e2b61c7e858a6f34ec17a40a575e1a82d1274f
@@ -38,7 +38,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<envinject.lib.version>1.20</envinject.lib.version>
<envinject.lib.version>1.21</envinject.lib.version>
<ivy.plugin.version>1.21</ivy.plugin.version>
<junit.version>4.9</junit.version>
<mockito.version>1.8.5</mockito.version>
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.envinject;

import com.google.common.collect.Maps;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import org.apache.commons.collections.map.UnmodifiableMap;
@@ -10,6 +11,7 @@
import java.io.File;
import java.io.ObjectStreamException;
import java.util.Map;
import java.util.Set;

/**
* @author Gregory Boissinot
@@ -56,7 +58,13 @@ public String getUrlName() {
}

public Object getTarget() {
return new EnvInjectVarList(envMap);
final Set sensitiveVariables = build.getSensitiveBuildVariables();
return new EnvInjectVarList(Maps.transformEntries(envMap,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return sensitiveVariables.contains(key) ? "********" : value;
}
}));
}

@SuppressWarnings("unused")
@@ -1,11 +1,13 @@
package org.jenkinsci.plugins.envinject;

import com.google.common.collect.Maps;
import hudson.EnvVars;
import hudson.model.AbstractBuild;
import hudson.model.EnvironmentContributingAction;
import org.jenkinsci.lib.envinject.EnvInjectAction;

import java.util.Map;
import java.util.Set;

/**
* @author Gregory Boissinot
@@ -17,7 +19,12 @@ public EnvInjectPluginAction(AbstractBuild build, Map<String, String> envMap) {
}

public Object getTarget() {
return new EnvInjectVarList(envMap);
return new EnvInjectVarList(Maps.transformEntries(envMap,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return getSensibleVariables().contains(key) ? "********" : value;
}
}));
}

public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {

0 comments on commit d3e2b61

Please sign in to comment.