Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
cd99f787
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cd99f787
编写于
11月 13, 2020
作者:
H
hongming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix container terminal security risk
Signed-off-by:
N
hongming
<
talonwan@yunify.com
>
上级
1cb1eb4f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
27 addition
and
14 deletion
+27
-14
pkg/apiserver/apiserver.go
pkg/apiserver/apiserver.go
+5
-2
pkg/kapis/tenant/v1alpha2/handler.go
pkg/kapis/tenant/v1alpha2/handler.go
+6
-2
pkg/kapis/tenant/v1alpha2/register.go
pkg/kapis/tenant/v1alpha2/register.go
+6
-2
pkg/kapis/terminal/v1alpha2/register.go
pkg/kapis/terminal/v1alpha2/register.go
+1
-1
pkg/models/tenant/tenant.go
pkg/models/tenant/tenant.go
+2
-5
pkg/models/tenant/tenent_test.go
pkg/models/tenant/tenent_test.go
+6
-1
tools/cmd/doc-gen/main.go
tools/cmd/doc-gen/main.go
+1
-1
未找到文件。
pkg/apiserver/apiserver.go
浏览文件 @
cd99f787
...
...
@@ -166,6 +166,10 @@ func (s *APIServer) PrepareRun(stopCh <-chan struct{}) error {
// Installation happens before all informers start to cache objects, so
// any attempt to list objects using listers will get empty results.
func
(
s
*
APIServer
)
installKubeSphereAPIs
()
{
imOperator
:=
im
.
NewOperator
(
s
.
KubernetesClient
.
KubeSphere
(),
s
.
InformerFactory
,
s
.
Config
.
AuthenticationOptions
)
amOperator
:=
am
.
NewOperator
(
s
.
InformerFactory
,
s
.
KubernetesClient
.
KubeSphere
(),
s
.
KubernetesClient
.
Kubernetes
())
rbacAuthorizer
:=
authorizerfactory
.
NewRBACAuthorizer
(
amOperator
)
urlruntime
.
Must
(
configv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
Config
))
urlruntime
.
Must
(
resourcev1alpha3
.
AddToContainer
(
s
.
container
,
s
.
InformerFactory
))
urlruntime
.
Must
(
monitoringv1alpha3
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
MonitoringClient
,
s
.
InformerFactory
,
s
.
OpenpitrixClient
))
...
...
@@ -174,7 +178,7 @@ func (s *APIServer) installKubeSphereAPIs() {
urlruntime
.
Must
(
resourcesv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
InformerFactory
,
s
.
KubernetesClient
.
Master
()))
urlruntime
.
Must
(
tenantv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
InformerFactory
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
KubernetesClient
.
KubeSphere
(),
s
.
EventsClient
,
s
.
LoggingClient
,
s
.
AuditingClient
))
s
.
KubernetesClient
.
KubeSphere
(),
s
.
EventsClient
,
s
.
LoggingClient
,
s
.
AuditingClient
,
amOperator
,
rbacAuthorizer
))
urlruntime
.
Must
(
terminalv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
KubernetesClient
.
Config
()))
urlruntime
.
Must
(
clusterkapisv1alpha1
.
AddToContainer
(
s
.
container
,
s
.
InformerFactory
.
KubernetesSharedInformerFactory
(),
...
...
@@ -182,7 +186,6 @@ func (s *APIServer) installKubeSphereAPIs() {
s
.
Config
.
MultiClusterOptions
.
ProxyPublishService
,
s
.
Config
.
MultiClusterOptions
.
ProxyPublishAddress
,
s
.
Config
.
MultiClusterOptions
.
AgentImage
))
imOperator
:=
im
.
NewOperator
(
s
.
KubernetesClient
.
KubeSphere
(),
s
.
InformerFactory
,
s
.
Config
.
AuthenticationOptions
)
urlruntime
.
Must
(
iamapi
.
AddToContainer
(
s
.
container
,
imOperator
,
am
.
NewOperator
(
s
.
InformerFactory
,
s
.
KubernetesClient
.
KubeSphere
(),
s
.
KubernetesClient
.
Kubernetes
()),
group
.
New
(
s
.
InformerFactory
,
s
.
KubernetesClient
.
KubeSphere
(),
s
.
KubernetesClient
.
Kubernetes
()),
...
...
pkg/kapis/tenant/v1alpha2/handler.go
浏览文件 @
cd99f787
...
...
@@ -30,10 +30,12 @@ import (
eventsv1alpha1
"kubesphere.io/kubesphere/pkg/api/events/v1alpha1"
loggingv1alpha2
"kubesphere.io/kubesphere/pkg/api/logging/v1alpha2"
tenantv1alpha2
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/request"
kubesphere
"kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/iam/am"
"kubesphere.io/kubesphere/pkg/models/tenant"
servererr
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client/auditing"
...
...
@@ -45,10 +47,12 @@ type tenantHandler struct {
tenant
tenant
.
Interface
}
func
newTenantHandler
(
factory
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
events
.
Client
,
loggingClient
logging
.
Interface
,
auditingclient
auditing
.
Client
)
*
tenantHandler
{
func
newTenantHandler
(
factory
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
events
.
Client
,
loggingClient
logging
.
Interface
,
auditingclient
auditing
.
Client
,
am
am
.
AccessManagementInterface
,
authorizer
authorizer
.
Authorizer
)
*
tenantHandler
{
return
&
tenantHandler
{
tenant
:
tenant
.
New
(
factory
,
k8sclient
,
ksclient
,
evtsClient
,
loggingClient
,
auditingclient
),
tenant
:
tenant
.
New
(
factory
,
k8sclient
,
ksclient
,
evtsClient
,
loggingClient
,
auditingclient
,
am
,
authorizer
),
}
}
...
...
pkg/kapis/tenant/v1alpha2/register.go
浏览文件 @
cd99f787
...
...
@@ -27,11 +27,13 @@ import (
eventsv1alpha1
"kubesphere.io/kubesphere/pkg/api/events/v1alpha1"
loggingv1alpha2
"kubesphere.io/kubesphere/pkg/api/logging/v1alpha2"
tenantv1alpha2
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
kubesphere
"kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/iam/am"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client/auditing"
"kubesphere.io/kubesphere/pkg/simple/client/events"
...
...
@@ -49,11 +51,13 @@ func Resource(resource string) schema.GroupResource {
return
GroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
func
AddToContainer
(
c
*
restful
.
Container
,
factory
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
events
.
Client
,
loggingClient
logging
.
Interface
,
auditingclient
auditing
.
Client
)
error
{
func
AddToContainer
(
c
*
restful
.
Container
,
factory
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
events
.
Client
,
loggingClient
logging
.
Interface
,
auditingclient
auditing
.
Client
,
am
am
.
AccessManagementInterface
,
authorizer
authorizer
.
Authorizer
)
error
{
mimePatch
:=
[]
string
{
restful
.
MIME_JSON
,
runtime
.
MimeMergePatchJson
,
runtime
.
MimeJsonPatchJson
}
ws
:=
runtime
.
NewWebService
(
GroupVersion
)
handler
:=
newTenantHandler
(
factory
,
k8sclient
,
ksclient
,
evtsClient
,
loggingClient
,
auditingclient
)
handler
:=
newTenantHandler
(
factory
,
k8sclient
,
ksclient
,
evtsClient
,
loggingClient
,
auditingclient
,
am
,
authorizer
)
ws
.
Route
(
ws
.
GET
(
"/clusters"
)
.
To
(
handler
.
ListClusters
)
.
...
...
pkg/kapis/terminal/v1alpha2/register.go
浏览文件 @
cd99f787
...
...
@@ -39,7 +39,7 @@ func AddToContainer(c *restful.Container, client kubernetes.Interface, config *r
handler
:=
newTerminalHandler
(
client
,
config
)
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod}
/exec
"
)
.
To
(
handler
.
handleTerminalSession
)
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"namespace of which the pod located in"
))
.
Param
(
webservice
.
PathParameter
(
"pod"
,
"name of the pod"
))
.
...
...
pkg/models/tenant/tenant.go
浏览文件 @
cd99f787
...
...
@@ -41,7 +41,6 @@ import (
tenantv1alpha2
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
typesv1beta1
"kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizerfactory"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/request"
kubesphere
"kubesphere.io/kubesphere/pkg/client/clientset/versioned"
...
...
@@ -92,11 +91,9 @@ type tenantOperator struct {
auditing
auditing
.
Interface
}
func
New
(
informers
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
eventsclient
.
Client
,
loggingClient
loggingclient
.
Interface
,
auditingclient
auditingclient
.
Client
)
Interface
{
amOperator
:=
am
.
NewReadOnlyOperator
(
informers
)
authorizer
:=
authorizerfactory
.
NewRBACAuthorizer
(
amOperator
)
func
New
(
informers
informers
.
InformerFactory
,
k8sclient
kubernetes
.
Interface
,
ksclient
kubesphere
.
Interface
,
evtsClient
eventsclient
.
Client
,
loggingClient
loggingclient
.
Interface
,
auditingclient
auditingclient
.
Client
,
am
am
.
AccessManagementInterface
,
authorizer
authorizer
.
Authorizer
)
Interface
{
return
&
tenantOperator
{
am
:
am
Operator
,
am
:
am
,
authorizer
:
authorizer
,
resourceGetter
:
resourcesv1alpha3
.
NewResourceGetter
(
informers
),
k8sclient
:
k8sclient
,
...
...
pkg/models/tenant/tenent_test.go
浏览文件 @
cd99f787
...
...
@@ -30,9 +30,11 @@ import (
iamv1alpha2
"kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
tenantv1alpha1
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
tenantv1alpha2
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizerfactory"
"kubesphere.io/kubesphere/pkg/apiserver/query"
fakeks
"kubesphere.io/kubesphere/pkg/client/clientset/versioned/fake"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/iam/am"
"reflect"
fakeapp
"sigs.k8s.io/application/pkg/client/clientset/versioned/fake"
"testing"
...
...
@@ -538,5 +540,8 @@ func prepare() Interface {
RoleBindings
()
.
Informer
()
.
GetIndexer
()
.
Add
(
roleBinding
)
}
return
New
(
fakeInformerFactory
,
k8sClient
,
ksClient
,
nil
,
nil
,
nil
)
amOperator
:=
am
.
NewOperator
(
fakeInformerFactory
,
ksClient
,
k8sClient
)
authorizer
:=
authorizerfactory
.
NewRBACAuthorizer
(
amOperator
)
return
New
(
fakeInformerFactory
,
k8sClient
,
ksClient
,
nil
,
nil
,
nil
,
amOperator
,
authorizer
)
}
tools/cmd/doc-gen/main.go
浏览文件 @
cd99f787
...
...
@@ -127,7 +127,7 @@ func generateSwaggerJson() []byte {
urlruntime
.
Must
(
operationsv1alpha2
.
AddToContainer
(
container
,
clientsets
.
Kubernetes
()))
urlruntime
.
Must
(
resourcesv1alpha2
.
AddToContainer
(
container
,
clientsets
.
Kubernetes
(),
informerFactory
,
""
))
urlruntime
.
Must
(
resourcesv1alpha3
.
AddToContainer
(
container
,
informerFactory
))
urlruntime
.
Must
(
tenantv1alpha2
.
AddToContainer
(
container
,
informerFactory
,
nil
,
nil
,
nil
,
nil
,
nil
))
urlruntime
.
Must
(
tenantv1alpha2
.
AddToContainer
(
container
,
informerFactory
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
,
nil
))
urlruntime
.
Must
(
terminalv1alpha2
.
AddToContainer
(
container
,
clientsets
.
Kubernetes
(),
nil
))
urlruntime
.
Must
(
metricsv1alpha2
.
AddToContainer
(
container
))
urlruntime
.
Must
(
networkv1alpha2
.
AddToContainer
(
container
,
""
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录