Skip to content

Commit

Permalink
[JENKINS-41653] better safe than sorry
Browse files Browse the repository at this point in the history
  • Loading branch information
escoem committed Oct 31, 2017
1 parent 484b700 commit 653b6c7
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -40,6 +40,13 @@ class SecretHandler {
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
Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 653b6c7

Please sign in to comment.