Issues (23)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/admin/system-info.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 15.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * System Info
4
 *
5
 * These are functions
6
 *
7
 * @package     GoogleMapsBuilder
8
 * @subpackage  Admin/System
9
 * @copyright   Copyright (c) 2015, WordImpress
10
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
 */
12
13
// Exit if accessed directly
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
19
/**
20
 * Display the system info tab
21
 *
22
 * @since       1.0
23
 * @return      void
24
 */
25
function gmb_system_info_callback() {
26
27
	if ( ! current_user_can( 'install_plugins' ) ) {
28
		return;
29
	}
30
31
	?>
32
	<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="gmb-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo gmb_tools_sysinfo_get(); ?></textarea>
33
	<p class="submit">
34
		<input type="hidden" name="gmb_action" value="download_sysinfo" />
35
		<?php submit_button( __( 'Download System Info File', 'google-maps-builder' ), 'secondary', 'gmb-download-sysinfo', false ); ?>
36
	</p>
37
	<style>
38
		.gmb_forms_page_gmb-settings .gmb-submit-wrap {
39
			display: none; /* Hide Save settings button on System Info Tab (not needed) */
40
		}
41
	</style>
42
	<?php
43
}
44
45
46
/**
47
 * Get system info
48
 *
49
 * @since       1.0
50
 * @access      public
51
 * @global      object $wpdb        Used to query the database using the WordPress Database API
52
 * @global      array  $gmb_options Array of all Maps Builder options
53
 * @return      string $return A string containing the info to output
54
 */
55
function gmb_tools_sysinfo_get() {
56
	global $wpdb, $gmb_options;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
57
58
	if ( ! class_exists( 'Browser' ) ) {
59
		require_once GMB_PLUGIN_PATH . 'includes/libraries/browser.php';
60
	}
61
62
	$browser = new Browser();
63
64
	// Get theme info
65
	if ( get_bloginfo( 'version' ) < '3.4' ) {
66
		$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
67
		$theme      = $theme_data['Name'] . ' ' . $theme_data['Version'];
68
	} else {
69
		$theme_data = wp_get_theme();
70
		$theme      = $theme_data->Name . ' ' . $theme_data->Version;
71
	}
72
73
	// Try to identify the hosting provider
74
	$host = gmb_get_host();
75
76
	$return = '### Begin System Info ###' . "\n\n";
77
78
	// Start with the basics...
79
	$return .= '-- Site Info' . "\n\n";
80
	$return .= 'Site URL:                 ' . site_url() . "\n";
81
	$return .= 'Home URL:                 ' . home_url() . "\n";
82
	$return .= 'Multisite:                ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
83
84
	$return = apply_filters( 'gmb_sysinfo_after_site_info', $return );
85
86
	// Can we determine the site's host?
87
	if ( $host ) {
88
		$return .= "\n" . '-- Hosting Provider' . "\n\n";
89
		$return .= 'Host:                     ' . $host . "\n";
90
91
		$return = apply_filters( 'gmb_sysinfo_after_host_info', $return );
92
	}
93
94
	// The local users' browser information, handled by the Browser class
95
	$return .= "\n" . '-- User Browser' . "\n\n";
96
	$return .= $browser;
97
98
	$return = apply_filters( 'gmb_sysinfo_after_user_browser', $return );
99
100
	// WordPress configuration
101
	$return .= "\n" . '-- WordPress Configuration' . "\n\n";
102
	$return .= 'Version:                  ' . get_bloginfo( 'version' ) . "\n";
103
	$return .= 'Language:                 ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
104
	$return .= 'Permalink Structure:      ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
105
	$return .= 'Active Theme:             ' . $theme . "\n";
106
	$return .= 'Show On Front:            ' . get_option( 'show_on_front' ) . "\n";
107
108
	// Only show page specs if frontpage is set to 'page'
109
	if ( get_option( 'show_on_front' ) == 'page' ) {
110
		$front_page_id = get_option( 'page_on_front' );
111
		$blog_page_id  = get_option( 'page_for_posts' );
112
113
		$return .= 'Page On Front:            ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
114
		$return .= 'Page For Posts:           ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
115
	}
116
117
	// Make sure wp_remote_post() is working
118
	$request['cmd'] = '_notify-validate';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
119
120
	$params = array(
121
		'sslverify'  => false,
122
		'timeout'    => 60,
123
		'user-agent' => 'Maps Builder/' . GMB_VERSION,
124
		'body'       => $request
125
	);
126
127
	$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
128
129
	if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
130
		$WP_REMOTE_POST = 'wp_remote_post() works';
131
	} else {
132
		$WP_REMOTE_POST = 'wp_remote_post() does not work';
133
	}
134
135
	$return .= 'Remote Post:              ' . $WP_REMOTE_POST . "\n";
136
	$return .= 'Table Prefix:             ' . 'Length: ' . strlen( $wpdb->prefix ) . '   Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
137
	$return .= 'Admin AJAX:               ' . ( gmb_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n";
138
	$return .= 'WP_DEBUG:                 ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
139
	$return .= 'Memory Limit:             ' . WP_MEMORY_LIMIT . "\n";
140
	$return .= 'Registered Post Stati:    ' . implode( ', ', get_post_stati() ) . "\n";
141
142
	$return = apply_filters( 'gmb_sysinfo_after_wordpress_config', $return );
143
144
	// GMB configuration
145
	$return .= "\n" . '-- Maps Builder Configuration' . "\n\n";
146
	$return .= 'Version:                  ' . GMB_VERSION . "\n";
147
	$return .= 'Upgraded From:            ' . get_option( 'gmb_version_upgraded_from', 'None' ) . "\n";
148
149
	$return = apply_filters( 'gmb_sysinfo_after_gmb_config', $return );
150
151
152
	// Must-use plugins
153
	$muplugins = get_mu_plugins();
154
	if ( count( $muplugins > 0 ) ) {
155
		$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
156
157
		foreach ( $muplugins as $plugin => $plugin_data ) {
158
			$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
159
		}
160
161
		$return = apply_filters( 'gmb_sysinfo_after_wordpress_mu_plugins', $return );
162
	}
163
164
	// WordPress active plugins
165
	$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
166
167
	$plugins        = get_plugins();
168
	$active_plugins = get_option( 'active_plugins', array() );
169
170
	foreach ( $plugins as $plugin_path => $plugin ) {
171
		if ( ! in_array( $plugin_path, $active_plugins ) ) {
172
			continue;
173
		}
174
175
		$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
176
	}
177
178
	$return = apply_filters( 'gmb_sysinfo_after_wordpress_plugins', $return );
179
180
	// WordPress inactive plugins
181
	$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
182
183
	foreach ( $plugins as $plugin_path => $plugin ) {
184
		if ( in_array( $plugin_path, $active_plugins ) ) {
185
			continue;
186
		}
187
188
		$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
189
	}
190
191
	$return = apply_filters( 'gmb_sysinfo_after_wordpress_plugins_inactive', $return );
192
193
	if ( is_multisite() ) {
194
		// WordPress Multisite active plugins
195
		$return .= "\n" . '-- Network Active Plugins' . "\n\n";
196
197
		$plugins        = wp_get_active_network_plugins();
198
		$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
199
200
		foreach ( $plugins as $plugin_path ) {
201
			$plugin_base = plugin_basename( $plugin_path );
202
203
			if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
204
				continue;
205
			}
206
207
			$plugin = get_plugin_data( $plugin_path );
208
			$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
209
		}
210
211
		$return = apply_filters( 'gmb_sysinfo_after_wordpress_ms_plugins', $return );
212
	}
213
214
	// Server configuration (really just versioning)
215
	$return .= "\n" . '-- Webserver Configuration' . "\n\n";
216
	$return .= 'PHP Version:              ' . PHP_VERSION . "\n";
217
	$return .= 'MySQL Version:            ' . $wpdb->db_version() . "\n";
218
	$return .= 'Webserver Info:           ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
219
220
	$return = apply_filters( 'gmb_sysinfo_after_webserver_config', $return );
221
222
	// PHP configs... now we're getting to the important stuff
223
	$return .= "\n" . '-- PHP Configuration' . "\n\n";
224
	$return .= 'Safe Mode:                ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
225
	$return .= 'Memory Limit:             ' . ini_get( 'memory_limit' ) . "\n";
226
	$return .= 'Upload Max Size:          ' . ini_get( 'upload_max_filesize' ) . "\n";
227
	$return .= 'Post Max Size:            ' . ini_get( 'post_max_size' ) . "\n";
228
	$return .= 'Upload Max Filesize:      ' . ini_get( 'upload_max_filesize' ) . "\n";
229
	$return .= 'Time Limit:               ' . ini_get( 'max_execution_time' ) . "\n";
230
	$return .= 'Max Input Vars:           ' . ini_get( 'max_input_vars' ) . "\n";
231
	$return .= 'Display Errors:           ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
232
233
	$return = apply_filters( 'gmb_sysinfo_after_php_config', $return );
234
235
	// PHP extensions and such
236
	$return .= "\n" . '-- PHP Extensions' . "\n\n";
237
	$return .= 'cURL:                     ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
238
	$return .= 'fsockopen:                ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
239
	$return .= 'SOAP Client:              ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
240
	$return .= 'Suhosin:                  ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
241
242
	$return = apply_filters( 'gmb_sysinfo_after_php_ext', $return );
243
244
245
	// The rest of this is only relevant is session is enabled
246
	if ( isset( $_SESSION ) ) {
247
		$return .= 'Session Name:             ' . esc_html( ini_get( 'session.name' ) ) . "\n";
248
		$return .= 'Cookie Path:              ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
249
		$return .= 'Save Path:                ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
250
		$return .= 'Use Cookies:              ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
251
		$return .= 'Use Only Cookies:         ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
252
	}
253
254
	$return = apply_filters( 'gmb_sysinfo_after_session_config', $return );
255
256
	$return .= "\n" . '### End System Info ###';
257
258
	return $return;
259
}
260
261
262
/**
263
 * Generates a System Info download file
264
 *
265
 * @since       1.0
266
 * @return      void
267
 */
268
function gmb_tools_sysinfo_download() {
269
270
	if ( ! current_user_can( 'install_plugins' ) ) {
271
		return;
272
	}
273
274
	nocache_headers();
275
276
	header( 'Content-Type: text/plain' );
277
	header( 'Content-Disposition: attachment; filename="gmb-system-info.txt"' );
278
279
	echo wp_strip_all_tags( $_POST['gmb-sysinfo'] );
280
	gmb_die();
281
}
282
283
add_action( 'gmb_download_sysinfo', 'gmb_tools_sysinfo_download' );