mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 04:22:16 +00:00
Updated to reflect the signature change around role checking in remoting
This commit is contained in:
1 parent
f343595b43
commit
201b035cfc
5 files changed
+29
-24
No files matched your search
@@ -67,7 +67,7 @@ import org.apache.tools.ant.types.FileSet;
|
||||
import org.apache.tools.tar.TarEntry;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
import org.jenkinsci.remoting.Role;
|
||||
import org.jenkinsci.remoting.RoleChecker;
|
||||
import org.jenkinsci.remoting.RoleSensitive;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
|
||||
@@ -95,8 +95,6 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
@@ -912,8 +910,8 @@ public final class FilePath implements Serializable {
|
||||
*/
|
||||
public static abstract class MasterToSlaveFileCallable<T> implements FileCallable<T> {
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return Roles.FOR_SLAVE;
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
checker.check(this,Roles.SLAVE);
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -923,8 +921,8 @@ public final class FilePath implements Serializable {
|
||||
*/
|
||||
public static abstract class SlaveToMasterFileCallable<T> implements FileCallable<T> {
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return Roles.FOR_MASTER;
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
checker.check(this,Roles.MASTER);
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -1085,8 +1083,8 @@ public final class FilePath implements Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return task.getRecipients();
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
task.checkRoles(checker);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -2537,8 +2535,8 @@ public final class FilePath implements Serializable {
|
||||
* Role check comes from {@link FileCallable}s.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return callable.getRecipients();
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
callable.checkRoles(checker);
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
|
||||
@@ -48,7 +48,11 @@ public class CallableDirectionChecker extends RoleChecker {
|
||||
*/
|
||||
public static ConcurrentMap<String,Void> BYPASS_CALLABLES = new ConcurrentHashMap<String,Void>();
|
||||
|
||||
/**
|
||||
* Test feature that is meant to replace all logging, and log what would have been violations.
|
||||
*/
|
||||
private static final PrintWriter BYPASS_LOG;
|
||||
|
||||
static {
|
||||
String log = System.getProperty(CallableDirectionChecker.class.getName()+".log");
|
||||
if (log == null) {
|
||||
@@ -65,16 +69,16 @@ public class CallableDirectionChecker extends RoleChecker {
|
||||
private CallableDirectionChecker() {}
|
||||
|
||||
@Override
|
||||
public void check(RoleSensitive subject, @Nonnull Collection<Role> roles) throws SecurityException {
|
||||
if (Roles.FOR_MASTER.containsAll(roles)) {
|
||||
public void check(RoleSensitive subject, @Nonnull Collection<Role> expected) throws SecurityException {
|
||||
final String name = subject.getClass().getName();
|
||||
|
||||
if (expected.contains(Roles.MASTER)) {
|
||||
if (BYPASS_LOG == null) {
|
||||
LOGGER.log(Level.FINE, "Executing {0} is allowed since it is targeted for the master role");
|
||||
LOGGER.log(Level.FINE, "Executing {0} is allowed since it is targeted for the master role", name);
|
||||
}
|
||||
return; // known to be safe
|
||||
}
|
||||
|
||||
final String name = subject.getClass().getName();
|
||||
|
||||
if (BYPASS_LOG != null) {
|
||||
BYPASS_LOG.println(name);
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,7 @@ package jenkins.security;
|
||||
|
||||
import hudson.remoting.Callable;
|
||||
import org.jenkinsci.remoting.Role;
|
||||
import org.jenkinsci.remoting.RoleChecker;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -13,8 +14,8 @@ import java.util.Collection;
|
||||
*/
|
||||
public abstract class MasterToSlaveCallable<V, T extends Throwable> implements Callable<V,T> {
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return Roles.FOR_SLAVE;
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
checker.check(this,Roles.SLAVE);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -2,6 +2,7 @@ package jenkins.security;
|
||||
|
||||
import hudson.remoting.Callable;
|
||||
import org.jenkinsci.remoting.Role;
|
||||
import org.jenkinsci.remoting.RoleChecker;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -13,8 +14,8 @@ import java.util.Collection;
|
||||
*/
|
||||
public abstract class SlaveToMasterCallable<V, T extends Throwable> implements Callable<V,T> {
|
||||
@Override
|
||||
public Collection<Role> getRecipients() {
|
||||
return Roles.FOR_MASTER;
|
||||
public void checkRoles(RoleChecker checker) throws SecurityException {
|
||||
checker.check(this,Roles.MASTER);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Reference in new issue
Block a user