Skip to content

Commit

Permalink
Merge pull request #3919 from dragonchaser/issue-3753-issues-with-audit
Browse files Browse the repository at this point in the history
[WIP] Add missing timestamps to events
  • Loading branch information
dragonchaser authored Jun 5, 2023
2 parents be4a212 + b1e71c0 commit e841425
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/add-missing-timestamps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: We added missing timestamps to events

We added missing timestamps to events

https://github.com/cs3org/reva/pull/3919
https://github.com/owncloud/ocis/issues/3753
14 changes: 14 additions & 0 deletions internal/grpc/interceptors/eventsmiddleware/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func ContainerCreated(r *provider.CreateContainerResponse, req *provider.CreateC
SpaceOwner: spaceOwner,
Executant: executant,
Ref: req.Ref,
Timestamp: utils.TSNow(),
}
}

Expand Down Expand Up @@ -166,6 +167,7 @@ func LinkAccessFailed(r *link.GetPublicShareByTokenResponse, req *link.GetPublic
Executant: executant,
Status: r.Status.Code,
Message: r.Status.Message,
Timestamp: utils.TSNow(),
}
if r.Share != nil {
e.ShareID = r.Share.Id
Expand All @@ -180,6 +182,7 @@ func LinkRemoved(r *link.RemovePublicShareResponse, req *link.RemovePublicShareR
Executant: executant,
ShareID: req.Ref.GetId(),
ShareToken: req.Ref.GetToken(),
Timestamp: utils.TSNow(),
}
}

Expand All @@ -189,6 +192,7 @@ func FileTouched(r *provider.TouchFileResponse, req *provider.TouchFileRequest,
SpaceOwner: spaceOwner,
Executant: executant,
Ref: req.Ref,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -198,6 +202,7 @@ func FileUploaded(r *provider.InitiateFileUploadResponse, req *provider.Initiate
SpaceOwner: spaceOwner,
Executant: executant,
Ref: req.Ref,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -206,6 +211,7 @@ func FileDownloaded(r *provider.InitiateFileDownloadResponse, req *provider.Init
return events.FileDownloaded{
Executant: executant,
Ref: req.Ref,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -221,6 +227,7 @@ func ItemTrashed(r *provider.DeleteResponse, req *provider.DeleteRequest, spaceO
SpaceId: req.Ref.GetResourceId().GetSpaceId(),
OpaqueId: opaqueID,
},
Timestamp: utils.TSNow(),
}
}

Expand All @@ -231,6 +238,7 @@ func ItemMoved(r *provider.MoveResponse, req *provider.MoveRequest, spaceOwner,
Executant: executant,
Ref: req.Destination,
OldReference: req.Source,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -239,6 +247,7 @@ func ItemPurged(r *provider.PurgeRecycleResponse, req *provider.PurgeRecycleRequ
return events.ItemPurged{
Executant: executant,
Ref: req.Ref,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -254,6 +263,7 @@ func ItemRestored(r *provider.RestoreRecycleItemResponse, req *provider.RestoreR
Ref: ref,
OldReference: req.Ref,
Key: req.Key,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -264,6 +274,7 @@ func FileVersionRestored(r *provider.RestoreFileVersionResponse, req *provider.R
Executant: executant,
Ref: req.Ref,
Key: req.Key,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -288,6 +299,7 @@ func SpaceRenamed(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt
ID: r.StorageSpace.Id,
Owner: extractOwner(r.StorageSpace.Owner),
Name: r.StorageSpace.Name,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -297,6 +309,7 @@ func SpaceUpdated(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt
Executant: executant,
ID: r.StorageSpace.Id,
Space: r.StorageSpace,
Timestamp: utils.TSNow(),
}
}

Expand All @@ -306,6 +319,7 @@ func SpaceEnabled(r *provider.UpdateStorageSpaceResponse, req *provider.UpdateSt
Executant: executant,
ID: r.StorageSpace.Id,
Owner: extractOwner(r.StorageSpace.Owner),
Timestamp: utils.TSNow(),
}
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/events/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
)

// ContainerCreated is emitted when a directory has been created
Expand All @@ -31,6 +32,7 @@ type ContainerCreated struct {
Executant *user.UserId
Ref *provider.Reference
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -46,6 +48,7 @@ type FileUploaded struct {
Executant *user.UserId
Ref *provider.Reference
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -60,6 +63,7 @@ type FileTouched struct {
SpaceOwner *user.UserId
Executant *user.UserId
Ref *provider.Reference
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -74,6 +78,7 @@ type FileDownloaded struct {
Executant *user.UserId
Ref *provider.Reference
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -90,6 +95,7 @@ type ItemTrashed struct {
ID *provider.ResourceId
Ref *provider.Reference
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -106,6 +112,7 @@ type ItemMoved struct {
Ref *provider.Reference
Owner *user.UserId
OldReference *provider.Reference
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -121,6 +128,7 @@ type ItemPurged struct {
ID *provider.ResourceId
Ref *provider.Reference
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -139,6 +147,7 @@ type ItemRestored struct {
Owner *user.UserId
OldReference *provider.Reference
Key string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -155,6 +164,7 @@ type FileVersionRestored struct {
Ref *provider.Reference
Owner *user.UserId
Key string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down
11 changes: 9 additions & 2 deletions pkg/events/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import (
"encoding/json"

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
)

// GroupCreated is emitted when a group was created
type GroupCreated struct {
Executant *user.UserId
GroupID string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -41,6 +43,7 @@ func (GroupCreated) Unmarshal(v []byte) (interface{}, error) {
type GroupDeleted struct {
Executant *user.UserId
GroupID string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -55,6 +58,7 @@ type GroupMemberAdded struct {
Executant *user.UserId
GroupID string
UserID string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -69,6 +73,7 @@ type GroupMemberRemoved struct {
Executant *user.UserId
GroupID string
UserID string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -80,15 +85,17 @@ func (GroupMemberRemoved) Unmarshal(v []byte) (interface{}, error) {

// GroupFeature represents a group feature
type GroupFeature struct {
Name string
Value string
Name string
Value string
Timestamp *types.Timestamp
}

// GroupFeatureChanged is emitted when a group feature was changed
type GroupFeatureChanged struct {
Executant *user.UserId
GroupID string
Features []GroupFeature
Timestamp *types.Timestamp
}

// Unmarshal to fulfill unmarshaller interface
Expand Down
8 changes: 7 additions & 1 deletion pkg/events/postprocessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
)

type (
Expand Down Expand Up @@ -59,6 +60,7 @@ type BytesReceived struct {
Filename string
Filesize uint64
URL string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -80,6 +82,7 @@ type StartPostprocessingStep struct {
RevaToken string // for file retrieval in after upload case

StepToStart Postprocessingstep
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -99,6 +102,7 @@ type PostprocessingStepFinished struct {
Result interface{} // result information see VirusscanResult for example
Error error // possible error of the step
Outcome PostprocessingOutcome // some services may cause postprocessing to stop
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down Expand Up @@ -128,6 +132,7 @@ type VirusscanResult struct {
Scandate time.Time
ResourceID *provider.ResourceId
ErrorMsg string // empty when no error
Timestamp *types.Timestamp
}

// PostprocessingFinished is emitted by *some* service which can decide that
Expand All @@ -138,6 +143,7 @@ type PostprocessingFinished struct {
ExecutingUser *user.User
Result map[Postprocessingstep]interface{} // it is a map[step]Event
Outcome PostprocessingOutcome
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -155,7 +161,7 @@ type UploadReady struct {
ExecutingUser *user.User
FileRef *provider.Reference
Failed bool
Timestamp time.Time
Timestamp *types.Timestamp
// add reference here? We could use it to inform client pp is finished
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/events/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ type LinkAccessFailed struct {
Token string
Status rpc.Code
Message string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -221,6 +222,7 @@ type LinkRemoved struct {
// split protobuf Ref
ShareID *link.PublicShareId
ShareToken string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down
4 changes: 4 additions & 0 deletions pkg/events/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type SpaceRenamed struct {
ID *provider.StorageSpaceId
Owner *user.UserId
Name string
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down Expand Up @@ -81,6 +82,7 @@ type SpaceEnabled struct {
Executant *user.UserId
ID *provider.StorageSpaceId
Owner *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down Expand Up @@ -144,6 +146,7 @@ type SpaceUpdated struct {
Executant *user.UserId
ID *provider.StorageSpaceId
Space *provider.StorageSpace
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -162,6 +165,7 @@ type SpaceMembershipExpired struct {
// split the protobuf Grantee oneof so we can use stdlib encoding/json
GranteeUserID *user.UserId
GranteeGroupID *group.GroupId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down
3 changes: 3 additions & 0 deletions pkg/events/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
)

// TagsAdded is emitted when a Tag has been added
Expand All @@ -31,6 +32,7 @@ type TagsAdded struct {
Tags string
Ref *provider.Reference
Executant *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand All @@ -46,6 +48,7 @@ type TagsRemoved struct {
Tags string
Ref *provider.Reference
Executant *user.UserId
Timestamp *types.Timestamp
}

// Unmarshal to fulfill umarshaller interface
Expand Down
Loading

0 comments on commit e841425

Please sign in to comment.