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/model/setting/class-blacklist-lockout.php +34 -5 5.8.0 → 6.3.0 View file →
@@ -67,14 +67,14 @@
67 67 public $country_whitelist = array();
68 68
69 69 /**
70 70 * Path to downloaded GeoDB.
71 - * Important: This var doesn't support Union Types. So just 'string'.
71 + * An empty string indicates that no database path is saved.
72 72 *
73 73 * @var string
74 74 * @defender_property
75 75 */
76 - public $geodb_path = null;
76 + public $geodb_path = '';
77 77
78 78 /**
79 79 * MaxMind license key.
80 80 *
@@ -187,9 +187,10 @@
187 187 unset( $collection[ $i ] );
188 188 $errors = array_merge( $errors, $messages );
189 189 }
190 190 }
191 - $this->$key = implode( PHP_EOL, array_filter( $collection, 'strlen' ) );
191 +
192 + $this->set_list_property( $key, implode( PHP_EOL, array_filter( $collection, 'strlen' ) ) );
192 193 }
193 194
194 195 if ( array() !== $errors ) {
195 196 $this->errors[] = esc_html__( 'Invalid IP addresses detected. Please fix the following errors:', 'defender-security' );
@@ -197,8 +198,31 @@
197 198 }
198 199 }
199 200
200 201 /**
202 + * Set a list property.
203 + *
204 + * @param string $property Property name.
205 + * @param string $value Property value.
206 + *
207 + * @throws \InvalidArgumentException Invalid property name.
208 + */
209 + private function set_list_property( string $property, string $value ): void {
210 + switch ( $property ) {
211 + case 'ip_blacklist':
212 + $this->ip_blacklist = $value;
213 + break;
214 +
215 + case 'ip_whitelist':
216 + $this->ip_whitelist = $value;
217 + break;
218 +
219 + default:
220 + throw new \InvalidArgumentException( 'Invalid property name.' );
221 + }
222 + }
223 +
224 + /**
201 225 * Get list of blocklisted or allowlisted IPs.
202 226 *
203 227 * @param string $type blocklist|allowlist.
204 228 *
@@ -261,11 +285,16 @@
261 285 *
262 286 * @return void
263 287 */
264 288 protected function after_load(): void {
289 + // Normalize legacy or imported settings before using this value in filesystem functions.
290 + if ( ! is_string( $this->geodb_path ) ) {
291 + $this->geodb_path = '';
292 + }
293 +
265 294 if (
266 - is_string( $this->geodb_path ) &&
267 - strlen( $this->geodb_path ) > 0
295 + strlen( $this->geodb_path ) > 0 &&
296 + ! is_file( $this->geodb_path )
268 297 ) {
269 298 $service_geo = wd_di()->get( MaxMind_Geolocation::class );
270 299
271 300 preg_match( '#.*[\\\/](.*[\\\/].*)$#', $this->geodb_path, $matches );