From 05406d04d3b78fd0fad404a740077fda22c447fe Mon Sep 17 00:00:00 2001 From: Karim Radhouani Date: Sun, 10 Nov 2024 15:33:47 -0800 Subject: [PATCH] Do not env expand regex fields --- pkg/config/environment.go | 10 +++++----- pkg/config/processors.go | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/config/environment.go b/pkg/config/environment.go index 351fb54e..90d067fe 100644 --- a/pkg/config/environment.go +++ b/pkg/config/environment.go @@ -90,11 +90,11 @@ func expandMapEnv(m map[string]interface{}, fn func(string, string) string) { for i, item := range v { switch item := item.(type) { case string: - v[i] = os.ExpandEnv(item) + v[i] = fn(f, item) case map[string]interface{}: expandMapEnv(item, fn) case []any: - expandSliceEnv(item, fn) + expandSliceEnv(f, item, fn) } } m[f] = v @@ -102,15 +102,15 @@ func expandMapEnv(m map[string]interface{}, fn func(string, string) string) { } } -func expandSliceEnv(s []any, fn func(string, string) string) { +func expandSliceEnv(parent string, s []any, fn func(string, string) string) { for i, item := range s { switch item := item.(type) { case string: - s[i] = os.ExpandEnv(item) + s[i] = fn(parent, item) case map[string]interface{}: expandMapEnv(item, fn) case []any: - expandSliceEnv(item, fn) + expandSliceEnv("", item, fn) } } } diff --git a/pkg/config/processors.go b/pkg/config/processors.go index 085ff6ec..423b42ca 100644 --- a/pkg/config/processors.go +++ b/pkg/config/processors.go @@ -39,7 +39,14 @@ func (c *Config) GetEventProcessors() (map[string]map[string]interface{}, error) c.Processors[n] = es } for n := range c.Processors { - expandMapEnv(c.Processors[n], expandExcept("expression", "condition")) + expandMapEnv(c.Processors[n], expandExcept( + "expression", + "condition", + "value-names", "values", + "tag-names", "tags", + "old", "new", // strings.replace + "source", // starlark + )) } if c.Debug { c.logger.Printf("processors: %+v", c.Processors)