-
-
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-45841] - Disable JNLP/JNLP2/CLI protocols on new installations #2950
Changes from 8 commits
ff6846a
f72cff3
9d5eb59
669958e
c71190e
398a0c5
6984791
5b6c675
e4c3ed6
4b8924b
b48c891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2017 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package jenkins.slaves; | ||
|
||
import hudson.Extension; | ||
import hudson.init.InitMilestone; | ||
import hudson.init.Initializer; | ||
import hudson.model.AdministrativeMonitor; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.annotation.CheckForNull; | ||
import jenkins.AgentProtocol; | ||
import jenkins.model.Jenkins; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
|
||
/** | ||
* Monitors enabled protocols and warns if a protocol is deprecated. | ||
* | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
@Extension | ||
@Symbol("remotingProtocolVersions") | ||
@Restricted(NoExternalUse.class) | ||
public class DeprecatedAgentProtocolMonitor extends AdministrativeMonitor { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(DeprecatedAgentProtocolMonitor.class.getName()); | ||
|
||
public DeprecatedAgentProtocolMonitor() { | ||
super(AgentProtocol.class.getName() + "-deprecated"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete and use the default ID |
||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Deprecated Remoting protocols"; | ||
} | ||
|
||
@Override | ||
public boolean isActivated() { | ||
final Set<String> agentProtocols = Jenkins.getInstance().getAgentProtocols(); | ||
for (String name : agentProtocols) { | ||
AgentProtocol pr = AgentProtocol.of(name); | ||
if (pr != null && pr.isDeprecated()) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant—already present on the whole class. |
||
public String getDeprecatedProtocols() { | ||
String res = getDeprecatedProtocolsString(); | ||
return res != null ? res : "N/A"; | ||
} | ||
|
||
@CheckForNull | ||
public static String getDeprecatedProtocolsString() { | ||
final List<String> deprecatedProtocols = new ArrayList<>(); | ||
final Set<String> agentProtocols = Jenkins.getInstance().getAgentProtocols(); | ||
for (String name : agentProtocols) { | ||
AgentProtocol pr = AgentProtocol.of(name); | ||
if (pr != null && pr.isDeprecated()) { | ||
deprecatedProtocols.add(name); | ||
} | ||
} | ||
if (deprecatedProtocols.isEmpty()) { | ||
return null; | ||
} | ||
return StringUtils.join(deprecatedProtocols, ','); | ||
} | ||
|
||
@Initializer(after = InitMilestone.PLUGINS_STARTED) | ||
@Restricted(NoExternalUse.class) | ||
public static void initializerCheck() { | ||
String protocols = getDeprecatedProtocolsString(); | ||
if(protocols != null) { | ||
LOGGER.log(Level.WARNING, "This Jenkins instance uses deprecated Remoting protocols: {0}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous logging, delete. Presence of an active There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to keep this log as well. It is important if somebody has remote logging system configured |
||
+ "It may impact stability of the instance. " | ||
+ "If newer protocol versions are supported by all system components " | ||
+ "(agents, CLI and other clients), " | ||
+ "it is highly recommended to disable the deprecated protocols.", protocols); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,15 @@ | |
* is generated once and used forever, which makes this whole scheme | ||
* less secure. | ||
* | ||
* <h2>UI Extensions</h2> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you meant to place this Javadoc on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed |
||
* <dl> | ||
* <dt>description.jelly</dt> | ||
* <dd>Optional protocol description</dd> | ||
* <dt>deprecationCause.jelly</dt> | ||
* <dd>Optional. If the protocol is marked as {@link #isDeprecated()}, | ||
* clarifies the deprecation reason and provides extra documentation links</dd> | ||
* </dl> | ||
* | ||
* @author Kohsuke Kawaguchi | ||
* @since 1.467 | ||
*/ | ||
|
@@ -79,6 +88,11 @@ public boolean isOptIn() { | |
return OPT_IN; | ||
} | ||
|
||
@Override | ||
public boolean isDeprecated() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return handler.isEnabled() ? handler.getName() : null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
${%message} | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
message=This protocol is an obsolete protocol, which has been replaced by CLI2-connect. \ | ||
It is also not encrypted. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
${%message} | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
message=Remoting-based CLI is deprecated and not recommended due to the security reasons. \ | ||
It is recommended to disable this protocol on the instance. \ | ||
if you need Remoting CLI on your instance, this protocol has to be enabled. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
<div class="warning"> | ||
${%blurb(it.deprecatedProtocols)} | ||
<a href="${rootURL}/configureSecurity">${%Protocol Configuration}</a> | ||
</div> | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
blurb=This Jenkins instance uses deprecated Remoting protocols: {0}. \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, "agent" would be definitely worse due to CLI. I will rename it |
||
It may impact stability of the instance. \ | ||
If newer protocol versions are supported by all system components (agents, CLI and other clients), \ | ||
it is highly recommended to disable the deprecated protocols. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
${%message} | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
message=This protocol is an obsolete protocol, which has been replaced by JNLP2-connect. \ | ||
It is also not encrypted. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
${%message} | ||
<a href="https://github.com/jenkinsci/remoting/blob/master/docs/protocols.md#jnlp2-connect-errata">${%JNLP2 Protocol Errata}</a> | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
message=This protocol has known stability issues, and it is replaced by JNLP4. \ | ||
It is also not encrypted. \ | ||
See more information in the protocol Errata. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
${%This protocol is unstable. See the protocol documentation for more info.} | ||
<!-- TODO: Move/mirror it to jenkins.io --> | ||
<a href="https://github.com/jenkinsci/remoting/blob/master/docs/protocols.md#jnlp3-connect-errata">${%JNLP3 Protocol Errata}</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not publish a link to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, will setup redirects for the remoting documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oleg-nenashev Just do what has been done before: https://github.com/jenkins-infra/jenkins.io/tree/master/content/redirect Note that these are typically rather specific URLs, often redirecting to more general pages. This is deliberate, as it makes restructuring documentation much easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daniel-beck ack, thanks. I would rather want to implement automatic publishing of Remoting docs to jenkins.io, but AFAIK our infrastructure is not ready to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even then, a redirect URL from Jenkins is the way to go as per @jglick's comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
summary=Extends the version 2 protocol by adding basic encryption but requires a thread per client. \ | ||
This protocol falls back to Java Web Start Agent Protocol/2 (unencrypted) when it can't create a secure connection. \ | ||
This protocol is not recommended. \ | ||
Use Java Web Start Agent Protocol/4 instead. | ||
summary=Extends the version 2 protocol by adding basic encryption but requires a thread per client. |
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.
agentProtocolVersions
? Or simplydeprecatedAgentProtocols
?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.
It is not only about Agents :(