Skip to content
Permalink
Browse files
[JENKINS-41653] better safe than sorry
  • Loading branch information
escoem committed Oct 31, 2017
1 parent 484b700 commit 653b6c76774250533b4fade34a86b4c4e501908c
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/main/java/com/cloudbees/jenkins/support/configfiles/SecretHandler.java
@@ -40,6 +40,13 @@
public static final String OUTPUT_ENCODING = "UTF-8";
public static final Pattern SECRET_PATTERN = Pattern.compile(">\\{(.*)\\}<|>(.*)\\=<");

/**
* Enabled by default.
* FALLBACK will be disable in case you define a system property like -Dsupport-core-plugin.SecretHandler.ENABLE_FALLBACK=false
* Otherwise will be enabled.
*/
private static boolean ENABLE_FALLBACK = !StringUtils.equalsIgnoreCase(System.getProperty("support-core-plugin.SecretHandler.ENABLE_FALLBACK", "TRUE"), "FALSE");

/**
* find the secret in the xml file and replace it with the place holder
* @param xmlFile we want to parse
@@ -95,7 +102,11 @@ public void characters(char[] ch, int start, int length) throws SAXException {
transformer.transform(src, res);
return result.toString("UTF-8");
} catch (TransformerException e) {
return findSecretFallback(str);
if (ENABLE_FALLBACK) {
return findSecretFallback(str);
} else {
throw e;
}
}
}

0 comments on commit 653b6c7

Please sign in to comment.