From 02be5f361895d7cf5795c444a13f2a5896fc5ba8 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Mon, 23 Jan 2023 16:28:43 +0100 Subject: [PATCH] allow literal `$` in plugin configuration (#2015) --- pkg/csplugin/broker.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/csplugin/broker.go b/pkg/csplugin/broker.go index 81bd5e1ca..716368a92 100644 --- a/pkg/csplugin/broker.go +++ b/pkg/csplugin/broker.go @@ -12,16 +12,18 @@ import ( "time" "github.com/Masterminds/sprig/v3" - "github.com/crowdsecurity/crowdsec/pkg/csconfig" - "github.com/crowdsecurity/crowdsec/pkg/models" - "github.com/crowdsecurity/crowdsec/pkg/protobufs" - "github.com/crowdsecurity/crowdsec/pkg/types" "github.com/google/uuid" plugin "github.com/hashicorp/go-plugin" "github.com/pkg/errors" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" "gopkg.in/yaml.v2" + + "github.com/crowdsecurity/crowdsec/pkg/csconfig" + "github.com/crowdsecurity/crowdsec/pkg/csstring" + "github.com/crowdsecurity/crowdsec/pkg/models" + "github.com/crowdsecurity/crowdsec/pkg/protobufs" + "github.com/crowdsecurity/crowdsec/pkg/types" ) var pluginMutex sync.Mutex @@ -254,7 +256,7 @@ func (pb *PluginBroker) loadPlugins(path string) error { if err != nil { return err } - data = []byte(os.ExpandEnv(string(data))) + data = []byte(csstring.StrictExpand(string(data), os.LookupEnv)) _, err = pluginClient.Configure(context.Background(), &protobufs.Config{Config: data}) if err != nil { return errors.Wrapf(err, "while configuring %s", pc.Name)