mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-25 14:30:28 -05:00
handle event container created in audit service
This commit is contained in:
5
changelog/unreleased/container-created-audit.md
Normal file
5
changelog/unreleased/container-created-audit.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Add audit events for created containers
|
||||
|
||||
Handle the event `ContainerCreated` in the audit service.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/3941
|
||||
@@ -61,6 +61,8 @@ func StartAuditLogger(ctx context.Context, ch <-chan interface{}, log log.Logger
|
||||
auditEvent = types.LinkAccessed(ev)
|
||||
case events.LinkAccessFailed:
|
||||
auditEvent = types.LinkAccessFailed(ev)
|
||||
case events.ContainerCreated:
|
||||
auditEvent = types.ContainerCreated(ev)
|
||||
case events.FileUploaded:
|
||||
auditEvent = types.FileUploaded(ev)
|
||||
case events.FileDownloaded:
|
||||
|
||||
@@ -21,6 +21,7 @@ const (
|
||||
ActionLinkAccessed = "public_link_accessed"
|
||||
|
||||
// Files
|
||||
ActionContainerCreated = "container_create"
|
||||
ActionFileCreated = "file_create"
|
||||
ActionFileRead = "file_read"
|
||||
ActionFileTrashed = "file_delete"
|
||||
@@ -55,7 +56,7 @@ func MessageShareCreated(sharer, item, grantee string) string {
|
||||
|
||||
// MessageLinkCreated returns the human readable string that describes the action
|
||||
func MessageLinkCreated(sharer, item, shareid string) string {
|
||||
return fmt.Sprintf("user '%s' created a public to file '%s' with id '%s'", sharer, item, shareid)
|
||||
return fmt.Sprintf("user '%s' created a public link to file '%s' with id '%s'", sharer, item, shareid)
|
||||
}
|
||||
|
||||
// MessageShareUpdated returns the human readable string that describes the action
|
||||
@@ -93,6 +94,11 @@ func MessageLinkAccessed(linkid string, success bool) string {
|
||||
return fmt.Sprintf("link '%s' was accessed. Success: %v", linkid, success)
|
||||
}
|
||||
|
||||
// MessageContainerCreated returns the human readable string that describes the action
|
||||
func MessageContainerCreated(item string) string {
|
||||
return fmt.Sprintf("Folder '%s' was created", item)
|
||||
}
|
||||
|
||||
// MessageFileCreated returns the human readable string that describes the action
|
||||
func MessageFileCreated(item string) string {
|
||||
return fmt.Sprintf("File '%s' was created", item)
|
||||
|
||||
@@ -232,6 +232,15 @@ func FilesAuditEvent(base AuditEvent, itemid, owner, path string) AuditEventFile
|
||||
}
|
||||
}
|
||||
|
||||
// ContainerCreated converts a ContainerCreated event to an AuditEventContainerCreated
|
||||
func ContainerCreated(ev events.ContainerCreated) AuditEventContainerCreated {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Executant)
|
||||
base := BasicAuditEvent(uid, "", MessageContainerCreated(iid), ActionContainerCreated)
|
||||
return AuditEventContainerCreated{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
}
|
||||
|
||||
// FileUploaded converts a FileUploaded event to an AuditEventFileCreated
|
||||
func FileUploaded(ev events.FileUploaded) AuditEventFileCreated {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
|
||||
@@ -96,6 +96,11 @@ type AuditEventFiles struct {
|
||||
FileID string // The newly created files identifier.
|
||||
}
|
||||
|
||||
// AuditEventContainerCreated is the event logged when a container is created
|
||||
type AuditEventContainerCreated struct {
|
||||
AuditEventFiles
|
||||
}
|
||||
|
||||
// AuditEventFileCreated is the event logged when a file is created
|
||||
type AuditEventFileCreated struct {
|
||||
AuditEventFiles
|
||||
|
||||
Reference in New Issue
Block a user