From 00d899ee8ef0c8b7c335dd1ab9d0d129ed17cd0f Mon Sep 17 00:00:00 2001 From: Sebastien Blot Date: Wed, 6 Dec 2023 10:35:04 +0100 Subject: [PATCH] rename struct in UnmarshalConfig --- pkg/acquisition/modules/appsec/appsec.go | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/pkg/acquisition/modules/appsec/appsec.go b/pkg/acquisition/modules/appsec/appsec.go index e30f0e35e..7f0a8155b 100644 --- a/pkg/acquisition/modules/appsec/appsec.go +++ b/pkg/acquisition/modules/appsec/appsec.go @@ -90,45 +90,45 @@ type BodyResponse struct { Action string `json:"action"` } -func (wc *AppsecSource) UnmarshalConfig(yamlConfig []byte) error { +func (w *AppsecSource) UnmarshalConfig(yamlConfig []byte) error { - err := yaml.UnmarshalStrict(yamlConfig, &wc.config) + err := yaml.UnmarshalStrict(yamlConfig, &w.config) if err != nil { return errors.Wrap(err, "Cannot parse appsec configuration") } - if wc.config.ListenAddr == "" { - wc.config.ListenAddr = "127.0.0.1:7422" + if w.config.ListenAddr == "" { + w.config.ListenAddr = "127.0.0.1:7422" } - if wc.config.Path == "" { - wc.config.Path = "/" + if w.config.Path == "" { + w.config.Path = "/" } - if wc.config.Path[0] != '/' { - wc.config.Path = "/" + wc.config.Path + if w.config.Path[0] != '/' { + w.config.Path = "/" + w.config.Path } - if wc.config.Mode == "" { - wc.config.Mode = configuration.TAIL_MODE + if w.config.Mode == "" { + w.config.Mode = configuration.TAIL_MODE } // always have at least one appsec routine - if wc.config.Routines == 0 { - wc.config.Routines = 1 + if w.config.Routines == 0 { + w.config.Routines = 1 } - if wc.config.AppsecConfig == "" && wc.config.AppsecConfigPath == "" { + if w.config.AppsecConfig == "" && w.config.AppsecConfigPath == "" { return fmt.Errorf("appsec_config or appsec_config_path must be set") } - if wc.config.Name == "" { - wc.config.Name = fmt.Sprintf("%s%s", wc.config.ListenAddr, wc.config.Path) + if w.config.Name == "" { + w.config.Name = fmt.Sprintf("%s%s", w.config.ListenAddr, w.config.Path) } csConfig := csconfig.GetConfig() - wc.lapiURL = fmt.Sprintf("%sv1/decisions/stream", csConfig.API.Client.Credentials.URL) - wc.AuthCache = NewAuthCache() + w.lapiURL = fmt.Sprintf("%sv1/decisions/stream", csConfig.API.Client.Credentials.URL) + w.AuthCache = NewAuthCache() return nil } @@ -204,6 +204,7 @@ func (w *AppsecSource) Configure(yamlConfig []byte, logger *log.Entry) error { "uuid": appsecRunnerUUID, }), AppsecRuntime: &wrt, + Labels: w.config.Labels, } err := runner.Init(appsecCfg.GetDataDir()) if err != nil {