Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create RequestBody struct, implement it using requests, add requestbody into Attribute for auditing #5124

Merged
merged 21 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b98c07b
Revert "CDNC-2088 (#5094) Add attempt-count to task processing logs"
bowenxia Feb 23, 2023
0a1b61f
experiment on adding audit info (has errorsgit status)
bowenxia Feb 24, 2023
1953ffe
Merge branch 'uber:master' into CDNC-2946-Add-Audit-Info
bowenxia Feb 24, 2023
acc3fed
move AuditInfo into Attr
bowenxia Feb 28, 2023
4a05932
implement requestBody Struct, implement it using requests, add it int…
bowenxia Mar 1, 2023
e3289ec
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 1, 2023
f202aa1
change struct name to be ManualRequestBody to avoid conflict
bowenxia Mar 1, 2023
24c792b
change any to interface to solve a compiling error
bowenxia Mar 1, 2023
8939918
rerun make go-generate && make fmt && make lint && make copyright for…
bowenxia Mar 1, 2023
5a0894b
change the PII-filtered request to still be a requset instead of a map
bowenxia Mar 1, 2023
839db23
add a utility function to check if access is manual, add request body…
bowenxia Mar 2, 2023
80df291
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 2, 2023
b7006fd
update with make go-generate && make fmt && make lint && make copyright
bowenxia Mar 2, 2023
e57f774
update comments and naming
bowenxia Mar 2, 2023
2e120ea
change Sprintf to marshal
bowenxia Mar 3, 2023
2e5d4d7
add error handling for json.marshal, pass it to the caller of Seriali…
bowenxia Mar 3, 2023
234e3c6
add a new log tag for actor email address
bowenxia Mar 3, 2023
fcc5429
update interface function error handling
bowenxia Mar 3, 2023
6428a9e
pass in a pointer for serialization instead of a struct
bowenxia Mar 6, 2023
f891ee7
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 6, 2023
263d9b9
delete the isManual checks when creating Attributes
bowenxia Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions common/authorization/authority_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions common/authorization/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type (
WorkflowType *types.WorkflowType
TaskList *types.TaskList
Permission Permission
RequestBody ManualRequestBody
Copy link
Contributor

@demirkayaender demirkayaender Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's call ManualRequestBody as FilteredRequestBody and add a comment next to it saying "request object except for data inputs"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// Result is result from authority.
Expand Down Expand Up @@ -97,3 +98,7 @@ func GetAuthProviderClient(privateKey string) (clientworker.AuthorizationProvide
}
return clientworker.NewAdminJwtAuthorizationProvider(pk), nil
}

type ManualRequestBody interface {
BodyToString() string
}
5 changes: 5 additions & 0 deletions common/log/tag/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ func HandlerCall(handlerCall string) Tag {
return newStringTag("handler-call", handlerCall)
}

// RequestBody returns the tag for the API request body
func RequestBody(requestBody string) Tag {
return newStringTag("request-body", requestBody)
}

// history engine shard

// ShardID returns tag for ShardID
Expand Down
36 changes: 36 additions & 0 deletions common/types/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type AddSearchAttributeRequest struct {
SecurityToken string `json:"securityToken,omitempty"`
}

func (v *AddSearchAttributeRequest) BodyToString() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming here is a bit misleading. It's not really stringifying the struct, it's outputting a string for logging. You probably rename this to something like "SerializeForLogging". Same for the util function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return StructToString(*v)
}

// GetSearchAttribute is an internal getter (TBD...)
func (v *AddSearchAttributeRequest) GetSearchAttribute() (o map[string]IndexedValueType) {
if v != nil && v.SearchAttribute != nil {
Expand All @@ -47,6 +51,10 @@ type AdminDescribeWorkflowExecutionRequest struct {
Execution *WorkflowExecution `json:"execution,omitempty"`
}

func (v *AdminDescribeWorkflowExecutionRequest) BodyToString() string {
return StructToString(*v)
}

// GetDomain is an internal getter (TBD...)
func (v *AdminDescribeWorkflowExecutionRequest) GetDomain() (o string) {
if v != nil {
Expand Down Expand Up @@ -91,6 +99,10 @@ type GetWorkflowExecutionRawHistoryV2Request struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *GetWorkflowExecutionRawHistoryV2Request) BodyToString() string {
return StructToString(*v)
}

// GetDomain is an internal getter (TBD...)
func (v *GetWorkflowExecutionRawHistoryV2Request) GetDomain() (o string) {
if v != nil {
Expand Down Expand Up @@ -206,6 +218,10 @@ type ResendReplicationTasksRequest struct {
EndVersion *int64 `json:"endVersion,omitempty"`
}

func (v *ResendReplicationTasksRequest) BodyToString() string {
return StructToString(*v)
}

// GetWorkflowID is an internal getter (TBD...)
func (v *ResendReplicationTasksRequest) GetWorkflowID() (o string) {
if v != nil {
Expand Down Expand Up @@ -242,6 +258,10 @@ type GetDynamicConfigRequest struct {
Filters []*DynamicConfigFilter `json:"filters,omitempty"`
}

func (v *GetDynamicConfigRequest) BodyToString() string {
return StructToString(*v)
}

type GetDynamicConfigResponse struct {
Value *DataBlob `json:"value,omitempty"`
}
Expand All @@ -251,18 +271,30 @@ type UpdateDynamicConfigRequest struct {
ConfigValues []*DynamicConfigValue `json:"configValues,omitempty"`
}

func (v *UpdateDynamicConfigRequest) BodyToString() string {
return StructToString(*v)
}

type RestoreDynamicConfigRequest struct {
ConfigName string `json:"configName,omitempty"`
Filters []*DynamicConfigFilter `json:"filters,omitempty"`
}

func (v *RestoreDynamicConfigRequest) BodyToString() string {
return StructToString(*v)
}

// AdminDeleteWorkflowRequest is an internal type (TBD...)
type AdminDeleteWorkflowRequest struct {
Domain string `json:"domain,omitempty"`
Execution *WorkflowExecution `json:"execution,omitempty"`
SkipErrors bool `json:"skipErrors,omitempty"`
}

func (v *AdminDeleteWorkflowRequest) BodyToString() string {
return StructToString(*v)
}

func (v *AdminDeleteWorkflowRequest) GetDomain() (o string) {
if v != nil {
return v.Domain
Expand Down Expand Up @@ -298,6 +330,10 @@ type ListDynamicConfigRequest struct {
ConfigName string `json:"configName,omitempty"`
}

func (v *ListDynamicConfigRequest) BodyToString() string {
return StructToString(*v)
}

type ListDynamicConfigResponse struct {
Entries []*DynamicConfigEntry `json:"entries,omitempty"`
}
24 changes: 24 additions & 0 deletions common/types/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ type GetDLQReplicationMessagesRequest struct {
TaskInfos []*ReplicationTaskInfo `json:"taskInfos,omitempty"`
}

func (v *GetDLQReplicationMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetTaskInfos is an internal getter (TBD...)
func (v *GetDLQReplicationMessagesRequest) GetTaskInfos() (o []*ReplicationTaskInfo) {
if v != nil && v.TaskInfos != nil {
Expand All @@ -249,6 +253,10 @@ type GetDomainReplicationMessagesRequest struct {
ClusterName string `json:"clusterName,omitempty"`
}

func (v *GetDomainReplicationMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetLastRetrievedMessageID is an internal getter (TBD...)
func (v *GetDomainReplicationMessagesRequest) GetLastRetrievedMessageID() (o int64) {
if v != nil && v.LastRetrievedMessageID != nil {
Expand Down Expand Up @@ -284,6 +292,10 @@ type GetReplicationMessagesRequest struct {
ClusterName string `json:"clusterName,omitempty"`
}

func (v *GetReplicationMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetClusterName is an internal getter (TBD...)
func (v *GetReplicationMessagesRequest) GetClusterName() (o string) {
if v != nil {
Expand Down Expand Up @@ -393,6 +405,10 @@ type MergeDLQMessagesRequest struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *MergeDLQMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetType is an internal getter (TBD...)
func (v *MergeDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down Expand Up @@ -454,6 +470,10 @@ type PurgeDLQMessagesRequest struct {
InclusiveEndMessageID *int64 `json:"inclusiveEndMessageID,omitempty"`
}

func (v *PurgeDLQMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetType is an internal getter (TBD...)
func (v *PurgeDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down Expand Up @@ -496,6 +516,10 @@ type ReadDLQMessagesRequest struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *ReadDLQMessagesRequest) BodyToString() string {
return StructToString(*v)
}

// GetType is an internal getter (TBD...)
func (v *ReadDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down
Loading