From 1845f9b9e5d5cc71d48d888a12bfcb03559e740b Mon Sep 17 00:00:00 2001 From: Mike Cohen Date: Thu, 21 Aug 2025 16:32:43 +1000 Subject: [PATCH 1/2] Export ordereddict methods to VQL --- go.mod | 2 +- go.sum | 4 ++-- protocols/protocol_associative.go | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9ac6696..dc11411 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-20250813031713-7996a9397018 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..b1e79ed 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-20250813031713-7996a9397018 h1:eUMb0bl+A+/rm79LO2ylmAtoOTvxhNBenD5EbBJI2Z8= +github.com/Velocidex/ordereddict v0.0.0-20250813031713-7996a9397018/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() From 445aa4def52a37c687c4d56e10a7cd7c79625a21 Mon Sep 17 00:00:00 2001 From: Mike Cohen Date: Thu, 21 Aug 2025 16:37:27 +1000 Subject: [PATCH 2/2] Update ordereddict --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dc11411..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-20250813031713-7996a9397018 + 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 b1e79ed..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-20250813031713-7996a9397018 h1:eUMb0bl+A+/rm79LO2ylmAtoOTvxhNBenD5EbBJI2Z8= -github.com/Velocidex/ordereddict v0.0.0-20250813031713-7996a9397018/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=