Issues (36)

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.

src/Response/Error.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
2
namespace Cassandra\Response;
3
use Cassandra\Protocol\Frame;
4
5
class Error extends Response {
6
	const SERVER_ERROR = 0x0000;
7
	const PROTOCOL_ERROR = 0x000A;
8
	const BAD_CREDENTIALS = 0x0100;
9
	const UNAVAILABLE_EXCEPTION = 0x1000;
10
	const OVERLOADED = 0x1001;
11
	const IS_BOOTSTRAPPING = 0x1002;
12
	const TRUNCATE_ERROR = 0x1003;
13
	const WRITE_TIMEOUT = 0x1100;
14
	const READ_TIMEOUT = 0x1200;
15
	const SYNTAX_ERROR = 0x2000;
16
	const UNAUTHORIZED = 0x2100;
17
	const INVALID = 0x2200;
18
	const CONFIG_ERROR = 0x2300;
19
	const ALREADY_EXIST = 0x2400;
20
	const UNPREPARED = 0x2500;
21
	
22
	/**
23
	 * Indicates an error processing a request. The body of the message will be an
24
	 * error code ([int]) followed by a [string] error message. Then, depending on
25
	 * the exception, more content may follow. The error codes are defined in
26
	 * Section 7, along with their additional content if any.
27
	 *
28
	 * @return array
29
	 */
30
	public function getData() {
31
		$this->_stream->offset(0);
32
		$data = [];
33
		$data['code'] = $this->_stream->readInt();
34
35
		switch($data['code']){
36
			case self::SERVER_ERROR:
37
				$data['message'] = "Server error: " . $this->_stream->readString();
38
				break;
39
40
			case self::PROTOCOL_ERROR:
41
				$data['message'] = "Protocol error: " . $this->_stream->readString();
42
				break;
43
44
			case self::BAD_CREDENTIALS:
45
				$data['message'] = "Bad credentials: " . $this->_stream->readString();
46
				break;
47
48 View Code Duplication
			case self::UNAVAILABLE_EXCEPTION:
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
				$data['message'] = "Unavailable exception. Error data: " . var_export([
50
                        'error'=>$this->_stream->readString(),
51
                        'consistency' => $this->_stream->readShort(),
52
                        'node' => $this->_stream->readInt(),
53
						'replica' => $this->_stream->readInt()
54
					], true);
55
				break;
56
57
			case self::OVERLOADED:
58
				$data['message'] = "Overloaded: " . $this->_stream->readString();
59
				break;
60
61
			case self::IS_BOOTSTRAPPING:
62
				$data['message'] = "Is_bootstrapping: " . $this->_stream->readString();
63
				break;
64
65
			case self::TRUNCATE_ERROR:
66
				$data['message'] = "Truncate_error: " . $this->_stream->readString();
67
				break;
68
69 View Code Duplication
			case self::WRITE_TIMEOUT:
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
				$data['message'] = "Write_timeout. Error data: " . var_export([
71
                        'error'=>$this->_stream->readString(),
72
                        'consistency' => $this->_stream->readShort(),
73
						'node' => $this->_stream->readInt(),
74
						'replica' => $this->_stream->readInt(),
75
						'writeType' => $this->_stream->readString()
76
					], true);
77
				break;
78
79 View Code Duplication
			case self::READ_TIMEOUT:
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
				$data['message'] = "Read_timeout. Error data: " . var_export([
81
                        'error'=>$this->_stream->readString(),
82
                        'consistency' => $this->_stream->readShort(),
83
						'node' => $this->_stream->readInt(),
84
						'replica' => $this->_stream->readInt(),
85
						'dataPresent' => $this->_stream->readChar()
86
					], true);
87
				break;
88
89
			case self::SYNTAX_ERROR:
90
				$data['message'] = "Syntax_error: " . $this->_stream->readString();
91
				break;
92
93
			case self::UNAUTHORIZED:
94
				$data['message'] = "Unauthorized: " . $this->_stream->readString();
95
				break;
96
97
			case self::INVALID:
98
				$data['message'] = "Invalid: " . $this->_stream->readString();
99
				break;
100
101
			case self::CONFIG_ERROR:
102
				$data['message'] = "Config_error: " . $this->_stream->readString();
103
				break;
104
105
			case self::ALREADY_EXIST:
106
				$data['message'] = "Already_exists: " . $this->_stream->readString();
107
				break;
108
109
			case self::UNPREPARED:
110
				$data['message'] = "Unprepared: " . $this->_stream->readShort();
111
				break;
112
113
			default:
114
				$data['message'] = 'Unknown error';
115
		}
116
		
117
		return $data;
118
	}
119
	
120
	/**
121
	 * 
122
	 * @return Exception
123
	 */
124
	public function getException(){
125
		$data = $this->getData();
126
		return new Exception($data['message'], $data['code']);
127
	}
128
}
129