Skip to content

Commit

Permalink
fix: Stapler: Missing permission check (#346)
Browse files Browse the repository at this point in the history
* fix: Stapler: Missing permission check

* fix: doIndex does not require POST
  • Loading branch information
kuisathaverat authored Oct 23, 2022
1 parent fac0f72 commit 7fd446b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/sshslaves/SSHLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@ public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,

@RequirePOST
public FormValidation doCheckPort(@QueryParameter String value) {
Jenkins.get().checkPermission(Computer.CONFIGURE);
if (StringUtils.isEmpty(value)) {
return FormValidation.error(Messages.SSHLauncher_PortNotSpecified());
}
Expand All @@ -1315,6 +1316,7 @@ public FormValidation doCheckPort(@QueryParameter String value) {

@RequirePOST
public FormValidation doCheckHost(@QueryParameter String value) {
Jenkins.get().checkPermission(Computer.CONFIGURE);
FormValidation ret = FormValidation.ok();
if (StringUtils.isEmpty(value)) {
return FormValidation.error(Messages.SSHLauncher_HostNotSpecified());
Expand All @@ -1324,6 +1326,7 @@ public FormValidation doCheckHost(@QueryParameter String value) {

@RequirePOST
public FormValidation doCheckJavaPath(@QueryParameter String value) {
Jenkins.get().checkPermission(Computer.CONFIGURE);
FormValidation ret = FormValidation.ok();
if (value != null && value.contains(" ")
&& !(value.startsWith("\"") && value.endsWith("\""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@

import edu.umd.cs.findbugs.annotations.NonNull;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.QueryParameter;

import hudson.Extension;
import hudson.model.Computer;
import hudson.model.TaskListener;
import hudson.plugins.sshslaves.Messages;
import hudson.plugins.sshslaves.SSHLauncher;
import hudson.slaves.SlaveComputer;
import hudson.util.FormValidation;
import java.util.Collections;
import jenkins.model.Jenkins;

/**
* Checks a key provided by a remote hosts matches a key specified as being required by the
Expand Down Expand Up @@ -116,7 +119,9 @@ public String getDisplayName() {
return Messages.ManualKeyProvidedHostKeyVerifier_DisplayName();
}

@RequirePOST
public FormValidation doCheckKey(@QueryParameter String key) {
Jenkins.get().checkPermission(Computer.CONFIGURE);
try {
ManuallyProvidedKeyVerificationStrategy.parseKey(key);
return FormValidation.ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ public String getUrlName() {
}
return actionPath;
}
}
}

0 comments on commit 7fd446b

Please sign in to comment.