diff --git a/bc-security.php b/bc-security.php index cbd0913..73fd43d 100644 --- a/bc-security.php +++ b/bc-security.php @@ -4,7 +4,7 @@ * Plugin Name: BC Security * Plugin URI: https://github.com/chesio/bc-security * Description: Helps keeping WordPress websites secure. - * Version: 0.17.0 + * Version: 0.17.1 * Author: Česlav Przywara * Author URI: https://www.chesio.com * Requires PHP: 7.3 diff --git a/classes/BlueChip/Security/Core/Settings.php b/classes/BlueChip/Security/Core/Settings.php index 795e5be..54ad107 100644 --- a/classes/BlueChip/Security/Core/Settings.php +++ b/classes/BlueChip/Security/Core/Settings.php @@ -80,7 +80,7 @@ public function __set(string $name, $value) //// ArrayAccess API /////////////////////////////////////////////////////// /** - * Return true, if there is any setting available under key $offset. + * Return true if there is any setting available under key $offset. * * @internal Implements ArrayAccess interface. * @@ -184,7 +184,7 @@ public function reset(): bool /** * Remove the data from database (= hard reset). * - * @return bool True, if settings have been deleted, false otherwise. + * @return bool True if settings have been deleted, false otherwise. */ public function destroy(): bool { @@ -195,7 +195,7 @@ public function destroy(): bool /** * Persist the value of data into database. * - * @return bool True, if settings have been updated (= changed), false otherwise. + * @return bool True if settings have been updated (= changed), false otherwise. */ public function persist(): bool { diff --git a/classes/BlueChip/Security/Helpers/AjaxHelper.php b/classes/BlueChip/Security/Helpers/AjaxHelper.php index 9764302..f871e09 100644 --- a/classes/BlueChip/Security/Helpers/AjaxHelper.php +++ b/classes/BlueChip/Security/Helpers/AjaxHelper.php @@ -14,7 +14,7 @@ abstract class AjaxHelper /** - * Register callback as handler for AJAX action. Handler will be only executed, if nonce check passes. + * Register callback as handler for AJAX action. Handler will be only executed when nonce check passes. * * @param string $action * @param callable $handler @@ -22,7 +22,7 @@ abstract class AjaxHelper public static function addHandler(string $action, callable $handler) { add_action(self::WP_AJAX_PREFIX . $action, function () use ($action, $handler) { - // Check AJAX referer for given action - will die, if invalid. + // Check AJAX referer for given action - will die if invalid. check_ajax_referer($action); \call_user_func($handler); diff --git a/classes/BlueChip/Security/Helpers/HaveIBeenPwned.php b/classes/BlueChip/Security/Helpers/HaveIBeenPwned.php index 25c4388..8afb9b0 100644 --- a/classes/BlueChip/Security/Helpers/HaveIBeenPwned.php +++ b/classes/BlueChip/Security/Helpers/HaveIBeenPwned.php @@ -22,7 +22,7 @@ abstract class HaveIBeenPwned /** * @link https://haveibeenpwned.com/API/v2#PwnedPasswords * @param string $password Password to check. - * @return bool True, if $password has been previously exposed in a data breach, false if not, null if check failed. + * @return bool True if $password has been previously exposed in a data breach, false if not, null if check failed. */ public static function hasPasswordBeenPwned(string $password): ?bool { diff --git a/classes/BlueChip/Security/Helpers/Is.php b/classes/BlueChip/Security/Helpers/Is.php index 4e7a174..1d37428 100644 --- a/classes/BlueChip/Security/Helpers/Is.php +++ b/classes/BlueChip/Security/Helpers/Is.php @@ -49,7 +49,7 @@ public static function live(): bool * Return true if current request is of given $type. * * @param string $type One of: admin, ajax, cron, frontend or wp-cli. - * @return bool True, if current request is of given $type, false otherwise. + * @return bool True if current request is of given $type, false otherwise. */ public static function request(string $type): bool { diff --git a/classes/BlueChip/Security/Helpers/Plugin.php b/classes/BlueChip/Security/Helpers/Plugin.php index 835aec4..e5eed25 100644 --- a/classes/BlueChip/Security/Helpers/Plugin.php +++ b/classes/BlueChip/Security/Helpers/Plugin.php @@ -25,7 +25,7 @@ abstract class Plugin /** * @param string $plugin_basename - * @return string URL of the plugin changelog page or empty string, if it cannot be determined. + * @return string URL of the plugin changelog page or empty string if it cannot be determined. */ public static function getChangelogUrl(string $plugin_basename): string { @@ -67,7 +67,7 @@ public static function getChecksumsUrl(string $plugin_basename, array $plugin_da * Get slug (ie. bc-security) for plugin with given basename (ie. bc-security/bc-security.php). * * @param string $plugin_basename - * @return string Plugin slug or empty string, if plugin does not seem to be installed in its own directory. + * @return string Plugin slug or empty string if plugin does not seem to be installed in its own directory. */ public static function getSlug(string $plugin_basename): string { @@ -81,7 +81,7 @@ public static function getSlug(string $plugin_basename): string /** * @param string $plugin_basename - * @return bool True, if there is readme.txt file present in plugin directory, false otherwise. + * @return bool True if there is readme.txt file present in plugin directory, false otherwise. */ public static function hasReadmeTxt(string $plugin_basename): bool { @@ -91,7 +91,7 @@ public static function hasReadmeTxt(string $plugin_basename): bool /** * @param string $plugin_basename - * @return bool True, if directory of given plugin seems to be under version control (Subversion or Git). + * @return bool True if directory of given plugin seems to be under version control (Subversion or Git). */ public static function isVersionControlled(string $plugin_basename): bool { diff --git a/classes/BlueChip/Security/Modules/Checklist/Check.php b/classes/BlueChip/Security/Modules/Checklist/Check.php index 5cdc4b1..1bacf46 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Check.php +++ b/classes/BlueChip/Security/Modules/Checklist/Check.php @@ -80,7 +80,7 @@ public function getName(): string /** - * @return int Timestamp of last run or 0, if no info about last run is available. + * @return int Timestamp of last run or 0 if no info about last run is available. */ public function getTimeOfLastRun(): int { diff --git a/classes/BlueChip/Security/Modules/Checklist/CheckResult.php b/classes/BlueChip/Security/Modules/Checklist/CheckResult.php index 3dc2418..0c0a232 100644 --- a/classes/BlueChip/Security/Modules/Checklist/CheckResult.php +++ b/classes/BlueChip/Security/Modules/Checklist/CheckResult.php @@ -16,7 +16,7 @@ class CheckResult /** - * @param bool|null $status Check result status: false, if check failed; true, if check passed; null for undetermined status. + * @param bool|null $status Check result status: false if check failed; true if check passed; null for undetermined status. * @param array|string $message Human readable message explaining the result - inline HTML tags are allowed/expected. */ public function __construct(?bool $status, $message) @@ -54,7 +54,7 @@ public function getMessageAsPlainText(): string /** - * @return bool|null Check result status: false, if check failed; true, if check passed; null means status is undetermined. + * @return bool|null Check result status: false if check failed; true if check passed; null means status is undetermined. */ public function getStatus(): ?bool { diff --git a/classes/BlueChip/Security/Modules/Checklist/Checks/CoreIntegrity.php b/classes/BlueChip/Security/Modules/Checklist/Checks/CoreIntegrity.php index 7691015..6b5fbf9 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Checks/CoreIntegrity.php +++ b/classes/BlueChip/Security/Modules/Checklist/Checks/CoreIntegrity.php @@ -25,7 +25,7 @@ public function __construct() __('WordPress core files are untouched', 'bc-security'), \sprintf( /* translators: 1: link to Wikipedia article about md5sum, 2: link to checksums file at WordPress.org */ - esc_html__('By comparing %1$s of local core files with %2$s it is possible to determine, if any of core files have been modified or if there are any unknown files in core directories.', 'bc-security'), + esc_html__('By comparing %1$s of local core files with %2$s it is possible to determine whether any of core files have been modified or there are any unknown files in core directories.', 'bc-security'), '' . esc_html__('MD5 checksums', 'bc-security') . '', '' . esc_html__('checksums downloaded from WordPress.org', 'bc-security') . '' ) diff --git a/classes/BlueChip/Security/Modules/Checklist/Checks/NoAccessToPhpFilesInUploadsDirectory.php b/classes/BlueChip/Security/Modules/Checklist/Checks/NoAccessToPhpFilesInUploadsDirectory.php index a29fcaf..4d7546f 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Checks/NoAccessToPhpFilesInUploadsDirectory.php +++ b/classes/BlueChip/Security/Modules/Checklist/Checks/NoAccessToPhpFilesInUploadsDirectory.php @@ -43,7 +43,7 @@ protected function runInternal(): Checklist\CheckResult $url = \substr($result['url'], 0, -3) . 'php'; - // Check, if access to PHP file is forbidden. + // Check if access to PHP file is forbidden. $status = Checklist\Helper::isAccessToUrlForbidden($url, $php_file_message); // Remove temporary PHP file from uploads directory diff --git a/classes/BlueChip/Security/Modules/Checklist/Checks/NoPluginsRemovedFromDirectory.php b/classes/BlueChip/Security/Modules/Checklist/Checks/NoPluginsRemovedFromDirectory.php index 9745946..547eac3 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Checks/NoPluginsRemovedFromDirectory.php +++ b/classes/BlueChip/Security/Modules/Checklist/Checks/NoPluginsRemovedFromDirectory.php @@ -49,15 +49,17 @@ protected function runInternal(): Checklist\CheckResult $list_of_unknown_plugins = Helpers\Plugin::implodeList($problematic_plugins['unknown_plugins'], 'DirectoryURL'); if (!empty($list_of_removed_plugins)) { - $message = \sprintf( - esc_html__('Following plugins seem to have been removed from Plugins Directory: %s', 'bc-security'), - $list_of_removed_plugins - ); + $message = [ + \sprintf( + esc_html__('Following plugins seem to have been removed from Plugins Directory: %s', 'bc-security'), + $list_of_removed_plugins + ), + ]; if (!empty($list_of_unknown_plugins)) { // Also report any plugins that could not be checked, just in case. - $message .= '
'; - $message .= \sprintf( + $message[] = ''; + $message[] = \sprintf( esc_html__('Furthermore, following plugins could not be checked: %s', 'bc-security'), $list_of_unknown_plugins ); diff --git a/classes/BlueChip/Security/Modules/Checklist/Checks/PhpVersionSupported.php b/classes/BlueChip/Security/Modules/Checklist/Checks/PhpVersionSupported.php index 5df5772..f8cd876 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Checks/PhpVersionSupported.php +++ b/classes/BlueChip/Security/Modules/Checklist/Checks/PhpVersionSupported.php @@ -12,7 +12,7 @@ class PhpVersionSupported extends Checklist\BasicCheck private const SUPPORTED_VERSIONS = [ '7.3' => '2021-12-06', '7.4' => '2022-11-28', - '8.0' => '2023-11026', + '8.0' => '2023-11-26', ]; diff --git a/classes/BlueChip/Security/Modules/Checklist/Checks/PluginsIntegrity.php b/classes/BlueChip/Security/Modules/Checklist/Checks/PluginsIntegrity.php index b67df0f..8ab2dea 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Checks/PluginsIntegrity.php +++ b/classes/BlueChip/Security/Modules/Checklist/Checks/PluginsIntegrity.php @@ -20,7 +20,7 @@ public function __construct() __('Plugin files are untouched', 'bc-security'), \sprintf( /* translators: 1: link to Wikipedia article about md5sum, 2: link to Plugins Directory at WordPress.org */ - esc_html__('By comparing %1$s of local plugin files with checksums provided by WordPress.org it is possible to determine, if any of plugin files have been modified or if there are any unknown files in plugin directories. Note that this check works only with plugins installed from %2$s.', 'bc-security'), + esc_html__('By comparing %1$s of local plugin files with checksums provided by WordPress.org it is possible to determine whether any of plugin files have been modified or there are any unknown files in plugin directories. Note that this check works only with plugins installed from %2$s.', 'bc-security'), '' . esc_html__('MD5 checksums', 'bc-security') . '', '' . esc_html__('Plugins Directory', 'bc-security') . '' ) @@ -67,7 +67,7 @@ protected function runInternal(): Checklist\CheckResult // Use checksums to find any unknown files. $unknown_files = Checklist\Helper::scanDirectoryForUnknownFiles($plugin_dir, $plugin_dir, $checksums, true); - // Trigger alert, if any suspicious files have been found. + // Trigger alert if any suspicious files have been found. if (!empty($modified_files) || !empty($unknown_files)) { $checksums_verification_failed[$plugin_basename] = \array_merge( $plugin_data, diff --git a/classes/BlueChip/Security/Modules/Checklist/Helper.php b/classes/BlueChip/Security/Modules/Checklist/Helper.php index 1bcd474..383f733 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Helper.php +++ b/classes/BlueChip/Security/Modules/Checklist/Helper.php @@ -35,11 +35,11 @@ function (string $file): string { /** - * Check, if HTTP request to $url results in 403 forbidden response. + * Check if HTTP request to $url results in 403 forbidden response. * * Method returns: - * - true, if HTTP request to $url returns HTTP status 403. - * - false, if HTTP request to $url returns HTTP status 200 and response body is equal to $body (if given) or 404 + * - true if HTTP request to $url returns HTTP status 403. + * - false if HTTP request to $url returns HTTP status 200 and response body is equal to $body (if given) or 404 * is returned (meaning file does not exist, but access is not forbidden). * - null, in all other cases: especially if HTTP request to $url fails or other HTTP status than 200, 403 or 404 * is returned. Null is also returned for HTTP status 200 if response body is different than $body (if given). @@ -50,12 +50,12 @@ function (string $file): string { */ public static function isAccessToUrlForbidden(string $url, ?string $body = null): ?bool { - // Try to get provided URL. Use HEAD request for simplicity, if response body is of no interest. + // Try to get provided URL. Use HEAD request for simplicity if response body is of no interest. $response = \is_string($body) ? wp_remote_get($url) : wp_remote_head($url); switch (wp_remote_retrieve_response_code($response)) { case 200: - // Status suggests that URL can be accessed, but check response body too, if given. + // Status suggests that URL can be accessed, but check response body too if given. return \is_string($body) ? ((wp_remote_retrieve_body($response) === $body) ? false : null) : false; case 403: // Status suggests that access to URL is forbidden. @@ -93,7 +93,7 @@ public static function checkDirectoryForModifiedFiles(string $path, object $chec // Get absolute file path. $pathname = $path . $filename; - // Check, if file exists (skip non-existing files). + // Check whether file exists (skip non-existing files). if (!\file_exists($pathname)) { continue; } diff --git a/classes/BlueChip/Security/Modules/Checklist/Manager.php b/classes/BlueChip/Security/Modules/Checklist/Manager.php index 29dcfc5..080f5c3 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Manager.php +++ b/classes/BlueChip/Security/Modules/Checklist/Manager.php @@ -78,7 +78,7 @@ public function constructChecks(\wpdb $wpdb, string $google_api_key): array // Display of errors should be off in live environment. Checks\DisplayOfPhpErrorsIsOff::getId() => new Checks\DisplayOfPhpErrorsIsOff(), - // Error log should not be publicly visible, if debugging is on. + // Error log should not be publicly visible if debugging is on. Checks\ErrorLogNotPubliclyAccessible::getId() => new Checks\ErrorLogNotPubliclyAccessible(), // There should be no obvious usernames. diff --git a/classes/BlueChip/Security/Modules/Cron/Job.php b/classes/BlueChip/Security/Modules/Cron/Job.php index e3f1891..7167adc 100644 --- a/classes/BlueChip/Security/Modules/Cron/Job.php +++ b/classes/BlueChip/Security/Modules/Cron/Job.php @@ -48,7 +48,7 @@ public function __construct(string $hook, $time, string $recurrence) /** - * Schedule this cron job, if not scheduled yet. + * Schedule this cron job if not scheduled yet. * * @return bool True if cron job has been activated or was already active, false otherwise. */ @@ -110,7 +110,7 @@ public static function getTimestamp(string $time_string): int // Assume $time_string denotes actual time like '01:02:03'. $time = $time_string; } - // Get time zone from settings. Fall back to UTC, if option is empty. + // Get time zone from settings. Fall back to UTC if option is empty. $time_zone = new \DateTimeZone(get_option('timezone_string') ?: 'UTC'); // Get DateTime object. $date = new \DateTime($time, $time_zone); diff --git a/classes/BlueChip/Security/Modules/Cron/Manager.php b/classes/BlueChip/Security/Modules/Cron/Manager.php index e5353bf..3ebf11f 100644 --- a/classes/BlueChip/Security/Modules/Cron/Manager.php +++ b/classes/BlueChip/Security/Modules/Cron/Manager.php @@ -66,7 +66,7 @@ public function getJob(string $hook): Job /** - * Activate cron job: schedule the job and mark it as permanently active, if scheduling succeeds. + * Activate cron job: schedule the job and mark it as permanently active if scheduling succeeds. * * @param string $hook * @return bool True if cron job has been activated or was active already, false otherwise. @@ -82,7 +82,7 @@ public function activateJob(string $hook): bool /** - * Deactivate cron job: unschedule the job and mark it as permanently inactive, if unscheduling succeeds. + * Deactivate cron job: unschedule the job and mark it as permanently inactive if unscheduling succeeds. * * @param string $hook * @return bool True if cron job has been deactivated or was inactive already, false otherwise. diff --git a/classes/BlueChip/Security/Modules/Hardening/Core.php b/classes/BlueChip/Security/Modules/Hardening/Core.php index 1852c23..e165c8d 100644 --- a/classes/BlueChip/Security/Modules/Hardening/Core.php +++ b/classes/BlueChip/Security/Modules/Hardening/Core.php @@ -72,7 +72,7 @@ public function init() if ($this->settings[Settings::CHECK_PASSWORDS]) { // Check user password on successful login. add_action('wp_login', [$this, 'checkUserPassword'], 10, 2); - // Display warning notice, if pwned password has been detected for current user. + // Display warning notice if pwned password has been detected for current user. add_action('current_screen', [$this, 'displayPasswordPwnedNotice'], 10, 1); } if ($this->settings[Settings::VALIDATE_PASSWORDS]) { @@ -207,7 +207,7 @@ public function filterAuthorQuery(array $query_vars): array * @link https://hackertarget.com/wordpress-user-enumeration/ * * @param array $query_vars - * @return bool True, if `author` key is present and its value is either an array or can be seen as numeric. + * @return bool True if `author` key is present and its value is either an array or can be seen as numeric. */ protected static function smellsLikeAuthorScan(array $query_vars): bool { @@ -261,7 +261,7 @@ public function checkUserPassword(string $username, \WP_User $user) /** - * Display password pwned notice, if user's password is marked as pwned. + * Display password pwned notice if user's password is marked as pwned. * * @action https://developer.wordpress.org/reference/hooks/current_screen/ * diff --git a/classes/BlueChip/Security/Modules/IpBlacklist/AdminPage.php b/classes/BlueChip/Security/Modules/IpBlacklist/AdminPage.php index a0f7d97..8db1148 100644 --- a/classes/BlueChip/Security/Modules/IpBlacklist/AdminPage.php +++ b/classes/BlueChip/Security/Modules/IpBlacklist/AdminPage.php @@ -273,14 +273,14 @@ private function processBlacklistAction() $scope = \filter_input(INPUT_POST, 'scope', FILTER_VALIDATE_INT); $comment = \filter_input(INPUT_POST, 'comment', FILTER_SANITIZE_STRING); - // Check, if input is formally valid. + // Check whether input is formally valid. if (empty($ip_address) || empty($duration_length) || empty($duration_unit) || empty($scope)) { return; } $duration = $duration_length * $duration_unit; - // Check, if input is semantically valid. + // Check whether input is semantically valid. if (($duration <= 0) || !\in_array($scope, [LockScope::ADMIN, LockScope::COMMENTS, LockScope::WEBSITE], true)) { return; } diff --git a/classes/BlueChip/Security/Modules/IpBlacklist/Bouncer.php b/classes/BlueChip/Security/Modules/IpBlacklist/Bouncer.php index 5cee920..e5612f5 100644 --- a/classes/BlueChip/Security/Modules/IpBlacklist/Bouncer.php +++ b/classes/BlueChip/Security/Modules/IpBlacklist/Bouncer.php @@ -6,8 +6,8 @@ /** * Bouncer takes care of bouncing uninvited guests by: - * 1) Blocking access to website, if remote IP address cannot be determined. - * 2) Blocking access to website, if remote IP address is on website blacklist. + * 1) Blocking access to website when remote IP address cannot be determined. + * 2) Blocking access to website when remote IP address is on website blacklist. */ class Bouncer implements \BlueChip\Security\Modules\Initializable, \BlueChip\Security\Modules\Loadable { @@ -38,12 +38,12 @@ public function __construct(string $remote_address, Manager $bl_manager) */ public function load() { - // In case of non-cli context, if remote IP address is invalid, die immediately. + // In case of non-cli context or if remote IP address is invalid, die immediately. if (!Helpers\Is::cli() && empty($this->remote_address)) { self::blockAccessTemporarily(); } - // Check, if access to website is allowed. + // Check if access to website is allowed. add_filter('plugins_loaded', [$this, 'checkAccess'], 1, 0); // Leave priority 0 for site maintainers. } @@ -78,7 +78,7 @@ public static function blockAccessTemporarily(string $ip_address = '') //// Hookers - public methods that should in fact be private /** - * Block access to the website, if remote IP address is locked. + * Block access to the website when remote IP address is locked. */ public function checkAccess() { @@ -89,7 +89,7 @@ public function checkAccess() /** - * Block access to the login, if remote IP address is locked. + * Block access to the login when remote IP address is locked. * * @param \WP_Error|\WP_User $user * @return \WP_Error|\WP_User diff --git a/classes/BlueChip/Security/Modules/IpBlacklist/Manager.php b/classes/BlueChip/Security/Modules/IpBlacklist/Manager.php index ef72f68..22fa33a 100644 --- a/classes/BlueChip/Security/Modules/IpBlacklist/Manager.php +++ b/classes/BlueChip/Security/Modules/IpBlacklist/Manager.php @@ -9,7 +9,7 @@ * Who's on the blacklist, baby? * * Note on blacklist release time with respect to <, =, > comparisons against - * current time: item is locked (lock is active), if release time is in the + * current time: item is locked (lock is active) if release time is in the * future, in other words: release_time > current_time. Otherwise, the item is * not locked (lock is expired). * @@ -17,7 +17,7 @@ * several times because of different scope, but also because of different * reason. Unlike the scope, the reason is not important for actual application * of lock, so practical approach is to use the most restrictive lock (ie. the - * release date that is the most future one), if single IP is locked multiple + * release date that is the most future one) if single IP is locked multiple * times in the same scope. */ class Manager implements Modules\Countable, Modules\Installable, Modules\Initializable, \Countable @@ -166,7 +166,7 @@ public function fetch(int $scope = LockScope::ANY, int $from = 0, int $limit = 2 $query .= \sprintf(" WHERE scope = %d", $scope); } - // Apply order by column, if column name is valid + // Apply order by column if column name is valid if ($order_by && \in_array($order_by, $this->columns, true)) { $query .= " ORDER BY {$order_by}"; if ($order === 'asc') { @@ -215,7 +215,7 @@ public function fetchAll(int $scope = LockScope::ANY): array * * @param string $ip_address IP address to check. * @param int $scope Blacklist scope. - * @return bool True, if IP address is on blacklist with given scope. + * @return bool True if IP address is on blacklist with given scope. */ public function isLocked(string $ip_address, int $scope): bool { @@ -243,7 +243,7 @@ public function isLocked(string $ip_address, int $scope): bool * @param int $scope * @param int $reason * @param string $comment [optional] - * @return bool True, if IP address has been locked, false otherwise. + * @return bool True if IP address has been locked, false otherwise. */ public function lock(string $ip_address, int $duration, int $scope, int $reason, string $comment = ''): bool { @@ -302,7 +302,7 @@ public function prune(): bool * Remove record with primary key $id. * * @param int $id - * @return bool True, if record with $id has been removed, false otherwise. + * @return bool True if record with $id has been removed, false otherwise. */ public function remove(int $id): bool { @@ -344,7 +344,7 @@ public function removeMany(array $ids): int * @todo Only unlock really active locks. * * @param int $id - * @return bool True, if record with $id has been unlocked, false otherwise. + * @return bool True if record with $id has been unlocked, false otherwise. */ public function unlock(int $id): bool { @@ -396,7 +396,7 @@ public function unlockMany(array $ids): int * @param string $ip_address IP address to check. * @param int $scope * @param int $reason - * @return int|null Record ID or null, if no record with given $ip_address, $scope and ban $reason exists. + * @return int|null Record ID or null if no record with given $ip_address, $scope and ban $reason exists. */ protected function getId(string $ip_address, int $scope, int $reason): ?int { diff --git a/classes/BlueChip/Security/Modules/Log/Logger.php b/classes/BlueChip/Security/Modules/Log/Logger.php index 80bf98d..f1acd0a 100644 --- a/classes/BlueChip/Security/Modules/Log/Logger.php +++ b/classes/BlueChip/Security/Modules/Log/Logger.php @@ -185,7 +185,7 @@ public function logEvent(Event $event) * Return integer code for given log level. * * @param string $level Log level constant: emergency, alert, critical, error, warning, notice, info or debug. - * @return int|null Integer code for given log level or null, if unknown level given. + * @return int|null Integer code for given log level or null if unknown level given. */ public function translateLogLevel(string $level): ?int { @@ -301,7 +301,7 @@ public function fetch(?string $event = null, int $from = 0, int $limit = 20, str $query .= $this->wpdb->prepare(" WHERE event = %s", $event); } - // Apply order by column, if column name is valid. + // Apply order by column if column name is valid. if ($order_by && \in_array($order_by, $this->columns, true)) { $query .= " ORDER BY {$order_by}"; if ($order === 'asc') { @@ -376,7 +376,7 @@ public function pruneBySize(): bool { $max_size = $this->settings->getMaxSize(); - // First check, if pruning makes sense at all. + // First check if pruning makes sense at all. if ($this->countAll() <= $max_size) { return true; } diff --git a/classes/BlueChip/Security/Modules/Login/Gatekeeper.php b/classes/BlueChip/Security/Modules/Login/Gatekeeper.php index 0e5daf3..efadf31 100644 --- a/classes/BlueChip/Security/Modules/Login/Gatekeeper.php +++ b/classes/BlueChip/Security/Modules/Login/Gatekeeper.php @@ -141,7 +141,7 @@ public function handleFailedLogin(string $username) // Record failed login attempt, get total number of retries for IP $retries = $this->bookkeeper->recordFailedLoginAttempt($this->remote_address, $username); - // Determine, if it is the lockout time: + // Determine whether it is the lockout time: if ($retries % $this->settings[Settings::LONG_LOCKOUT_AFTER] === 0) { // Long lockout $this->lockOut($username, $this->settings->getLongLockoutDuration(), IpBlacklist\BanReason::LOGIN_LOCKOUT_LONG); @@ -153,7 +153,7 @@ public function handleFailedLogin(string $username) /** - * Lock IP out and die with 503 error, if non-existing $username has been + * Lock IP out and die with 503 error if non-existing $username has been * used to log in and is present on username blacklist. * * Filter is called from wp_authenticate(). @@ -200,7 +200,7 @@ public function muteStandardErrorMessages($user) /** - * Remove all WordPress authentication cookies, if IP is on black list. + * Remove all WordPress authentication cookies if IP is on black list. * Method should be called as early as possible. */ public function removeAuthCookieIfIpIsLocked() diff --git a/classes/BlueChip/Security/Modules/Notifications/Mailman.php b/classes/BlueChip/Security/Modules/Notifications/Mailman.php index 80f6669..8e44fa7 100644 --- a/classes/BlueChip/Security/Modules/Notifications/Mailman.php +++ b/classes/BlueChip/Security/Modules/Notifications/Mailman.php @@ -19,7 +19,7 @@ abstract class Mailman * @param array|string $to Email address(es) of notification recipient(s). * @param string $subject Subject of notification. * @param array|string $message Body of notification. - * @return bool True, if notification has been sent successfully, false otherwise. + * @return bool True if notification has been sent successfully, false otherwise. */ public static function send($to, string $subject, $message): bool { diff --git a/classes/BlueChip/Security/Modules/Notifications/Watchman.php b/classes/BlueChip/Security/Modules/Notifications/Watchman.php index 1b599df..49b37c8 100644 --- a/classes/BlueChip/Security/Modules/Notifications/Watchman.php +++ b/classes/BlueChip/Security/Modules/Notifications/Watchman.php @@ -54,7 +54,7 @@ public function __construct(Settings $settings, string $remote_address, Logger $ /** - * @return bool True, if notifications are muted via `BC_SECURITY_MUTE_NOTIFICATIONS` constant, false otherwise. + * @return bool True if notifications are muted via `BC_SECURITY_MUTE_NOTIFICATIONS` constant, false otherwise. */ public static function isMuted(): bool { @@ -63,7 +63,7 @@ public static function isMuted(): bool /** - * Format remote IP address - append result of reverse DNS lookup, if successful. + * Format remote IP address - append result of reverse DNS lookup if successful. * * @param string $remote_address * @return string @@ -84,7 +84,7 @@ private static function formatRemoteAddress(string $remote_address): string */ public function init() { - // Bail early, if no recipients are set or we are explicitly ordered to not disturb. + // Bail early if no recipients are set or we are explicitly ordered to not disturb. if (empty($this->recipients) || self::isMuted()) { return; } @@ -122,7 +122,7 @@ public function activate() */ public function deactivate() { - // Bail early, if no recipients are set. + // Bail early if no recipients are set. if (empty($this->recipients)) { return; } @@ -158,7 +158,7 @@ public function deactivate() */ public function watchCoreUpdateAvailable($update_transient) { - // Check, if update transient has the data we are interested in. + // Check if update transient has the data we are interested in. if (!isset($update_transient->updates) || !\is_array($update_transient->updates) || empty($update_transient->updates)) { return; } @@ -202,7 +202,7 @@ public function watchCoreUpdateAvailable($update_transient) */ public function watchPluginUpdatesAvailable($update_transient) { - // Check, if update transient has the data we are interested in. + // Check if update transient has the data we are interested in. if (!isset($update_transient->response) || !\is_array($update_transient->response)) { return; } @@ -259,7 +259,7 @@ public function watchPluginUpdatesAvailable($update_transient) */ public function watchThemeUpdatesAvailable($update_transient) { - // Check, if update transient has the data we are interested in. + // Check if update transient has the data we are interested in. if (!isset($update_transient->response) || !\is_array($update_transient->response)) { return; } @@ -388,7 +388,7 @@ public function watchChecklistMultipleChecksAlert(array $issues) * * @param string $subject * @param array|string $message - * @return bool|null Null, if there are no recipients configured. True, if email has been sent, false otherwise. + * @return bool|null Null if there are no recipients configured. True if email has been sent, false otherwise. */ private function notify(string $subject, $message): ?bool { diff --git a/classes/BlueChip/Security/Setup/IpAddress.php b/classes/BlueChip/Security/Setup/IpAddress.php index ae1a4c1..fb4521f 100644 --- a/classes/BlueChip/Security/Setup/IpAddress.php +++ b/classes/BlueChip/Security/Setup/IpAddress.php @@ -45,7 +45,7 @@ public static function enlist(bool $explain = false): array * Get remote address according to provided $type (with fallback to REMOTE_ADDR). * * @param string $type - * @return string Remote IP or empty string, if remote IP could not been determined. + * @return string Remote IP or empty string if remote IP could not been determined. */ public static function get(string $type): string { @@ -58,7 +58,7 @@ public static function get(string $type): string return self::getFirst($_SERVER[$type]); } - // Not found, try to fall back to direct address, if proxy has been requested. + // Not found: try to fall back to direct address if proxy has been requested. if (($type !== self::REMOTE_ADDR) && isset($_SERVER[self::REMOTE_ADDR])) { // NOTE: Even though we fall back to direct address -- meaning you // can get a mostly working plugin when connection type is not set