Issues (30)

Security Analysis    not enabled

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.

src/PhpConsole/Helper.php (1 issue)

Labels
Severity

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
2
3
namespace PhpConsole {
4
5
	/**
6
	 * Makes more easy access to debug dispatcher method.
7
	 *
8
	 * Usage:
9
	 * 1. Call \PhpConsole\Helper::register();
10
	 * 2. Call PC::debug($sql, 'db') or PC::db($sql)
11
	 *
12
	 * It will be the same as calling Handler::getInstance()->debug($var, 'db')
13
	 *
14
	 * @package PhpConsole
15
	 * @version 3.1
16
	 * @link http://consle.com
17
	 * @author Sergey Barbushin http://linkedin.com/in/barbushin
18
	 * @copyright © Sergey Barbushin, 2011-2013. All rights reserved.
19
	 * @license http://www.opensource.org/licenses/BSD-3-Clause "The BSD 3-Clause License"
20
	 */
21
	class Helper {
22
23
		/** @var Connector|null */
24
		private static $connector;
25
		/** @var Handler|null */
26
		private static $handler;
27
		/** @var  bool */
28
		protected static $isActive;
29
30
		private function __construct() {
31
		}
32
33
		/**
34
		 * This method must be called to make class "PC" available
35
		 * @param Connector|null $connector
36
		 * @param Handler|null $handler
37
		 * @throws \Exception
38
		 * @return Connector
39
		 */
40 9
		public static function register(Connector $connector = null, Handler $handler = null) {
41 9
			if(static::$connector) {
0 ignored issues
show
Since $connector is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $connector 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...
42 1
				throw new \Exception('Helper already registered');
43
			}
44 9
			self::$handler = $handler;
45 9
			self::$connector = $connector ? : Connector::getInstance();
46 9
			self::$isActive = self::$connector->isActiveClient();
47 9
			return self::$connector;
48
		}
49
50
		/**
51
		 * Check if method Helper::register() was called before
52
		 * @return bool
53
		 */
54 2
		public static function isRegistered() {
55 2
			return isset(self::$connector);
56
		}
57
58
		/**
59
		 * Get actual helper connector instance
60
		 * @return Connector
61
		 * @throws \Exception
62
		 */
63 3
		public static function getConnector() {
64 3
			if(!self::$connector) {
65 1
				throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()');
66
			}
67 2
			return self::$connector;
68
		}
69
70
		/**
71
		 * Get actual handler instance
72
		 * @return Handler
73
		 * @throws \Exception
74
		 */
75 3
		public static function getHandler() {
76 3
			if(!self::$connector) {
77 1
				throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()');
78
			}
79 2
			if(!self::$handler) {
80 1
				self::$handler = Handler::getInstance();
81
			}
82 2
			return self::$handler;
83
		}
84
85
		/**
86
		 * Analog of Handler::getInstance()->debug(...) method
87
		 * @param mixed $data
88
		 * @param string|null $tags Tags separated by dot, e.g. "low.db.billing"
89
		 * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore
90
		 */
91 3
		public static function debug($data, $tags = null, $ignoreTraceCalls = 0) {
92 3
			if(self::$isActive) {
93 2
				self::$connector->getDebugDispatcher()->dispatchDebug($data, $tags, is_numeric($ignoreTraceCalls) ? $ignoreTraceCalls + 1 : $ignoreTraceCalls);
94
			}
95 3
		}
96
97
		/**
98
		 * Short access to analog of Handler::getInstance()->debug(...) method
99
		 * You can access it like PC::tagName($debugData, $additionalTags = null)
100
		 * @param string $tags
101
		 * @param $args
102
		 */
103 1
		public static function __callStatic($tags, $args) {
104 1
			if(isset($args[1])) {
105
				$tags .= '.' . $args[1];
106
			}
107 1
			static::debug(isset($args[0]) ? $args[0] : null, $tags, 1);
108 1
		}
109
	}
110
}
111
112
namespace {
113
114
	use PhpConsole\Helper;
115
116 1
	if(!class_exists('PC', false)) {
117
		/**
118
		 * Helper short class name in global namespace
119
		 */
120
		class PC extends Helper {
121
122
		}
123
	}
124
}
125