Skip to content

Commit

Permalink
Merge pull request #50 from andham/JENKINS-4428
Browse files Browse the repository at this point in the history
[FIXED JENKINS-4428] MavenProbeAction exposes password parameters
  • Loading branch information
olamy committed Mar 24, 2016
2 parents cc6027c + 3e97072 commit 9c5eb51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -848,7 +848,7 @@ protected Result doRun(final BuildListener listener) throws Exception {

MavenProbeAction mpa=null;
try {
mpa = new MavenProbeAction(project,process.channel);
mpa = new MavenProbeAction(project, process.channel, MavenModuleSetBuild.this);
addAction(mpa);
r = process.call(builder);
for (ProxyImpl2 proxy : proxies.values()) {
Expand Down
36 changes: 33 additions & 3 deletions src/main/java/hudson/maven/MavenProbeAction.java
Expand Up @@ -33,9 +33,13 @@
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import com.google.common.collect.Maps;

import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
* UI for probing Maven process.
Expand All @@ -49,11 +53,13 @@
*/
public final class MavenProbeAction implements Action {
private final transient Channel channel;
private final transient AbstractMavenBuild<?,?> build;

public final AbstractProject<?,?> owner;

MavenProbeAction(AbstractProject<?,?> owner, Channel channel) {
MavenProbeAction(AbstractProject<?,?> owner, Channel channel, AbstractMavenBuild<?,?> build) {
this.channel = channel;
this.build = build;
this.owner = owner;
}

Expand All @@ -76,15 +82,39 @@ public String getUrlName() {
* If this is the master, it returns the system property of the master computer.
*/
public Map<Object,Object> getSystemProperties() throws IOException, InterruptedException {
return RemotingDiagnostics.getSystemProperties(channel);
Map<Object,Object> props = RemotingDiagnostics.getSystemProperties(channel);

if (build != null) {
final Set<String> sensitiveBuildVars = build.getSensitiveBuildVariables();
props = new TreeMap<Object, Object>(Maps.transformEntries(props,
new Maps.EntryTransformer<Object, Object, Object>() {
public Object transformEntry(Object key, Object value) {
return sensitiveBuildVars.contains(key.toString()) ? "********" : value;
}
}));
}

return props;
}

/**
* Gets the environment variables of the JVM on this computer.
* If this is the master, it returns the system property of the master computer.
*/
public Map<String,String> getEnvVars() throws IOException, InterruptedException {
return EnvVars.getRemote(channel);
EnvVars vars = EnvVars.getRemote(channel);

if (build != null) {
final Set<String> sensitiveBuildVars = build.getSensitiveBuildVariables();
vars = new EnvVars(Maps.transformEntries(vars,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return sensitiveBuildVars.contains(key) ? "********" : value;
}
}));
}

return vars;
}

/**
Expand Down

0 comments on commit 9c5eb51

Please sign in to comment.