true ]; try { // Scan for high privilege roles array_push( $issues, ...self::_scan_for_high_privilege_roles(self::_read_role_key_option()) ); } catch (Exception $e) { array_push($issues, self::_format_issue(sprintf( __('Unexpected application error: %s', AAM_KEY), $e->getMessage() ), 'APPLICATION_ERROR', 'error')); } if (count($issues) > 0) { $response['issues'] = $issues; } // Determine final status for the check self::_determine_check_status($response); return $response; } /** * Scan for high-privilege roles that are not whitelisted * * @param array $db_roles * * @return array * * @access private * @static * * @version 7.0.0 */ private static function _scan_for_high_privilege_roles($db_roles) { $response = []; foreach($db_roles as $role_id => $role) { if (!in_array($role_id, self::WHITELISTED_ROLES)) { $assigned_caps = array_keys( array_filter($role['capabilities'], function($v) { return !empty($v); }) ); $matched = array_intersect($assigned_caps, self::HIGH_PRIVILEGE_CAPS); if (!empty($matched)) { array_push($response, self::_format_issue(sprintf( __('Detected high-privilege role "%s" with capabilities: %s', AAM_KEY), translate_user_role( !empty($role['name']) ? $role['name'] : $role_id ), implode(', ', $matched) ), 'HIGH_PRIVILEGE_ROLE_CAPS', 'critical')); } } } return $response; } }