forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotocol.go
67 lines (53 loc) · 1.63 KB
/
protocol.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
package glob
import (
"www.velocidex.com/golang/velociraptor/accessors"
vql_subsystem "www.velocidex.com/golang/velociraptor/vql"
"www.velocidex.com/golang/vfilter"
"www.velocidex.com/golang/vfilter/protocols"
)
// Define a protocol for glob objects so we can hide deprecated fields
// and expose additional fields.
type _GlobHitAssociativeProtocol struct{}
func (self _GlobHitAssociativeProtocol) Applicable(
a vfilter.Any, b vfilter.Any) bool {
_, ok := a.(*GlobHit)
if !ok {
return false
}
switch b.(type) {
case string:
break
default:
return false
}
return true
}
func (self _GlobHitAssociativeProtocol) GetMembers(
scope vfilter.Scope, a vfilter.Any) []string {
// Only expose some fields that are explicitly provided by the
// glob.FileInfo interface. This cleans up * expansion in SELECT *
// FROM ...
return []string{
"Name", "OSPath", "Mtime", "Atime", "Ctime",
"Btime", "Size", "Mode", "IsDir", "IsLink", "Data", "Globs",
}
}
func (self _GlobHitAssociativeProtocol) Associative(
scope vfilter.Scope, a vfilter.Any, b vfilter.Any) (vfilter.Any, bool) {
// Issue a deprecation warning if needed but only issue it once per query.
b_str, ok := b.(string)
if ok && b_str == "FullPath" {
scope.Log("Deprecation: The FullPath column of the Glob plugin is deprecated and will be removed soon - Use OSPath instead")
}
return protocols.DefaultAssociative{}.Associative(scope, a, b)
}
func init() {
vql_subsystem.RegisterProtocol(&_GlobHitAssociativeProtocol{})
}
func getUniqueName(f accessors.FileInfo) string {
uniquer, ok := f.(accessors.UniqueBasename)
if ok {
return uniquer.UniqueName()
}
return f.Name()
}