Skip to content

Commit 7fd446b

Browse files
fix: Stapler: Missing permission check (#346)
* fix: Stapler: Missing permission check * fix: doIndex does not require POST
1 parent fac0f72 commit 7fd446b

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/main/java/hudson/plugins/sshslaves/SSHLauncher.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,7 @@ public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
12961296

12971297
@RequirePOST
12981298
public FormValidation doCheckPort(@QueryParameter String value) {
1299+
Jenkins.get().checkPermission(Computer.CONFIGURE);
12991300
if (StringUtils.isEmpty(value)) {
13001301
return FormValidation.error(Messages.SSHLauncher_PortNotSpecified());
13011302
}
@@ -1315,6 +1316,7 @@ public FormValidation doCheckPort(@QueryParameter String value) {
13151316

13161317
@RequirePOST
13171318
public FormValidation doCheckHost(@QueryParameter String value) {
1319+
Jenkins.get().checkPermission(Computer.CONFIGURE);
13181320
FormValidation ret = FormValidation.ok();
13191321
if (StringUtils.isEmpty(value)) {
13201322
return FormValidation.error(Messages.SSHLauncher_HostNotSpecified());
@@ -1324,6 +1326,7 @@ public FormValidation doCheckHost(@QueryParameter String value) {
13241326

13251327
@RequirePOST
13261328
public FormValidation doCheckJavaPath(@QueryParameter String value) {
1329+
Jenkins.get().checkPermission(Computer.CONFIGURE);
13271330
FormValidation ret = FormValidation.ok();
13281331
if (value != null && value.contains(" ")
13291332
&& !(value.startsWith("\"") && value.endsWith("\""))

src/main/java/hudson/plugins/sshslaves/verifiers/ManuallyProvidedKeyVerificationStrategy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@
3232

3333
import edu.umd.cs.findbugs.annotations.NonNull;
3434
import org.kohsuke.stapler.DataBoundConstructor;
35+
import org.kohsuke.stapler.interceptor.RequirePOST;
3536
import org.kohsuke.stapler.QueryParameter;
3637

3738
import hudson.Extension;
39+
import hudson.model.Computer;
3840
import hudson.model.TaskListener;
3941
import hudson.plugins.sshslaves.Messages;
4042
import hudson.plugins.sshslaves.SSHLauncher;
4143
import hudson.slaves.SlaveComputer;
4244
import hudson.util.FormValidation;
4345
import java.util.Collections;
46+
import jenkins.model.Jenkins;
4447

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

122+
@RequirePOST
119123
public FormValidation doCheckKey(@QueryParameter String key) {
124+
Jenkins.get().checkPermission(Computer.CONFIGURE);
120125
try {
121126
ManuallyProvidedKeyVerificationStrategy.parseKey(key);
122127
return FormValidation.ok();

src/main/java/hudson/plugins/sshslaves/verifiers/TrustHostKeyAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ public String getUrlName() {
131131
}
132132
return actionPath;
133133
}
134-
}
134+
}

0 commit comments

Comments
 (0)