提交 c693f9e4 编写于 作者: S Sereinity 提交者: Oleg Nenashev

Stop warning about not keeping undefined parameters (#2687)

* Stop warning about not keeping undefined parameters

* Add javadoc on dontKeepUndefinedParameters parameter

* keepUndefinedParameters become a three state flag, remove dontKeepUndefinedParameters

* Add missing backtick in log message, reword the keepUndefinedParameters log
上级 a7b01851
......@@ -67,6 +67,16 @@ import jenkins.util.SystemProperties;
@ExportedBean
public class ParametersAction implements RunAction2, Iterable<ParameterValue>, QueueAction, EnvironmentContributingAction, LabelAssignmentAction {
/**
* Three state variable (null, false, true).
*
* If explicitly set to true, it will keep all variable, explicitly set to
* false it will drop all of them (except if they are marked safe).
* If null, and they are not safe, it will log a warning in logs to the user
* to let him choose the behavior
*
* @since TODO
*/
@Restricted(NoExternalUse.class)
public static final String KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME = ParametersAction.class.getName() +
".keepUndefinedParameters";
......@@ -306,7 +316,8 @@ public class ParametersAction implements RunAction2, Iterable<ParameterValue>, Q
return parameters;
}
if (SystemProperties.getBoolean(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME)) {
String shouldKeepFlag = SystemProperties.getString(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME);
if ("true".equalsIgnoreCase(shouldKeepFlag)) {
return parameters;
}
......@@ -315,10 +326,10 @@ public class ParametersAction implements RunAction2, Iterable<ParameterValue>, Q
for (ParameterValue v : this.parameters) {
if (this.parameterDefinitionNames.contains(v.getName()) || isSafeParameter(v.getName())) {
filteredParameters.add(v);
} else {
} else if ("false".equalsIgnoreCase(shouldKeepFlag)) {
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",
+ "even though it represents a security breach or `-D{2}=false` to no longer show this message.",
new Object [] { v.getName(), run.getParent().getFullName(), KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME, SAFE_PARAMETERS_SYSTEM_PROPERTY_NAME });
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册