PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/component/class-malicious-bot.php +4 -13 6.1.0 → 6.3.0 View file →
@@ -12,8 +12,9 @@
12 12 use WP_Defender\Model\Lockout_Log;
13 13 use WP_Defender\Traits\File_Operations;
14 14 use WP_Defender\Integrations\Smartcrawl;
15 15 use WP_Defender\Model\Setting\User_Agent_Lockout;
16 +use WP_Defender\Model\Notification\Firewall_Notification;
16 17
17 18 /**
18 19 * Handles operations to insert a weekly rotating hash URL into the footer,
19 20 * and blocking IP addresses that access this URL.
@@ -232,22 +233,10 @@
232 233 * @param string $uri The URI that was accessed.
233 234 * @param string $scenario The scenario under which the event is logged.
234 235 */
235 236 public function log_event( $ip, $uri, $scenario ) {
236 - $model = new Lockout_Log();
237 - $model->ip = $ip;
238 - $user_agent = defender_get_data_from_request( 'HTTP_USER_AGENT', 's' );
239 - $model->user_agent = isset( $user_agent ) ? User_Agent::fast_cleaning( $user_agent ) : null;
240 - $model->date = time();
241 - $model->tried = $uri;
242 - $model->blog_id = get_current_blog_id();
237 + $model = Lockout_Log::create( $ip, $uri );
243 238
244 - $ip_to_country = $this->ip_to_country( $ip );
245 -
246 - if ( isset( $ip_to_country['iso'] ) ) {
247 - $model->country_iso_code = $ip_to_country['iso'];
248 - }
249 -
250 239 switch ( $scenario ) {
251 240 case self::SCENARIO_MALICIOUS_BOT:
252 241 default:
253 242 $model->type = Lockout_Log::LOCKOUT_MALICIOUS_BOT;
@@ -254,8 +243,10 @@
254 243 $model->log = esc_html__( 'Lockout occurred: Bot ignored robots.txt rules.', 'defender-security' );
255 244 break;
256 245 }
257 246 $model->save();
247 + // Notify directly because the 'defender_notify' hook isn't registered yet at firewall-time.
248 + wd_di()->get( Firewall_Notification::class )->notify_lockout( $model );
258 249 }
259 250
260 251 /**
261 252 * Creates a lockout for a blocked IP.