forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.go
41 lines (32 loc) · 944 Bytes
/
inventory.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
package paths
import (
"crypto/sha256"
"encoding/hex"
artifacts_proto "www.velocidex.com/golang/velociraptor/artifacts/proto"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/file_store/api"
)
func ObfuscateName(
config_obj *config_proto.Config, name string) string {
sha_sum := sha256.New()
_, err := sha_sum.Write([]byte(config_obj.ObfuscationNonce + name))
if err != nil {
return name
}
return hex.EncodeToString(sha_sum.Sum(nil))
}
type InventoryPathManager struct {
root api.FSPathSpec
}
func (self InventoryPathManager) Path() api.FSPathSpec {
return self.root
}
func NewInventoryPathManager(config_obj *config_proto.Config,
tool *artifacts_proto.Tool) *InventoryPathManager {
if tool.FilestorePath == "" {
tool.FilestorePath = ObfuscateName(config_obj, tool.Name)
}
return &InventoryPathManager{
root: PUBLIC_ROOT.AddChild(tool.FilestorePath),
}
}