Issues (557)

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.

modules/google-maps/gmaps.php (11 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 27 and the first side effect is on line 22.

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
 * WP Google Maps API
4
 *
5
 * @package WP-Google-Maps-API
6
 */
7
8
/*
9
 * Plugin Name: WP Google Maps API
10
 * Plugin URI: https://github.com/wp-api-libraries/wp-google-maps-api
11
 * Description: Perform API requests to Google Maps API.
12
 * Author: WP API Libraries, sgarza
13
 * Version: 1.0.0
14
 * Author URI: https://wp-api-libraries.com
15
 * GitHub Plugin URI: https://github.com/wp-api-libraries/wp-google-maps-api
16
 * GitHub Branch: master
17
 */
18
19
// Exit if accessed directly.
20
if ( ! defined( 'ABSPATH' ) ) { exit; }
21
if ( ! class_exists( 'WPAPI_GOOGLE_MAPS' ) ) {
22
	require_once( 'maps-widget.php' );
23
24
	/**
25
	 * Google Maps Class.
26
	 */
27
	class WPAPI_GOOGLE_MAPS {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
29
		/**
30
		 * API Key.
31
		 *
32
		 * @var string
33
		 */
34
		static private $api_key;
35
36
		/**
37
		 * Output Type.
38
		 *
39
		 * @var string
40
		 */
41
		static private $output;
0 ignored issues
show
The property $output is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
42
43
		/**
44
		 * Map data to be sent to JS.
45
		 *
46
		 * @var [Array]
47
		 */
48
		static private $map_data;
49
50
		/**
51
		 * Default map options.
52
		 *
53
		 * @var [Array]
54
		 */
55
		static public $defaults = array(
56
			'width'	 => '300px',
57
			'height' => '300px',
58
			'lat'		 => '-17.7134',
59
			'lng'		 => '178.0650',
60
			'info'	 => '',
61
			'style'	 => '[]',
62
			'zoom'	 => 14,
63
			'scrollwheel' => 0,
64
		);
65
66
		/**
67
		 * __construct function.
68
		 *
69
		 * @access public
70
		 * @param String $api_key : API Key.
71
		 */
72
		public function __construct( $api_key ) {
73
			static::$api_key = $api_key;
0 ignored issues
show
Since $api_key is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $api_key to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
74
75
			add_action( 'wp_footer', array( $this, 'footer' ),  11 );
76
			add_action( 'widgets_init', array( $this, 'register_widgets' ) );
77
			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
78
			add_shortcode( 'wp_google_maps', array( $this, 'shortcode' ) );
79
		}
80
81
		/**
82
		 * Enqueue JS.
83
		 */
84
		public function enqueue() {
85
			wp_enqueue_script( 'wpapi-google-maps', plugins_url( 'assets/js/google-maps.min.js', REPRO_PLUGIN_FILE ), array( 'jquery' ), null, true );
86
		}
87
88
		/**
89
		 * Handle multiple google maps js api enqueues on the footer.
90
		 */
91
		public function footer() {
92
			wp_localize_script( 'wpapi-google-maps', 'wpapi_gmaps', static::$map_data );
0 ignored issues
show
Since $map_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $map_data to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
93
94
			// Only enqueue google maps API if yoast hasnt enqueued it already.
95
			if ( ! wp_script_is( 'maps-geocoder' ) ) {
96
				wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . static::$api_key, array(), null );
0 ignored issues
show
Since $api_key is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $api_key to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
97
			}
98
		}
99
100
		/**
101
		 * Print dat map.
102
		 *
103
		 * @param  [Mixed] $map_data : Array of map data to send to js.
0 ignored issues
show
The doc-type [Mixed] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
104
		 * @param  [Bool]  $echo     : If html should be returned or echoed, defaults to true.
0 ignored issues
show
The doc-type [Bool] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
105
		 */
106
		public static function print_map( $map_data, $echo = true ) {
107
108
			$map_data = apply_filters( 'wpapi_google_map_data', wp_parse_args( $map_data, static::$defaults ) );
109
			static::$map_data[] = $map_data;
0 ignored issues
show
Since $map_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $map_data to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
110
111
			$index = count( static::$map_data ) - 1;
0 ignored issues
show
Since $map_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $map_data to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
112
113
			$html = '<div id="wpapi-gmap-' . $index . '" style="width:' . esc_attr( $map_data['width'] ) . ';height:' . esc_attr( $map_data['height'] ) . '"></div>';
114
115
			if ( $echo ) {
116
				echo $html;
117
			} else {
118
				return $html;
119
			}
120
		}
121
122
		/**
123
		 * Shortcode for printing a single map.
124
		 *
125
		 * @param  [type] $atts : shortcode attributes.
0 ignored issues
show
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
126
		 */
127
		public function shortcode( $atts ) {
128
			// Set widget info.
129
			$atts = shortcode_atts( static::$defaults, $atts, 'wp_google_maps' );
130
131
			return static::print_map( $atts, false );
132
133
		}
134
135
		/**
136
		 * Register Google maps Widgets.
137
		 *
138
		 * @access public
139
		 * @return void
140
		 */
141
		public function register_widgets() {
142
			register_widget( 'WP_API_MAPS_WIDGET' );
143
		}
144
	}
145
146
}
147