diff --git a/config/config.go b/config/config.go index 179ab17..d5df3f8 100644 --- a/config/config.go +++ b/config/config.go @@ -22,12 +22,14 @@ type Config struct { // Application is used to manage the haproxy configuration and waf rules. type Application struct { - LogLevel string `yaml:"log_level"` - LogFile string `yaml:"log_file"` - NoResponseCheck bool `yaml:"no_response_check"` - Directives string `yaml:"directives"` - TransactionTTLMilliseconds int `yaml:"transaction_ttl_ms"` - TransactionActiveLimit int `yaml:"transaction_active_limit"` + LogLevel string `yaml:"log_level"` + LogFile string `yaml:"log_file"` + NoResponseCheck bool `yaml:"no_response_check"` + Directives string `yaml:"directives"` + // Deprecated: use directives instead, this will be removed in the near future. + Rules []string `yaml:"rules"` + TransactionTTLMilliseconds int `yaml:"transaction_ttl_ms"` + TransactionActiveLimit int `yaml:"transaction_active_limit"` } // InitConfig initializes the configuration. diff --git a/internal/spoa.go b/internal/spoa.go index 7386e82..1e02bd8 100644 --- a/internal/spoa.go +++ b/internal/spoa.go @@ -188,6 +188,11 @@ func New(conf *config.Config) (*SPOA, error) { WithDirectives(cfg.Directives). WithErrorCallback(logError(logger)) + if len(cfg.Rules) > 0 { + // Deprecated: this will soon be removed + conf = conf.WithDirectives(strings.Join(cfg.Rules, "\n")) + } + waf, err := coraza.NewWAF(conf) if err != nil { logger.Error("unable to create waf instance", zap.String("app", name), zap.Error(err))