Skip to content

Commit e16a230

Browse files
refactor: remove --no-delete-upload flag and auto-delete plumbing
Upload is a standalone action — auto-deleting the file the operator just uploaded makes no sense. Removed: - --no-delete-upload flag from all 12 commands - NoDelete field from ExecutionUpload - DeleteUploadedFile field and delete logic from FileStager - CleanUpload method from ExecutionIO - CleanUpload call from ExecuteCleanMethod Co-authored-by: Carter <carter-falconops@users.noreply.github.com>
1 parent c7769ec commit e16a230

5 files changed

Lines changed: 9 additions & 33 deletions

File tree

cmd/args.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func registerExecutionFlags(fs *pflag.FlagSet) {
5252
func registerExecutionUploadFlags(fs *pflag.FlagSet) {
5353
fs.StringVar(&uploadSource, "upload", "", "Upload local `file` to remote filesystem")
5454
fs.StringVar(&uploadDest, "upload-dest", "", "Remote destination `path` for uploaded file")
55-
fs.BoolVar(&exec.Upload.NoDelete, "no-delete-upload", false, "Preserve uploaded file on remote filesystem")
5655
}
5756

5857
func registerExecutionOutputFlags(fs *pflag.FlagSet) {

cmd/root.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,10 @@ Authors: FalconOps LLC (@FalconOpsLLC),
187187
if uploadSource != "" {
188188
exec.Upload.RemotePath = uploadDest
189189
exec.Upload.Provider = &smb.FileStager{
190-
Client: &smbClient,
191-
Share: `C$`,
192-
SharePath: `C:\`,
193-
File: uploadDest,
194-
DeleteUploadedFile: !exec.Upload.NoDelete,
190+
Client: &smbClient,
191+
Share: `C$`,
192+
SharePath: `C:\`,
193+
File: uploadDest,
195194
}
196195
}
197196
return

pkg/goexec/io.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type ExecutionOutput struct {
3535
}
3636

3737
type ExecutionUpload struct {
38-
NoDelete bool
3938
RemotePath string
4039
Provider InputProvider
4140
Reader io.ReadCloser
@@ -56,13 +55,6 @@ func (execIO *ExecutionIO) DoUpload(ctx context.Context) (err error) {
5655
return nil
5756
}
5857

59-
func (execIO *ExecutionIO) CleanUpload(ctx context.Context) (err error) {
60-
if execIO.Upload != nil && execIO.Upload.Provider != nil {
61-
return execIO.Upload.Provider.Clean(ctx)
62-
}
63-
return nil
64-
}
65-
6658
func (execIO *ExecutionIO) GetOutput(ctx context.Context) (err error) {
6759
if execIO.Output.Provider != nil {
6860
ctx = context.WithValue(ctx, ContextOptionOutputTimeout, execIO.Output.Timeout)

pkg/goexec/method.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,6 @@ func ExecuteCleanMethod(ctx context.Context, module CleanExecutionMethod, execIO
141141
err = nil
142142
}
143143

144-
// Upload cleanup (delete uploaded file if configured)
145-
if execIO.Upload != nil && execIO.Upload.Provider != nil {
146-
if cleanErr := execIO.CleanUpload(ctx); cleanErr != nil {
147-
log.Debug().Err(cleanErr).Msg("Upload cleanup failed")
148-
}
149-
}
150-
151144
// Output collection
152145
if execIO.Output != nil && execIO.Output.Provider != nil {
153146
log.Info().Msg("Collecting output")

pkg/goexec/smb/input.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ type FileStager struct {
1616

1717
Client *Client
1818

19-
Share string
20-
SharePath string
21-
File string
22-
relativePath string
23-
ForceReconnect bool
24-
DeleteUploadedFile bool
19+
Share string
20+
SharePath string
21+
File string
22+
relativePath string
23+
ForceReconnect bool
2524
}
2625

2726
func (o *FileStager) Upload(ctx context.Context, reader io.Reader) (err error) {
@@ -60,11 +59,5 @@ func (o *FileStager) Upload(ctx context.Context, reader io.Reader) (err error) {
6059

6160
o.AddCleaners(func(_ context.Context) error { return writer.Close() })
6261

63-
if o.DeleteUploadedFile {
64-
o.AddCleaners(func(_ context.Context) error {
65-
return o.Client.mount.Remove(o.relativePath)
66-
})
67-
}
68-
6962
return
7063
}

0 commit comments

Comments
 (0)