Permalink
Browse files

[JENKINS-23447] only mask sensible data when injectedEnvVars.txt is p…

…ersisted or exposed on UI
  • Loading branch information...
ndeloof committed Dec 17, 2014
1 parent b7191c5 commit e181ac473a9ea3d8b531ff0f061e7ca7071f7d87
Showing with 13 additions and 7 deletions.
  1. +13 −7 src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
@@ -30,6 +30,7 @@
*/
private transient Map<String, String> resultVariables;
private transient File rootDir;
private transient Set<String> sensibleVariables;
public EnvInjectAction(AbstractBuild build, Map<String, String> envMap) {
this.build = build;
@@ -49,12 +50,8 @@ public void overrideAll(final Set<String> sensibleVariables, Map<String, String>
return;
}
envMap.putAll(Maps.transformEntries(all,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return sensibleVariables.contains(key) ? "********" : value;
}
}));
this.sensibleVariables = sensibleVariables;
envMap.putAll(all);
}
@SuppressWarnings({"unused", "unchecked"})
@@ -91,7 +88,12 @@ private Object writeReplace() throws ObjectStreamException {
EnvInjectSavable dao = new EnvInjectSavable();
if (rootDir == null) {
dao.saveEnvironment(build.getRootDir(), envMap);
dao.saveEnvironment(build.getRootDir(), Maps.transformEntries(envMap,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return sensibleVariables.contains(key) ? "********" : value;
}
}));
return this;
}
@@ -152,4 +154,8 @@ private Object readResolve() throws ObjectStreamException {
public Object getTarget() {
throw new UnsupportedOperationException();
}
public Set<String> getSensibleVariables() {
return sensibleVariables;
}
}

0 comments on commit e181ac4

Please sign in to comment.