diff --git a/go.mod b/go.mod index 0a29f3e9..da655061 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.3.0 github.com/hashicorp/go-hclog v1.4.0 - github.com/hashicorp/go-plugin v1.4.6 + github.com/hashicorp/go-plugin v1.4.8 github.com/hashicorp/go-retryablehttp v0.7.1 github.com/jackc/pgx/v5 v5.2.0 github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126 @@ -51,7 +51,7 @@ require ( github.com/rs/cors v1.8.3-0.20220619195839-da52b0701de5 github.com/rs/xid v1.4.0 github.com/rs/zerolog v1.28.0 - github.com/sftpgo/sdk v0.1.3-0.20221205110949-c15308d4236e + github.com/sftpgo/sdk v0.1.3-0.20221208080405-e682ae869318 github.com/shirou/gopsutil/v3 v3.22.11 github.com/spf13/afero v1.9.3 github.com/spf13/cobra v1.6.1 @@ -110,7 +110,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect diff --git a/go.sum b/go.sum index 47446952..e5de8ee8 100644 --- a/go.sum +++ b/go.sum @@ -854,8 +854,8 @@ github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= +github.com/googleapis/enterprise-certificate-proxy v0.2.1 h1:RY7tHKZcRlk788d5WSo/e83gOyyy742E8GSs771ySpg= +github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -923,8 +923,8 @@ github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1: github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= -github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= @@ -1450,8 +1450,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4 h1:PT+ElG/UUFMfqy5HrxJxNzj3QBOf7dZwupeVC+mG1Lo= -github.com/sftpgo/sdk v0.1.3-0.20221205110949-c15308d4236e h1:F3G/BReUSU8TX6Kmk0moQgQAk9Ouiv2I+pg//o1IR6U= -github.com/sftpgo/sdk v0.1.3-0.20221205110949-c15308d4236e/go.mod h1:S2S/Q9fgUpXmL11YoCCt0hyCkEwH1LzQM/6QVsbUCFg= +github.com/sftpgo/sdk v0.1.3-0.20221208080405-e682ae869318 h1:oDr2it5L9nh13+P3BzyIqx89gN9Kfrsdk4cw42HaIuQ= +github.com/sftpgo/sdk v0.1.3-0.20221208080405-e682ae869318/go.mod h1:3GpW3Qy8IHH6kex0ny+Y6ayeYb9OJxz8Pxh3IZgAs2E= github.com/shirou/gopsutil/v3 v3.22.11 h1:kxsPKS+Eeo+VnEQ2XCaGJepeP6KY53QoRTETx3+1ndM= github.com/shirou/gopsutil/v3 v3.22.11/go.mod h1:xl0EeL4vXJ+hQMAGN8B9VFpxukEMA0XdevQOe5MZ1oY= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= diff --git a/internal/httpd/api_events.go b/internal/httpd/api_events.go index 3b0abf78..1a5d091d 100644 --- a/internal/httpd/api_events.go +++ b/internal/httpd/api_events.go @@ -167,9 +167,11 @@ func searchProviderEvents(w http.ResponseWriter, r *http.Request) { return } filters.Role = getRoleFilterForEventSearch(r, claims.Role) + filters.OmitObjectData = getBoolQueryParam(r, "omit_object_data") if getBoolQueryParam(r, "csv_export") { filters.Limit = 100 + filters.OmitObjectData = true if err := exportProviderEvents(w, &filters); err != nil { panic(http.ErrAbortHandler) } @@ -316,7 +318,7 @@ func (e *fsEvent) getCSVData() []string { if e.FileSize > 0 { fileSize = util.ByteCountIEC(e.FileSize) } - return []string{timestamp.Format(time.RFC3339), e.Action, pathInfo.String(), + return []string{timestamp.Format(time.RFC3339Nano), e.Action, pathInfo.String(), fileSize, status, e.Username, e.Protocol, e.IP, e.SSHCmd} } @@ -339,6 +341,6 @@ func (e *providerEvent) getCSVHeader() []string { func (e *providerEvent) getCSVData() []string { timestamp := time.Unix(0, e.Timestamp).UTC() - return []string{timestamp.Format(time.RFC3339), e.Action, e.ObjectType, e.ObjectName, + return []string{timestamp.Format(time.RFC3339Nano), e.Action, e.ObjectType, e.ObjectName, e.Username, e.IP} } diff --git a/internal/httpd/httpd_test.go b/internal/httpd/httpd_test.go index 354fddf7..8880d2a5 100644 --- a/internal/httpd/httpd_test.go +++ b/internal/httpd/httpd_test.go @@ -8869,6 +8869,20 @@ func TestSearchEvents(t *testing.T) { assert.True(t, ok, field) } } + req, err = http.NewRequest(http.MethodGet, providerEventsPath+"?omit_object_data=true", nil) + assert.NoError(t, err) + setBearerForReq(req, token) + rr = executeRequest(req) + checkResponseCode(t, http.StatusOK, rr) + events = make([]map[string]any, 0) + err = json.Unmarshal(rr.Body.Bytes(), &events) + assert.NoError(t, err) + if assert.Len(t, events, 1) { + ev := events[0] + field := "object_data" + _, ok := ev[field] + assert.False(t, ok, field) + } // CSV export req, err = http.NewRequest(http.MethodGet, providerEventsPath+"?csv_export=true", nil) assert.NoError(t, err) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index cbf51415..ca00e041 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -2446,6 +2446,13 @@ paths: default: false required: false description: 'If enabled, events are exported as a CSV file' + - in: query + name: omit_object_data + schema: + type: boolean + default: false + required: false + description: 'If enabled, returned events will not contain the `object_data` field' - in: query name: limit schema: @@ -4729,8 +4736,9 @@ components: type: string enum: - download - - pre-upload - upload + - first-upload + - first-download - delete - rename - mkdir @@ -6299,6 +6307,9 @@ components: $ref: '#/components/schemas/ProviderEventObjectType' object_name: type: string + object_data: + type: byte + description: 'base64 of the JSON serialized object with sensitive fields removed' instance_id: type: string KeyValue: diff --git a/templates/webadmin/events.html b/templates/webadmin/events.html index c5597662..d23e2b94 100644 --- a/templates/webadmin/events.html +++ b/templates/webadmin/events.html @@ -285,7 +285,7 @@ along with this program. If not, see . url+="&statuses="+encodeURIComponent(String(statuses)); } } else { - url = "{{.ProviderEventsSearchURL}}?limit="+limit; + url = "{{.ProviderEventsSearchURL}}?omit_object_data=true&limit="+limit; } let actions = []; $('#idActions').find('option:selected').each(function(){ @@ -542,9 +542,6 @@ along with this program. If not, see . idActions.append($('