Skip to content

Commit

Permalink
Merge pull request #23 from jcchavezs/os_fs_fallback
Browse files Browse the repository at this point in the history
fix: fallsback on OS FS when not loading CRS (#17)
  • Loading branch information
jcchavezs authored Oct 29, 2024
2 parents cbf68d8 + da51a64 commit d42b905
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,20 @@ func initializeWAF(host api.Host) (coraza.WAF, error) {
if cfg, err := getConfigFromHost(host); err == nil {
if cfg.includeCRS {
wafConfig = wafConfig.WithRootFS(mergefs.Merge(coreruleset.FS, fsio.OSFS))
} else {
wafConfig = wafConfig.WithRootFS(fsio.OSFS)
}

if cfg.directives == "" {
host.Log(api.LogLevelWarn, "Initializing WAF with no directives")
} else {
host.Log(api.LogLevelDebug, "Initializing WAF with directives:\n"+cfg.directives)
if host.LogEnabled(api.LogLevelDebug) {
if cfg.includeCRS {
host.Log(api.LogLevelDebug, "Initializing WAF with CRS embedded and directives:\n"+cfg.directives)
} else {
host.Log(api.LogLevelDebug, "Initializing WAF with directives:\n"+cfg.directives)
}
}
wafConfig = wafConfig.WithDirectives(cfg.directives)
}
} else {
Expand Down

0 comments on commit d42b905

Please sign in to comment.