Issues (2010)

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.

wp-includes/class-wp-http-response.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
 * HTTP API: WP_HTTP_Response class
4
 *
5
 * @package WordPress
6
 * @subpackage HTTP
7
 * @since 4.4.0
8
 */
9
10
/**
11
 * Core class used to prepare HTTP responses.
12
 *
13
 * @since 4.4.0
14
 */
15
class WP_HTTP_Response {
16
17
	/**
18
	 * Response data.
19
	 *
20
	 * @since 4.4.0
21
	 * @access public
22
	 * @var mixed
23
	 */
24
	public $data;
25
26
	/**
27
	 * Response headers.
28
	 *
29
	 * @since 4.4.0
30
	 * @access public
31
	 * @var array
32
	 */
33
	public $headers;
34
35
	/**
36
	 * Response status.
37
	 *
38
	 * @since 4.4.0
39
	 * @access public
40
	 * @var int
41
	 */
42
	public $status;
43
44
	/**
45
	 * Constructor.
46
	 *
47
	 * @since 4.4.0
48
	 * @access public
49
	 *
50
	 * @param mixed $data    Response data. Default null.
51
	 * @param int   $status  Optional. HTTP status code. Default 200.
52
	 * @param array $headers Optional. HTTP header map. Default empty array.
53
	 */
54
	public function __construct( $data = null, $status = 200, $headers = array() ) {
55
		$this->data = $data;
56
		$this->set_status( $status );
57
		$this->set_headers( $headers );
58
	}
59
60
	/**
61
	 * Retrieves headers associated with the response.
62
	 *
63
	 * @since 4.4.0
64
	 * @access public
65
	 *
66
	 * @return array Map of header name to header value.
67
	 */
68
	public function get_headers() {
69
		return $this->headers;
70
	}
71
72
	/**
73
	 * Sets all header values.
74
	 *
75
	 * @since 4.4.0
76
	 * @access public
77
	 *
78
	 * @param array $headers Map of header name to header value.
79
	 */
80
	public function set_headers( $headers ) {
81
		$this->headers = $headers;
82
	}
83
84
	/**
85
	 * Sets a single HTTP header.
86
	 *
87
	 * @since 4.4.0
88
	 * @access public
89
	 *
90
	 * @param string $key     Header name.
91
	 * @param string $value   Header value.
92
	 * @param bool   $replace Optional. Whether to replace an existing header of the same name.
93
	 *                        Default true.
94
	 */
95
	public function header( $key, $value, $replace = true ) {
96
		if ( $replace || ! isset( $this->headers[ $key ] ) ) {
97
			$this->headers[ $key ] = $value;
98
		} else {
99
			$this->headers[ $key ] .= ', ' . $value;
100
		}
101
	}
102
103
	/**
104
	 * Retrieves the HTTP return code for the response.
105
	 *
106
	 * @since 4.4.0
107
	 * @access public
108
	 *
109
	 * @return int The 3-digit HTTP status code.
110
	 */
111
	public function get_status() {
112
		return $this->status;
113
	}
114
115
	/**
116
	 * Sets the 3-digit HTTP status code.
117
	 *
118
	 * @since 4.4.0
119
	 * @access public
120
	 *
121
	 * @param int $code HTTP status.
122
	 */
123
	public function set_status( $code ) {
124
		$this->status = absint( $code );
0 ignored issues
show
Documentation Bug introduced by
It seems like absint($code) can also be of type double. However, the property $status is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
125
	}
126
127
	/**
128
	 * Retrieves the response data.
129
	 *
130
	 * @since 4.4.0
131
	 * @access public
132
	 *
133
	 * @return mixed Response data.
134
	 */
135
	public function get_data() {
136
		return $this->data;
137
	}
138
139
	/**
140
	 * Sets the response data.
141
	 *
142
	 * @since 4.4.0
143
	 * @access public
144
	 *
145
	 * @param mixed $data Response data.
146
	 */
147
	public function set_data( $data ) {
148
		$this->data = $data;
149
	}
150
151
	/**
152
	 * Retrieves the response data for JSON serialization.
153
	 *
154
	 * It is expected that in most implementations, this will return the same as get_data(),
155
	 * however this may be different if you want to do custom JSON data handling.
156
	 *
157
	 * @since 4.4.0
158
	 * @access public
159
	 *
160
	 * @return mixed Any JSON-serializable value.
161
	 */
162
	public function jsonSerialize() {
163
		return $this->get_data();
164
	}
165
}
166