Skip to content
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-70240] fix for non http based UpdateCenter URLs cause exception in plugin manager #7520

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,13 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
return FormValidation.error(Messages.PluginManager_emptyUpdateSiteUrl());
}

//Check to see if the value is a file as some update centers are local json files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will involve a file lookup for something like http://foo.example.com/bar
e.g.
new File("http://foo.example.com/bar").exists()

Rather than check for something that is obviously bogus perhaps first the URI should be created.
Then if it is a file based one do X, if it is http/https do Y (create another URI from the parsed URI appending the query parameter for the version)
if it is anything else return an FormValidation.warning("unable to check validity of update center due to protocol -> the protocol")

value = value.replace("file:/", "");
File file = new File(value);
if (file.isFile()) {
return FormValidation.ok();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the url is file://foo but the file does not exist we keep on trucking as if it is HTTP which is doomed to failure.

value += ((value.contains("?")) ? "&" : "?") + "version=" + Jenkins.VERSION + "&uctest";

URI uri;
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/hudson/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ PluginManager.deprecationWarning=<strong>This plugin is deprecated.</strong> In
PluginManager.insecureUrl=\
You are using an insecure URL to download the plugin, use at your own risk!
PluginManager.invalidUrl=\
You are using an invalid URL to download the plugin, only https and http (not recommended) are supported.
You are using an invalid URL to download the plugin. File paths, https and http (not recommended) URLs are supported. \
If you are using a local update center json file, make sure the file path to your file is correct.

PluginManager.emptyUpdateSiteUrl=\
The update site cannot be empty. Please enter a valid url.
Expand Down