This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
Redefine WAF provisioning to include disabled rules defined in TOML file #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the moment
waflyctl
doesn't allow me to promotewaflyctl.toml
in a batch mode. My goal is to reuse VCL delivery model for WAF config - store it in Git, version and promote across environments.Here's how my
waflyctl.toml
looks like:Disabled rules are not included while provisioning a service with
waflyctl --apikey=<FASTLY_API_KEY> --serviceid=<FASTLY_SERVICE_ID> --config=</path/to/waflyctl.toml> --provision
. That's not a surprise because of this comment andDefaultRuleDisabled
function placement (it gets triggered only when there's no WAF attached to given service yet).It simply means that
disabledrules
property is effectively ignored after initial WAF setup. The only way to disable rules is to usewaflyctl --apikey=<FASTLY_API_KEY> --serviceid=<FASTLY_SERVICE_ID> --config=</path/to/waflyctl.toml> --rules=<X,Y,Z> --action=disabled
.Unfortunately, such approach is not ideal. To get it done I'd have to use the following deployment strategy:
waflyctl --provision
(set tag/publishers rules to block)waflyctl --rules=<X,Y,Z> --action=disabled
(disable selected rules)There's a couple of downsides here:
block
). For tag-based rules that's less of a problem, as by default--force-status
isfalse
, so already disabled rules won't be changed to blocking mode. When it comes to publisher rules there's no such option - loop that goes through items fetched from/wafs/rules?filter[publisher]=<whatever>
simply sets an action according to config (or CLI param).block
mode few seconds ago, which means there's a short period of time when all rules block traffic, which is a no-go from my perspective.Alternatively I could deploy rules on a fine-grained basis (disable rule A, B and C, then turn rules X, Y, Z into blocking mode, etc), but that kinda defeats the purpose of having
waflyctl.toml
file.This PR respects
disabledrules
property during subsequent deployments. I also redefined the order in which ruleset is prepared before actual deployment (PatchRules
). OWASP settings get applied at the very end of WAF provisioning.