mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 13:32:24 +00:00
Merge pull request #82 from jenkinsci-cert/security-343
[SECURITY-343] Restrict API access to NodeMonitor data
This commit is contained in:
commit
0f92cd08a1
2 files changed
+27
-2
No files matched your search
@@ -1072,8 +1072,10 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
@Exported(inline=true)
|
||||
public Map<String/*monitor name*/,Object> getMonitorData() {
|
||||
Map<String,Object> r = new HashMap<String, Object>();
|
||||
for (NodeMonitor monitor : NodeMonitor.getAll())
|
||||
r.put(monitor.getClass().getName(),monitor.data(this));
|
||||
if (hasPermission(CONNECT)) {
|
||||
for (NodeMonitor monitor : NodeMonitor.getAll())
|
||||
r.put(monitor.getClass().getName(), monitor.data(this));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import hudson.security.ACL;
|
||||
@@ -47,6 +49,7 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
import org.jvnet.hudson.test.JenkinsRule;
|
||||
import org.jvnet.hudson.test.JenkinsRule.DummySecurityRealm;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
@@ -140,6 +143,26 @@ public class ComputerConfigDotXmlTest {
|
||||
assertThat(updatedSlave.getNumExecutors(), equalTo(42));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Issue("SECURITY-343")
|
||||
public void emptyNodeMonitorDataWithoutConnect() throws Exception {
|
||||
rule.jenkins.setAuthorizationStrategy(new GlobalMatrixAuthorizationStrategy());
|
||||
|
||||
assertTrue(computer.getMonitorData().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Issue("SECURITY-343")
|
||||
public void populatedNodeMonitorDataWithConnect() throws Exception {
|
||||
GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy();
|
||||
rule.jenkins.setAuthorizationStrategy(auth);
|
||||
auth.add(Computer.CONNECT, "user");
|
||||
|
||||
assertFalse(computer.getMonitorData().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private OutputStream captureOutput() throws IOException {
|
||||
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
Reference in new issue
Block a user