Skip to content

Commit

Permalink
[JENKINS-45519] Fix keepUndefinedParameters option for suppressing wa…
Browse files Browse the repository at this point in the history
…rnings (#2939)

* Update ParametersAction.java

Pull request 2687 added a 'false' setting for this flag to prevent warning messages from being logged, but the logic doesn't match the message or the documentation. This updates the check, so that the warning message is correctly suppressed if `hudson.model.ParametersAction.keepUndefinedParameters` is set to false.

* Updated check to use optBoolean
  • Loading branch information
arothian authored and oleg-nenashev committed Jul 22, 2017
1 parent f4d5c76 commit 354f380
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/hudson/model/ParametersAction.java
Expand Up @@ -316,8 +316,8 @@ private List<? extends ParameterValue> filter(List<ParameterValue> parameters) {
return parameters;
}

String shouldKeepFlag = SystemProperties.getString(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME);
if ("true".equalsIgnoreCase(shouldKeepFlag)) {
Boolean shouldKeepFlag = SystemProperties.optBoolean(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME);
if (shouldKeepFlag != null && shouldKeepFlag.booleanValue()) {
return parameters;
}

Expand All @@ -326,7 +326,7 @@ private List<? extends ParameterValue> filter(List<ParameterValue> parameters) {
for (ParameterValue v : this.parameters) {
if (this.parameterDefinitionNames.contains(v.getName()) || isSafeParameter(v.getName())) {
filteredParameters.add(v);
} else if ("false".equalsIgnoreCase(shouldKeepFlag)) {
} else if (shouldKeepFlag == null) {
LOGGER.log(Level.WARNING, "Skipped parameter `{0}` as it is undefined on `{1}`. Set `-D{2}=true` to allow "
+ "undefined parameters to be injected as environment variables or `-D{3}=[comma-separated list]` to whitelist specific parameter names, "
+ "even though it represents a security breach or `-D{2}=false` to no longer show this message.",
Expand Down

0 comments on commit 354f380

Please sign in to comment.