Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
37346150
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37346150
编写于
6月 23, 2020
作者:
W
wanjunlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve conversation
上级
7393ef91
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
86 deletion
+10
-86
pkg/apiserver/auditing/backend.go
pkg/apiserver/auditing/backend.go
+10
-16
pkg/kapis/devops/v1alpha2/devops.go
pkg/kapis/devops/v1alpha2/devops.go
+0
-45
pkg/kapis/iam/v1alpha2/handler.go
pkg/kapis/iam/v1alpha2/handler.go
+0
-25
未找到文件。
pkg/apiserver/auditing/backend.go
浏览文件 @
37346150
...
...
@@ -112,24 +112,18 @@ func (b *Backend) worker() {
func
(
b
*
Backend
)
eventToBytes
(
event
*
v1alpha1
.
EventList
)
([]
byte
,
error
)
{
if
bs
,
err
:=
json
.
Marshal
(
event
);
err
==
nil
{
return
bs
,
nil
}
// Normally, the serialization failure is caused by the failure of RequestObject or ResponseObject serialization.
// To ensure the integrity of the auditing event to the greatest extent,
// it is necessary to delete RequestObject or ResponseObject and and then try to serialize again.
if
event
.
Items
[
0
]
.
RequestObject
!=
nil
{
if
_
,
err
:=
json
.
Marshal
(
event
.
Items
[
0
]
.
RequestObject
);
err
!=
nil
{
event
.
Items
[
0
]
.
RequestObject
=
nil
}
}
if
event
.
Items
[
0
]
.
ResponseObject
!=
nil
{
if
_
,
err
:=
json
.
Marshal
(
event
.
Items
[
0
]
.
ResponseObject
);
err
!=
nil
{
bs
,
err
:=
json
.
Marshal
(
event
)
if
err
!=
nil
{
// Normally, the serialization failure is caused by the failure of ResponseObject serialization.
// To ensure the integrity of the auditing event to the greatest extent,
// it is necessary to delete ResponseObject and and then try to serialize again.
if
event
.
Items
[
0
]
.
ResponseObject
!=
nil
{
event
.
Items
[
0
]
.
ResponseObject
=
nil
return
json
.
Marshal
(
event
)
}
return
nil
,
err
}
return
json
.
Marshal
(
event
)
return
bs
,
err
}
pkg/kapis/devops/v1alpha2/devops.go
浏览文件 @
37346150
...
...
@@ -20,7 +20,6 @@ import (
"github.com/emicklei/go-restful"
log
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/request"
"kubesphere.io/kubesphere/pkg/models/devops"
"net/http"
"strings"
...
...
@@ -93,12 +92,6 @@ func (h *ProjectPipelineHandler) StopPipeline(req *restful.Request, resp *restfu
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
runId
event
.
Verb
=
"stop"
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -114,12 +107,6 @@ func (h *ProjectPipelineHandler) ReplayPipeline(req *restful.Request, resp *rest
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
runId
event
.
Verb
=
"replay"
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -134,11 +121,6 @@ func (h *ProjectPipelineHandler) RunPipeline(req *restful.Request, resp *restful
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
res
.
ID
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -233,11 +215,6 @@ func (h *ProjectPipelineHandler) SubmitInputStep(req *restful.Request, resp *res
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.runs.nodes.step"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
runId
+
"."
+
nodeId
+
"."
+
stepId
}
resp
.
Write
(
res
)
}
...
...
@@ -297,12 +274,6 @@ func (h *ProjectPipelineHandler) StopBranchPipeline(req *restful.Request, resp *
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.branches.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
branchName
+
"."
+
runId
event
.
Verb
=
"stop"
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -319,12 +290,6 @@ func (h *ProjectPipelineHandler) ReplayBranchPipeline(req *restful.Request, resp
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.branches.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
branchName
+
"."
+
runId
event
.
Verb
=
"replay"
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -340,11 +305,6 @@ func (h *ProjectPipelineHandler) RunBranchPipeline(req *restful.Request, resp *r
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.branches.runs"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
branchName
+
"."
+
res
.
ID
}
resp
.
Header
()
.
Set
(
restful
.
HEADER_ContentType
,
restful
.
MIME_JSON
)
resp
.
WriteAsJson
(
res
)
}
...
...
@@ -447,11 +407,6 @@ func (h *ProjectPipelineHandler) SubmitBranchInputStep(req *restful.Request, res
return
}
if
event
:=
request
.
AuditEventFrom
(
req
.
Request
.
Context
());
event
!=
nil
{
event
.
ObjectRef
.
Resource
=
"pipelines.branches.runs.nodes.steps"
event
.
ObjectRef
.
Name
=
pipelineName
+
"."
+
branchName
+
"."
+
runId
+
"."
+
nodeId
+
"."
+
stepId
}
resp
.
Write
(
res
)
}
...
...
pkg/kapis/iam/v1alpha2/handler.go
浏览文件 @
37346150
...
...
@@ -10,7 +10,6 @@ import (
iamv1alpha2
"kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
authoptions
"kubesphere.io/kubesphere/pkg/apiserver/authentication/options"
"kubesphere.io/kubesphere/pkg/apiserver/query"
requestinfo
"kubesphere.io/kubesphere/pkg/apiserver/request"
"kubesphere.io/kubesphere/pkg/models/iam/am"
"kubesphere.io/kubesphere/pkg/models/iam/im"
servererr
"kubesphere.io/kubesphere/pkg/server/errors"
...
...
@@ -822,14 +821,6 @@ func (h *iamHandler) CreateWorkspaceMembers(request *restful.Request, response *
}
}
if
event
:=
requestinfo
.
AuditEventFrom
(
request
.
Request
.
Context
());
event
!=
nil
{
name
:=
""
for
_
,
member
:=
range
members
{
name
+=
member
.
Username
+
", "
}
name
=
strings
.
TrimSuffix
(
name
,
", "
)
event
.
ObjectRef
.
Name
=
name
}
response
.
WriteEntity
(
members
)
}
...
...
@@ -908,14 +899,6 @@ func (h *iamHandler) CreateNamespaceMembers(request *restful.Request, response *
}
}
if
event
:=
requestinfo
.
AuditEventFrom
(
request
.
Request
.
Context
());
event
!=
nil
{
name
:=
""
for
_
,
member
:=
range
members
{
name
+=
member
.
Username
+
", "
}
name
=
strings
.
TrimSuffix
(
name
,
", "
)
event
.
ObjectRef
.
Name
=
name
}
response
.
WriteEntity
(
members
)
}
...
...
@@ -997,14 +980,6 @@ func (h *iamHandler) CreateClusterMembers(request *restful.Request, response *re
}
}
if
event
:=
requestinfo
.
AuditEventFrom
(
request
.
Request
.
Context
());
event
!=
nil
{
name
:=
""
for
_
,
member
:=
range
members
{
name
+=
member
.
Username
+
", "
}
name
=
strings
.
TrimSuffix
(
name
,
", "
)
event
.
ObjectRef
.
Name
=
name
}
response
.
WriteEntity
(
members
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录