forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented file upload through the VQL upload() plugin.
File uploads are sent through the responsible flow which ensures they are properly accounted for and upload quota is enforced.
- Loading branch information
Showing
14 changed files
with
303 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package file_store | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"os" | ||
"path" | ||
config "www.velocidex.com/golang/velociraptor/config" | ||
logging "www.velocidex.com/golang/velociraptor/logging" | ||
) | ||
|
||
type WriteSeekCloser interface { | ||
io.WriteSeeker | ||
io.Closer | ||
} | ||
|
||
type FileStore interface { | ||
WriteFile(filename string) (WriteSeekCloser, error) | ||
} | ||
|
||
type DirectoryFileStore struct { | ||
config_obj *config.Config | ||
} | ||
|
||
func (self *DirectoryFileStore) WriteFile(filename string) (WriteSeekCloser, error) { | ||
if self.config_obj.FileStore_directory == nil { | ||
return nil, errors.New("No configured file store directory.") | ||
} | ||
|
||
file_path := path.Join(*self.config_obj.FileStore_directory, filename) | ||
err := os.MkdirAll(path.Dir(file_path), 0700) | ||
if err != nil { | ||
logging.NewLogger(self.config_obj).Error( | ||
"Can not create dir: %s", err.Error()) | ||
return nil, err | ||
} | ||
|
||
file, err := os.OpenFile(file_path, os.O_RDWR|os.O_CREATE, 0700) | ||
if err != nil { | ||
logging.NewLogger(self.config_obj).Error( | ||
"Unable to open file %s: %s", file_path, err.Error()) | ||
return nil, err | ||
} | ||
|
||
return file, nil | ||
} | ||
|
||
// Currently we only support a DirectoryFileStore. | ||
func GetFileStore(config_obj *config.Config) FileStore { | ||
return &DirectoryFileStore{config_obj} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.