Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Preparing flow export from server artifact flows (#2606)
Did not include uploaded bulk files. Also fixed bug in recent client search: sort by recently active before paging to maintain stable paging behavior.
- Loading branch information
Showing
8 changed files
with
182 additions
and
27 deletions.
There are no files selected for viewing
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,44 @@ | ||
package test_utils | ||
|
||
import ( | ||
"archive/zip" | ||
"io" | ||
|
||
config_proto "www.velocidex.com/golang/velociraptor/config/proto" | ||
"www.velocidex.com/golang/velociraptor/file_store" | ||
"www.velocidex.com/golang/velociraptor/file_store/api" | ||
"www.velocidex.com/golang/velociraptor/utils" | ||
) | ||
|
||
func UnzipToFilestore( | ||
config_obj *config_proto.Config, | ||
base api.FSPathSpec, | ||
zip_path string) error { | ||
|
||
reader, err := zip.OpenReader(zip_path) | ||
if err != nil { | ||
return err | ||
} | ||
defer reader.Close() | ||
|
||
file_store_factory := file_store.GetFileStore(config_obj) | ||
|
||
for _, f := range reader.File { | ||
components := utils.SplitComponents(f.Name) | ||
output_path := base.AddChild(components...). | ||
SetType(api.PATH_TYPE_FILESTORE_ANY) | ||
fd, err := file_store_factory.WriteFile(output_path) | ||
if err != nil { | ||
return err | ||
} | ||
infd, err := reader.Open(f.Name) | ||
if err != nil { | ||
continue | ||
} | ||
|
||
io.Copy(fd, infd) | ||
fd.Close() | ||
} | ||
|
||
return nil | ||
} |
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
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
59 changes: 59 additions & 0 deletions
59
vql/server/downloads/fixtures/TestExportCollectionServerArtifact.golden
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,59 @@ | ||
{ | ||
"client_info.json": [ | ||
{} | ||
], | ||
"logs.json": [ | ||
{ | ||
"Timestamp": 1680585571852796, | ||
"Level": "DEFAULT", | ||
"message": "Running query on behalf of user mic\n" | ||
}, | ||
{ | ||
"Timestamp": 1680585571852838, | ||
"Level": "DEFAULT", | ||
"message": "\u003cgreen\u003eStarting\u003c/\u003e query execution.\n" | ||
}, | ||
{ | ||
"Timestamp": 1680585571855305, | ||
"Level": "DEFAULT", | ||
"message": "Uploaded /File0.txt.json (37 bytes)\n" | ||
}, | ||
{ | ||
"Timestamp": 1680585571856397, | ||
"Level": "DEFAULT", | ||
"message": "Uploaded /File1.txt.json (37 bytes)\n" | ||
}, | ||
{ | ||
"Timestamp": 1680585571857412, | ||
"Level": "DEBUG", | ||
"message": "Query Stats: {\"RowsScanned\":2,\"PluginsCalled\":1,\"FunctionsCalled\":4,\"ProtocolSearch\":0,\"ScopeCopy\":6}\n" | ||
} | ||
], | ||
"uploads/File0.txt": "This is a long test with many letters", | ||
"uploads/File1.txt": "This is a long test with many letters", | ||
"uploads.json.index": "\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\ufffd\u0000\u0000\u0000\u0000\u0001\u0000\u0000", | ||
"uploads.json": [ | ||
{ | ||
"Timestamp": 1680585571, | ||
"started": "2023-04-04 05:19:31.855375283 +0000 UTC", | ||
"vfs_path": "/File0.txt.json", | ||
"_Components": [ | ||
"uploads", | ||
"File0.txt" | ||
], | ||
"file_size": 37, | ||
"uploaded_size": 37 | ||
}, | ||
{ | ||
"Timestamp": 1680585571, | ||
"started": "2023-04-04 05:19:31.856444777 +0000 UTC", | ||
"vfs_path": "/File1.txt.json", | ||
"_Components": [ | ||
"uploads", | ||
"File1.txt" | ||
], | ||
"file_size": 37, | ||
"uploaded_size": 37 | ||
} | ||
] | ||
} |
Binary file not shown.