diff --git a/go.mod b/go.mod index b4160118..03a92dc1 100644 --- a/go.mod +++ b/go.mod @@ -159,7 +159,7 @@ require ( golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633 // indirect + google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect google.golang.org/grpc v1.54.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index e9f05d62..34fd9602 100644 --- a/go.sum +++ b/go.sum @@ -2809,8 +2809,8 @@ google.golang.org/genproto v0.0.0-20230113154510-dbe35b8444a5/go.mod h1:RGgjbofJ google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633 h1:0BOZf6qNozI3pkN3fJLwNubheHJYHhMh91GRFOWWK08= -google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= +google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd h1:sLpv7bNL1AsX3fdnWh9WVh7ejIzXdOc1RRHGeAmeStU= +google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= diff --git a/internal/common/eventmanager.go b/internal/common/eventmanager.go index 81304a22..5d1ca8e8 100644 --- a/internal/common/eventmanager.go +++ b/internal/common/eventmanager.go @@ -1848,6 +1848,7 @@ func executeCompressFsActionForUser(c dataprovider.EventActionFsCompress, replac } conn := NewBaseConnection(connectionID, protocolEventAction, "", "", user) name := util.CleanPath(replaceWithReplacer(c.Name, replacer)) + conn.CheckParentDirs(path.Dir(name)) //nolint:errcheck paths := make([]string, 0, len(c.Paths)) for idx := range c.Paths { p := util.CleanPath(replaceWithReplacer(c.Paths[idx], replacer)) diff --git a/internal/common/eventmanager_test.go b/internal/common/eventmanager_test.go index 70b5bc76..dc0d7fab 100644 --- a/internal/common/eventmanager_test.go +++ b/internal/common/eventmanager_test.go @@ -2017,6 +2017,8 @@ func TestEstimateZipSizeErrors(t *testing.T) { err = os.MkdirAll(u.GetHomeDir(), os.ModePerm) assert.NoError(t, err) conn := NewBaseConnection("", ProtocolFTP, "", "", u) + _, _, _, _, err = getFileWriter(conn, "/missing/path/file.txt", -1) //nolint:dogsled + assert.Error(t, err) _, err = getSizeForPath(conn, "/missing", vfs.NewFileInfo("missing", true, 0, time.Now(), false)) assert.True(t, conn.IsNotExistError(err)) if runtime.GOOS != osWindows { diff --git a/internal/common/protocol_test.go b/internal/common/protocol_test.go index 7948ac00..948b88bf 100644 --- a/internal/common/protocol_test.go +++ b/internal/common/protocol_test.go @@ -5429,22 +5429,6 @@ func TestEventActionCompressErrors(t *testing.T) { err = f.Close() assert.Error(t, err) } - // try to write to a missing directory - action1.Options.FsConfig.Compress.Name = "/subdir/missing/path/file.zip" - _, _, err = httpdtest.UpdateEventAction(action1, http.StatusOK) - assert.NoError(t, err) - conn, client, err = getSftpClient(user) - if assert.NoError(t, err) { - defer conn.Close() - defer client.Close() - - f, err := client.Create(testFileName) - assert.NoError(t, err) - _, err = f.Write(testFileContent) - assert.NoError(t, err) - err = f.Close() - assert.Error(t, err) - } _, err = httpdtest.RemoveEventRule(rule1, http.StatusOK) assert.NoError(t, err) @@ -5473,7 +5457,7 @@ func TestEventActionEmailAttachments(t *testing.T) { FsConfig: dataprovider.EventActionFilesystemConfig{ Type: dataprovider.FilesystemActionCompress, Compress: dataprovider.EventActionFsCompress{ - Name: "/{{VirtualPath}}.zip", + Name: "/archive/{{VirtualPath}}.zip", Paths: []string{"/{{VirtualPath}}"}, }, }, @@ -5489,7 +5473,7 @@ func TestEventActionEmailAttachments(t *testing.T) { Recipients: []string{"test@example.com"}, Subject: `"{{Event}}" from "{{Name}}"`, Body: "Fs path {{FsPath}}, size: {{FileSize}}, protocol: {{Protocol}}, IP: {{IP}}", - Attachments: []string{"/{{VirtualPath}}.zip"}, + Attachments: []string{"/archive/{{VirtualPath}}.zip"}, }, }, }