WAF: register WP Abilities API reads#48733
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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 🤖 🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so: 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage Summary1 file is newly checked for coverage.
|
Summary
Registers two read-only abilities for the Jetpack WAF (Web Application Firewall) package via the
Automattic\Jetpack\WP_Abilities\Registrarbase class:jetpack-waf/get-mode— returns{ mode, automatic_rules_active, automatic_rules_last_update, brute_force_protection_active, ip_allow_list_count, ip_block_list_count }.modeis one ofdisabled,silent, ornormal.jetpack-waf/get-rules-status— returns{ jetpack_waf_automatic_rules_last_updated_timestamp, jetpack_waf_last_updated_timestamp, standalone_mode, rules_file_present, rules_file_size }.Both are read-only / idempotent / non-destructive, gated on
current_user_can( 'manage_options' )to match the existing WAF REST controller cap.Cross-consumer wiring
WAF is consumed by both the Jetpack plugin and the Jetpack Protect plugin, so registration lives in a new
projects/packages/waf/actions.php(added tocomposer.jsonautoload.files). It hooksplugins_loadedat priority 20 and checks the package-widejetpack_wp_abilities_enabledgate filter (defaultfalse) before callingWaf_Abilities::init(). Net effect: when a host plugin opts in, the abilities fire on both Jetpack and Protect installs without duplicating bootstrap code.References plan §4.2 (cross-consumer wiring via package
actions.php) and §4.5 (read-only WAF surface; writes deferred to a follow-up).Test plan
composer phpunitfromprojects/packages/waf/— all 274 tests pass (48 integration including 17 new abilities tests, 226 unit).add_filter( 'jetpack_wp_abilities_enabled', '__return_true' ), confirm/wp-json/wp-abilities/v1/abilitieslists bothjetpack-waf/get-modeandjetpack-waf/get-rules-status.silent,normal).