-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-39232] Walk the DelegatingComputerLauncher instances when checking if JNLPComputerLauncher #2602
Conversation
…ecking if JNLPComputerLauncher
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
I do not believe it's a perfect fix since anybody can implement his own launcher using I agree it worths adding support of Delegating launchers, but it does not fix the issue |
…tinue to work until they get fixed
* {@link ComputerLauncher} when then should have extended {@link DelegatingComputerLauncher} | ||
* | ||
* @since FIXME | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Extension(NoExternalUse.class)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@Override | ||
public boolean owns(String clientName) { | ||
Computer computer = Jenkins.getInstance().getComputer(clientName); | ||
return computer != null; | ||
} | ||
|
||
private static ComputerLauncher getDelegate(ComputerLauncher launcher) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckForNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment wasn't addressed?
Method getDelegate = launcher.getClass().getMethod("getDelegate"); | ||
return ComputerLauncher.class.isAssignableFrom(getDelegate.getReturnType()) ? (ComputerLauncher) getDelegate | ||
.invoke(launcher) : null; | ||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReflectiveOperationException?
launcher = ((DelegatingComputerLauncher) launcher).getLauncher(); | ||
} else if (launcher instanceof ComputerLauncherFilter) { | ||
launcher = ((ComputerLauncherFilter) launcher).getCore(); | ||
} else if (null != (l = getDelegate(launcher))) { // TODO remove when all plugins are fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not guarantee a success for old plugins from what I see
} else { | ||
if (disableStrictVerification) { | ||
LOGGER.log(Level.WARNING, "Connecting {0} as a JNLP agent where the launcher does not mark itself " | ||
+ "correctly as being a JNLP agent", clientName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explicitly provide a class of the launcher
+ "correctly as being a JNLP agent", clientName); | ||
break; | ||
} else { | ||
event.reject(new ConnectionRefusalException(String.format("%s is not a JNLP agent", clientName))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 In the case of enforcement must contain more details. E.g. link to the Wiki page providing a workaround info. Or just in-text help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to go in such way, we need better diagnostic messages. 🐛 for it.
I still have concerns about such approach due to impact on plugins, but it's a subject for voting by @jenkinsci/core
- Since the failure of strict verification is an issue, we should log it as a warning always
I approve the code change itself since it makes the situation better that it is in 2.27. So 🐝 and 👍 as a partial fix. But I still do not feel it's a right approach to nuke so many instances. Hence as a community member I keep 👎 regarding the change as a complete fix of JENKINS-39232 |
@reviewbybees done |
P.S: I will follow-up on the default behavior |
I will merge it into the next weekly if nobody shouts |
return (ComputerLauncher) getDelegate.invoke(launcher); | ||
} | ||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { | ||
// ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can name ignore
instead e
to disable warnings static analysing tools.
launcher = ((DelegatingComputerLauncher) launcher).getLauncher(); | ||
} else if (launcher instanceof ComputerLauncherFilter) { | ||
launcher = ((ComputerLauncherFilter) launcher).getCore(); | ||
} else if (null != (l = getDelegate(launcher))) { // TODO remove when all plugins are fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO jenkins 3.x and don't break existing plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While technically, it doesn't qualify as an S, there are issues of that nature removed by enforcing that only agents explicitly configured to use a JNLP launcher get to use a JNLP launcher... especially as only a JNLP launcher will have a cookie and hence any existing connection will be dropped in favour of an incoming JNLP connection with a valid secret (it's the valid that stops it being an S... because if you've let somebody else get the master key driving the JNLP secrets... well that's your problem right there)
See JENKINS-39232
@jenkinsci/code-reviewers @reviewbybees
Replaces #2601