diff --git a/go.mod b/go.mod index 9ac6696..f888f6b 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module www.velocidex.com/golang/vfilter require ( - github.com/Velocidex/ordereddict v0.0.0-20230909174157-2aa49cc5d11d + github.com/Velocidex/ordereddict v0.0.0-20250821063524-02dc06e46238 github.com/alecthomas/assert v1.0.0 github.com/alecthomas/participle v0.7.1 github.com/alecthomas/repr v0.3.0 diff --git a/go.sum b/go.sum index e0fbfdc..dcb01a0 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/Velocidex/json v0.0.0-20220224052537-92f3c0326e5a h1:AeXPUzhU0yhID/v5JJEIkjaE85ASe+Vh4Kuv1RSLL+4= github.com/Velocidex/json v0.0.0-20220224052537-92f3c0326e5a/go.mod h1:ukJBuruT9b24pdgZwWDvOaCYHeS03B7oQPCUWh25bwM= -github.com/Velocidex/ordereddict v0.0.0-20230909174157-2aa49cc5d11d h1:fn372EqKyazBxYUP5HPpBi3jId4MXuppEypEALGfvEk= -github.com/Velocidex/ordereddict v0.0.0-20230909174157-2aa49cc5d11d/go.mod h1:+MqO5UMBemyFSm+yRXslbpFTwPUDhFHUf7HPV92twg4= +github.com/Velocidex/ordereddict v0.0.0-20250821063524-02dc06e46238 h1:Q2DFf1f4fiz1/V4cu2wojDKF6/DfjIY7QmfVAr/UnJY= +github.com/Velocidex/ordereddict v0.0.0-20250821063524-02dc06e46238/go.mod h1:+MqO5UMBemyFSm+yRXslbpFTwPUDhFHUf7HPV92twg4= github.com/Velocidex/yaml/v2 v2.2.8 h1:GUrSy4SBJ6RjGt43k6MeBKtw2z/27gh4A3hfFmFY3No= github.com/Velocidex/yaml/v2 v2.2.8/go.mod h1:PlXIg/Pxmoja48C1vMHo7C5pauAZvLq/UEPOQ3DsjS4= github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o= diff --git a/protocols/protocol_associative.go b/protocols/protocol_associative.go index 6295571..cb43f2d 100644 --- a/protocols/protocol_associative.go +++ b/protocols/protocol_associative.go @@ -10,6 +10,17 @@ import ( "www.velocidex.com/golang/vfilter/utils" ) +var ( + exportedDictMethods = map[string]bool{ + "Items": true, + "Keys": true, + "Values": true, + "Len": true, + "ToMap": true, + "String": true, + } +) + // Associative protocol. type AssociativeProtocol interface { Applicable(a types.Any, b types.Any) bool @@ -68,6 +79,12 @@ func (self *AssociativeDispatcher) Associative( return result, true case *ordereddict.Dict: + // Support common dict methods + if exportedDictMethods[b_str] { + res, pres := DefaultAssociative{}.Associative(scope, a, b) + return res, pres + } + res, pres := t.Get(b_str) if !pres { default_value := t.GetDefault()