Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
23729777
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
23729777
编写于
4月 28, 2016
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #70 from jenkinsci-cert/SECURITY-281
[SECURITY-281] Forbid /computer/(master)/config.xml
上级
53dd9046
bfad4c96
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
2 deletion
+58
-2
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+7
-0
test/src/test/java/hudson/cli/GetNodeCommandTest.java
test/src/test/java/hudson/cli/GetNodeCommandTest.java
+15
-2
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
+15
-0
test/src/test/java/hudson/model/NodeTest.java
test/src/test/java/hudson/model/NodeTest.java
+21
-0
未找到文件。
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
23729777
...
...
@@ -298,6 +298,7 @@ import static hudson.init.InitMilestone.*;
import
hudson.util.LogTaskListener
;
import
static
java
.
util
.
logging
.
Level
.*;
import
static
javax
.
servlet
.
http
.
HttpServletResponse
.*;
import
org.kohsuke.stapler.WebMethod
;
/**
* Root object of the system.
...
...
@@ -3996,6 +3997,12 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
Jenkins
.
getInstance
().
doConfigExecutorsSubmit
(
req
,
rsp
);
}
@WebMethod
(
name
=
"config.xml"
)
@Override
public
void
doConfigDotXml
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
throw
HttpResponses
.
status
(
SC_BAD_REQUEST
);
}
@Override
public
boolean
hasPermission
(
Permission
permission
)
{
// no one should be allowed to delete the master.
...
...
test/src/test/java/hudson/cli/GetNodeCommandTest.java
浏览文件 @
23729777
...
...
@@ -30,15 +30,14 @@ import static hudson.cli.CLICommandInvoker.Matcher.hasNoErrorOutput;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
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
.
hamcrest
.
text
.
IsEmptyString
.
isEmptyString
;
import
hudson.model.Computer
;
import
jenkins.model.Jenkins
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.JenkinsRule
;
public
class
GetNodeCommandTest
{
...
...
@@ -92,4 +91,18 @@ public class GetNodeCommandTest {
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
}
@Issue
(
"SECURITY-281"
)
@Test
public
void
getNodeShouldFailForMaster
()
throws
Exception
{
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
EXTENDED_READ
,
Jenkins
.
READ
).
invokeWithArgs
(
""
);
assertThat
(
result
.
stderr
(),
containsString
(
"No such node ''"
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
result
=
command
.
authorizedTo
(
Computer
.
EXTENDED_READ
,
Jenkins
.
READ
).
invokeWithArgs
(
"(master)"
);
assertThat
(
result
.
stderr
(),
containsString
(
"No such node '(master)'"
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
}
}
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
浏览文件 @
23729777
...
...
@@ -38,6 +38,7 @@ import jenkins.model.Jenkins;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.JenkinsRule
;
public
class
UpdateNodeCommandTest
{
...
...
@@ -96,4 +97,18 @@ public class UpdateNodeCommandTest {
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
}
@Issue
(
"SECURITY-281"
)
@Test
public
void
updateNodeShouldFailForMaster
()
throws
Exception
{
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
CONFIGURE
,
Jenkins
.
READ
).
withStdin
(
Computer
.
class
.
getResourceAsStream
(
"node.xml"
)).
invokeWithArgs
(
""
);
assertThat
(
result
.
stderr
(),
containsString
(
"No such node ''"
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
result
=
command
.
authorizedTo
(
Computer
.
EXTENDED_READ
,
Jenkins
.
READ
).
withStdin
(
Computer
.
class
.
getResourceAsStream
(
"node.xml"
)).
invokeWithArgs
(
"(master)"
);
assertThat
(
result
.
stderr
(),
containsString
(
"No such node '(master)'"
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
}
}
test/src/test/java/hudson/model/NodeTest.java
浏览文件 @
23729777
...
...
@@ -23,6 +23,10 @@
*/
package
hudson.model
;
import
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
;
import
com.gargoylesoftware.htmlunit.HttpMethod
;
import
com.gargoylesoftware.htmlunit.Page
;
import
com.gargoylesoftware.htmlunit.WebRequestSettings
;
import
hudson.EnvVars
;
import
hudson.FilePath
;
import
hudson.maven.MavenModuleSet
;
...
...
@@ -41,6 +45,7 @@ import hudson.slaves.OfflineCause;
import
hudson.slaves.OfflineCause.ByCLI
;
import
hudson.slaves.OfflineCause.UserCause
;
import
hudson.util.TagCloud
;
import
java.net.HttpURLConnection
;
import
java.util.*
;
import
java.util.concurrent.Callable
;
...
...
@@ -400,6 +405,22 @@ public class NodeTest {
assertThatCloudLabelDoesNotContain
(
cloud
,
"label1 label2"
,
0
);
}
@Issue
(
"SECURITY-281"
)
@Test
public
void
masterComputerConfigDotXml
()
throws
Exception
{
JenkinsRule
.
WebClient
wc
=
j
.
createWebClient
();
wc
.
assertFails
(
"computer/(master)/config.xml"
,
HttpURLConnection
.
HTTP_BAD_REQUEST
);
WebRequestSettings
settings
=
new
WebRequestSettings
(
wc
.
createCrumbedUrl
(
"computer/(master)/config.xml"
));
settings
.
setHttpMethod
(
HttpMethod
.
POST
);
settings
.
setRequestBody
(
"<hudson/>"
);
try
{
Page
page
=
wc
.
getPage
(
settings
);
fail
(
page
.
getWebResponse
().
getContentAsString
());
}
catch
(
FailingHttpStatusCodeException
x
)
{
assertEquals
(
HttpURLConnection
.
HTTP_BAD_REQUEST
,
x
.
getStatusCode
());
}
}
/**
* Assert that a tag cloud contains label name and weight.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录