@@ -17,7 +17,6 @@ import (
1717 log "github.com/sirupsen/logrus"
1818
1919 "github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration"
20- "github.com/crowdsecurity/crowdsec/pkg/apiclient"
2120 "github.com/crowdsecurity/crowdsec/pkg/apiclient/useragent"
2221 "github.com/crowdsecurity/crowdsec/pkg/appsec"
2322 "github.com/crowdsecurity/crowdsec/pkg/appsec/allowlists"
@@ -125,13 +124,6 @@ func (w *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Ent
125124 return errors .New ("appsec datasource requires a lapi client configuration. this is a bug, please report" )
126125 }
127126
128- client , err := apiclient .GetLAPIClient ()
129- if err != nil {
130- return fmt .Errorf ("unable to get authenticated LAPI client: %w" , err )
131- }
132-
133- w .lapiClient = client
134-
135127 if err := w .UnmarshalConfig (yamlConfig ); err != nil {
136128 return fmt .Errorf ("unable to parse appsec configuration: %w" , err )
137129 }
@@ -167,16 +159,16 @@ func (w *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Ent
167159
168160 // let's load the associated appsec_config:
169161 if w .config .AppsecConfigPath != "" {
170- if err = appsecCfg .LoadByPath (w .config .AppsecConfigPath ); err != nil {
162+ if err : = appsecCfg .LoadByPath (w .config .AppsecConfigPath ); err != nil {
171163 return fmt .Errorf ("unable to load appsec_config: %w" , err )
172164 }
173165 } else if w .config .AppsecConfig != "" {
174- if err = appsecCfg .Load (w .config .AppsecConfig , w .hub ); err != nil {
166+ if err : = appsecCfg .Load (w .config .AppsecConfig , w .hub ); err != nil {
175167 return fmt .Errorf ("unable to load appsec_config: %w" , err )
176168 }
177169 } else if len (w .config .AppsecConfigs ) > 0 {
178170 for _ , appsecConfig := range w .config .AppsecConfigs {
179- if err = appsecCfg .Load (appsecConfig , w .hub ); err != nil {
171+ if err : = appsecCfg .Load (appsecConfig , w .hub ); err != nil {
180172 return fmt .Errorf ("unable to load appsec_config: %w" , err )
181173 }
182174 }
@@ -187,11 +179,13 @@ func (w *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Ent
187179 // Now we can set up the logger
188180 appsecCfg .SetUpLogger ()
189181
190- w . AppsecRuntime , err = appsecCfg .Build (w .hub )
182+ appsecRuntime , err : = appsecCfg .Build (w .hub )
191183 if err != nil {
192184 return fmt .Errorf ("unable to build appsec_config: %w" , err )
193185 }
194186
187+ w .AppsecRuntime = appsecRuntime
188+
195189 err = w .AppsecRuntime .ProcessOnLoadRules ()
196190 if err != nil {
197191 return fmt .Errorf ("unable to process on load rules: %w" , err )
0 commit comments