Skip to content

Commit

Permalink
Merge pull request #58 from jenkinsci/SECURITY-2290-2
Browse files Browse the repository at this point in the history
[SECURITY-2290] check permission as well
  • Loading branch information
gmcdonald authored Feb 21, 2022
2 parents 94dcabc + 1dc2f26 commit a49b27d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public FormValidation doCheckKeyPath(@QueryParameter final String value) {
public FormValidation doTestConnection(@QueryParameter final String configName, @QueryParameter final String username,
@QueryParameter final String encryptedPassphrase, @QueryParameter final String key,
@QueryParameter final String keyPath) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
final BapSshCredentials credentials = new BapSshCredentials(username, encryptedPassphrase, key, keyPath);
final BPBuildInfo buildInfo = BapSshPublisherPluginDescriptor.createDummyBuildInfo();
buildInfo.put(BPBuildInfo.OVERRIDE_CREDENTIALS_CONTEXT_KEY, credentials);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ public FormValidation doCheckTimeout(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}

@RequirePOST
public FormValidation doCheckKeyPath(@QueryParameter final String value) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
return BPValidators.validateFileOnMaster(value);
}

@RequirePOST
public FormValidation doTestConnection(final StaplerRequest request, final StaplerResponse response) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);

final BapSshPublisherPlugin.Descriptor pluginDescriptor;
Jenkins j = Jenkins.getInstanceOrNull();
if(j != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public jenkins.plugins.publish_over.view_defaults.manage_jenkins.Messages getCom

@RequirePOST
public FormValidation doTestConnection(final StaplerRequest request, final StaplerResponse response) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
final BapSshHostConfiguration hostConfig = request.bindParameters(BapSshHostConfiguration.class, "");
hostConfig.setCommonConfig(request.bindParameters(BapSshCommonConfiguration.class, "common."));
return validateConnection(hostConfig, createDummyBuildInfo());
Expand Down

1 comment on commit a49b27d

@knowyi
Copy link

@knowyi knowyi commented on a49b27d Feb 23, 2022

Choose a reason for hiding this comment

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

@gmcdonald Hello,Jenkins is currently suspending publish over SSH. When will it resume

Please sign in to comment.