forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfs_service.go
85 lines (74 loc) · 2.58 KB
/
vfs_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package services
import (
"context"
"time"
"github.com/Velocidex/ordereddict"
api_proto "www.velocidex.com/golang/velociraptor/api/proto"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
flows_proto "www.velocidex.com/golang/velociraptor/flows/proto"
)
type VFSPartition struct {
StartIdx uint64 `json:"start_idx"`
EndIdx uint64 `json:"end_idx"`
}
// This is the type of rows sent in the
// System.VFS.ListDirectory/Listing artifact. The VFS service will
// parse them and write to the datastore.
type VFSListRow struct {
FullPath string `json:"FullPath"`
Components []string `json:"Components"`
Accessor string `json:"Accessor"`
Data *ordereddict.Dict `json:"Data"`
Stats *VFSPartition `json:"Stats"`
Name string `json:"Name"`
Size int64 `json:"Size"`
Mode string `json:"Mode"`
Mtime time.Time `json:"mtime"`
Atime time.Time `json:"atime"`
Ctime time.Time `json:"ctime"`
Btime time.Time `json:"btime"`
Idx uint64 `json:"Idx"`
}
func GetVFSService(config_obj *config_proto.Config) (VFSService, error) {
org_manager, err := GetOrgManager()
if err != nil {
return nil, err
}
return org_manager.Services(config_obj.OrgId).VFSService()
}
type VFSService interface {
// Lists all the directories in the VFS path provided. This is
// used by the tree widget in the GUI so it only returns
// directories. For both files and directories see ListFiles()
// below.
ListDirectories(
ctx context.Context,
config_obj *config_proto.Config,
client_id string,
components []string) (*api_proto.VFSListResponse, error)
// Lists the files in the directory as well. Enriches with
// download information for downloaed files. Used by the GUI's VFS
// file listing widget. Supports table transformations like
// filtering/sorting etc which can be provided with the
// GetTableRequest.
ListDirectoryFiles(
ctx context.Context,
config_obj *config_proto.Config,
in *api_proto.GetTableRequest) (*api_proto.GetTableResponse, error)
StatDirectory(
config_obj *config_proto.Config,
client_id string,
vfs_components []string) (*api_proto.VFSListResponse, error)
StatDownload(
config_obj *config_proto.Config,
client_id string,
accessor string,
path_components []string) (*flows_proto.VFSDownloadInfo, error)
WriteDownloadInfo(
ctx context.Context,
config_obj *config_proto.Config,
client_id string,
accessor string,
client_components []string,
record *flows_proto.VFSDownloadInfo) error
}