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/Dispatcher/Evaluate.php (1 issue)

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\Dispatcher;
4
use PhpConsole\Connector;
5
use PhpConsole\Dispatcher;
6
use PhpConsole\Dumper;
7
use PhpConsole\EvalProvider;
8
use PhpConsole\EvalResultMessage;
9
10
/**
11
 * Executes client code and sends result data to connector as client expected messages
12
 *
13
 * @package PhpConsole
14
 * @version 3.1
15
 * @link http://consle.com
16
 * @author Sergey Barbushin http://linkedin.com/in/barbushin
17
 * @copyright © Sergey Barbushin, 2011-2013. All rights reserved.
18
 * @license http://www.opensource.org/licenses/BSD-3-Clause "The BSD 3-Clause License"
19
 */
20
class Evaluate extends Dispatcher {
21
22
	/** @var EvalProvider */
23
	protected $evalProvider;
24
25
	/**
26
	 * @param Connector $connector
27
	 * @param EvalProvider $evalProvider
28
	 * @param Dumper $dumper
29
	 */
30 10
	public function __construct(Connector $connector, EvalProvider $evalProvider, Dumper $dumper) {
31 10
		$this->evalProvider = $evalProvider;
32 10
		parent::__construct($connector, $dumper);
33 10
	}
34
35
	/**
36
	 * Override eval provider
37
	 * @param EvalProvider $evalProvider
38
	 */
39 1
	public function setEvalProvider(EvalProvider $evalProvider) {
40 1
		$this->evalProvider = $evalProvider;
41 1
	}
42
43
	/**
44
	 * Get eval provider
45
	 * @return EvalProvider
46
	 */
47 2
	public function getEvalProvider() {
48 2
		return $this->evalProvider;
49
	}
50
51
	/**
52
	 * Execute PHP code and send result message in connector
53
	 * @param $code
54
	 */
55 6
	public function dispatchCode($code) {
56 6
		if($this->isActive()) {
57 5
			$previousLastError = error_get_last();
58 5
			$oldDisplayErrors = ini_set('display_errors', false);
59 5
			$result = $this->evalProvider->evaluate($code);
60 5
			ini_set('display_errors', $oldDisplayErrors);
61
62 5
			$message = new EvalResultMessage();
63 5
			$message->return = $this->dumper->dump($result->return);
64 5
			$message->output = $this->dumper->dump($result->output);
65 5
			$message->time = round($result->time, 6);
66
67 5
			$newLastError = error_get_last();
68 5
			if($newLastError && $newLastError != $previousLastError) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $newLastError of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
69
				$this->connector->getErrorsDispatcher()->dispatchError($newLastError ['type'], $newLastError ['message'], $newLastError ['file'], $newLastError ['line'], 999);
70
			}
71 5
			if($result->exception) {
72 2
				$this->connector->getErrorsDispatcher()->dispatchException($result->exception);
73
			}
74 5
			$this->sendMessage($message);
75
		}
76 6
	}
77
}
78