-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config validate functionality without starting the server #110
base: main
Are you sure you want to change the base?
Conversation
…arting the server
Added a flag to validate the configuration without restarting the server
# Conflicts: # cmd/coraza-spoa/main.go
@@ -61,6 +63,11 @@ func main() { | |||
globalLogger.Fatal().Err(err).Msg("Failed creating applications") | |||
} | |||
|
|||
if validateConfig == true { | |||
globalLogger.Info().Bool("valid", true).Msg("Configuration is valid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing valid=true implies that a invalid config would print false. Instead it would return with exit 1 and another error message. We should probably rework this to return false and not fatal when in check mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this should be added to the CI/E2E test
@@ -28,6 +28,13 @@ coraza-spoa -f /etc/coraza-spoa/coraza-spoa.yaml | |||
|
|||
You will also want to download & extract the [OWASP Core Ruleset]( https://github.com/coreruleset/coreruleset/releases) (version 4+ supported) to the `/etc/coraza-spoa` directory. | |||
|
|||
### Validate Configuration | |||
To validate the configuration, you can pass the `-validate` flag, which just loads the configuration and exits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like our current flag names but because renaming would be a breaking change I left them as they are. I would really like to use haproxy like flags e.g. -c
for check mode and supplying the config file as first argument to the process. What do you think about this?
New CLI-Flag
I have added the CLI flag
-validate
which checks the configuration and exits before starting the SPOA server.Example call:
Why?
When modifying rules, there can happen errors like wrong syntax or duplicate ids.
If they are unnoticed and you restart the
coraza-spoa
it will crash and the WAF isn't handling any requests anymore.This flag enables you to check the configuration before running into such troubles.
This feature isn't solving the restart without downtime as in #19, but it minimizes the risk of bigger downtimes.
Other fixes
I fixed the systemd unit file with the wrong syntax
InaccessiblePaths=-/bin/find
Fixes #102