Add WAF rule factory#3
Open
premtsd-code wants to merge 1 commit into
Open
Conversation
Greptile Summary
Confidence Score: 5/5The changes are contained to a framework-agnostic factory and its unit tests, with no outstanding code issues identified. The implementation scope is narrow, validates malformed inputs, preserves default handling behavior, and is covered by focused tests described for supported actions and invalid payloads.
What T-Rex did
Reviews (6): Last reviewed commit: "Add WAF rule factory" | Re-trigger Greptile |
252c402 to
88d22b5
Compare
88d22b5 to
e5ea287
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
RuleFactory::fromArray()for building typed WAF rule objects from plain array payloads.RuleFactory::create()for callers that already haveaction,conditions, andconfigas separate values.bypass,deny,challenge,rateLimit, andredirectactions from one shared action-to-class mapping.Scope
This factory is framework-agnostic. It does not know about Appwrite documents, databases, projects, edge caches, or request routing. Consumers should adapt persisted or API data into plain arrays before calling the factory.
Why
Consumers need a consistent way to turn stored WAF rule definitions into executable rule objects. Keeping rule construction in this package avoids duplicating action-to-class mapping and default config handling in each consumer.
Tests
php -l src/RuleFactory.phpphp vendor/bin/phpunit --configuration phpunit.xmlphp vendor/bin/pint --testphp vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 512M