Skip to content

Commit

Permalink
WAF: Remove unnecessary mode check before updating rule files (#38326)
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller authored Jul 15, 2024
1 parent f1da7bd commit 7dd18be
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Removed unnecessary check from the method that updates the WAF rule files.


5 changes: 0 additions & 5 deletions projects/packages/waf/src/class-waf-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ public static function check_for_updates() {

Waf_Compatibility::run_compatibility_migrations();

Waf_Constants::define_mode();
if ( ! Waf_Runner::is_allowed_mode( JETPACK_WAF_MODE ) ) {
return new WP_Error( 'waf_mode_invalid', 'Invalid firewall mode.' );
}

try {
Waf_Rules_Manager::generate_ip_rules();
Waf_Rules_Manager::generate_rules();
Expand Down
9 changes: 0 additions & 9 deletions projects/packages/waf/src/class-waf-rules-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ public static function schedule_rules_cron() {
* @return bool|WP_Error True if rules update is successful, WP_Error on failure.
*/
public static function update_rules_cron() {
Waf_Constants::define_mode();
if ( ! Waf_Runner::is_allowed_mode( JETPACK_WAF_MODE ) ) {
return new WP_Error( 'waf_invalid_mode', 'Invalid firewall mode.' );
}

try {
self::generate_automatic_rules();
self::generate_ip_rules();
Expand Down Expand Up @@ -127,10 +122,6 @@ public static function reactivate_on_rules_option_change() {
* @return void
*/
public static function update_rules_if_changed() {
Waf_Constants::define_mode();
if ( ! Waf_Runner::is_allowed_mode( JETPACK_WAF_MODE ) ) {
throw new Waf_Exception( 'Invalid firewall mode.' );
}
$version = get_option( self::VERSION_OPTION_NAME );
if ( self::RULES_VERSION !== $version ) {
self::generate_automatic_rules();
Expand Down
5 changes: 0 additions & 5 deletions projects/packages/waf/src/class-waf-runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,6 @@ public static function initialize_filesystem() {
* @return void
*/
public static function activate() {
Waf_Constants::define_mode();
if ( ! self::is_allowed_mode( JETPACK_WAF_MODE ) ) {
throw new Waf_Exception( 'Invalid firewall mode.' );
}

$version = get_option( Waf_Rules_Manager::VERSION_OPTION_NAME );
if ( ! $version ) {
add_option( Waf_Rules_Manager::VERSION_OPTION_NAME, Waf_Rules_Manager::RULES_VERSION );
Expand Down

0 comments on commit 7dd18be

Please sign in to comment.