Skip to content

Commit

Permalink
keep regression but deprecate rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jptosso committed May 13, 2023
1 parent fb9eea8 commit 4bb9c3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions internal/spoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4bb9c3e

Please sign in to comment.