Skip to content
Permalink
Browse files

[JENKINS-45519] Fix keepUndefinedParameters option for suppressing wa…

…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 354f3802430bf114869796279305177a0091aa70
Showing with 3 additions and 3 deletions.
  1. +3 −3 core/src/main/java/hudson/model/ParametersAction.java
@@ -316,8 +316,8 @@ public void onLoad(Run<?, ?> r) {
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;
}

@@ -326,7 +326,7 @@ public void onLoad(Run<?, ?> r) {
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.",

0 comments on commit 354f380

Please sign in to comment.
You can’t perform that action at this time.