-
Notifications
You must be signed in to change notification settings - Fork 808
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
WAF: Add a dedicated automatic-rules.php file for storing firewall rules #28027
WAF: Add a dedicated automatic-rules.php file for storing firewall rules #28027
Conversation
Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Protect plugin:
|
…etched from WPCOM
3e0a2d2
to
627c697
Compare
With a fresh installation, using Protect, I was able to toggle the Automatic and Manual rules without any issue and the When canceling the plan, I could verify that the require for On the same install, via the Jetpack settings, the manual rules toggle handled similarly, however, regardless of the presence of a Scan plan, I was unable to get the |
const IP_LISTS_ENABLED_OPTION_NAME = 'jetpack_waf_ip_list'; | ||
const IP_ALLOW_LIST_OPTION_NAME = 'jetpack_waf_ip_allow_list'; | ||
const IP_BLOCK_LIST_OPTION_NAME = 'jetpack_waf_ip_block_list'; | ||
const RULES_FILE = __DIR__ . '/../rules/rules.php'; |
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.
Maybe we should change the name? We have too many permutations of RULES_FILE naming and it's starting to get confused, maybe something like ENTRYPOINT_FILE?
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've organized the constants a bit, and renamed them as follows via 70f04f4:
RULES_ENTRYPOINT_FILE
AUTOMATIC_RULES_FILE
IP_ALLOW_RULES_FILE
IP_BLOCK_RULES_FILE
This introduces a naming system where the sub-rule file are all named FOO_BAR_RULES_FILE
while the main file is RULES_ENTRYPOINT_FILE
for extra distinction.
3a7677e
to
70f04f4
Compare
I pulled in some backwards compatibility changes from #27785 to resolve this issue (d9ae22e and 0da59ac). This PR is now ready for re-review 👍 |
When I first activated Protect on a fresh Jurassic Tube instance, the Firewall was disabled by default - after hitting the prompt to enable, the notice remained after the loading icon resolved, prompting me again to enable it until I refreshed the page. The WAF module did appear to be enabled on the initial click and the endpoints were registered, however, it seems that the latest changes may have introduced an issue with toggling the Automatic and Manual rules settings. The initial attempt presents an error notice, and an immediate second attempt succeeds. A refresh of the page on the initial attempt displays as if the settings are active, however, in either case (regardless of a plan), no rules file is generated, no rules are run, and we are unable to successfully save changes to the manual rules settings, although we can access them. With the WAF module enabled and all other settings off, activating Jetpack produces the following fatal error because we never initially generated the rules file. It is not clear to me why
|
@dkmyta Thanks so much for all of the testing and assistance on this PR! I've updated with all of the latest changes from trunk/phase 2, and fixed the issues you were having. Now, the Protect UI will allow you to manage automatic rules after downgrading. Ready for your re-review 🙏 |
Note: Changelogger validity will be fixed in the add/protect-waf-phase-2 branch. |
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.
Works great!
This PR ensures that sites do not remove their automatic rules previously downloaded from WPCOM, in situations where the rules file is being re-generated and the site no longer has access to the latest firewall rules (i.e. cancelled their Scan plan).
Changes proposed in this Pull Request:
rules/automatic-rules.php
file for storing automatic rules fetched from WPCOM.rules/rules.php
torequire()
the relevant rules files, based on the WAF configuration (automatic and manual rules enabled options).automatic-rules.php
available to use.Other information:
Jetpack product discussion
peb6dq-p2-m9
Does this pull request change what data or activity we track or use?
No
Testing instructions:
automatic-rules.php
file is generated, but not yet included in the mainrules.php
file.?test=<script>
request is not blocked.?test=<script>
request is blocked.rules.php
file.rules.php
file.automatic-rules.php
file still contains the automatic rules fetched at the beginning of your testing.Screenshots
When the site previously upgraded and fetched automatic firewall rules, and then downgraded back to the free plan: