Issues (4967)

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/wp-includes/class-wp-simplepie-file.php (4 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
/**
3
 * Feed API: WP_SimplePie_File class
4
 *
5
 * @package WordPress
6
 * @subpackage Feed
7
 * @since 4.7.0
8
 */
9
10
/**
11
 * Core class for fetching remote files and reading local files with SimplePie.
12
 *
13
 * @since 2.8.0
14
 *
15
 * @see SimplePie_File
16
 */
17
class WP_SimplePie_File extends SimplePie_File {
18
19
	/**
20
	 * Constructor.
21
	 *
22
	 * @since 2.8.0
23
	 * @since 3.2.0 Updated to use a PHP5 constructor.
24
	 * @access public
25
	 *
26
	 * @param string       $url             Remote file URL.
27
	 * @param integer      $timeout         Optional. How long the connection should stay open in seconds.
28
	 *                                      Default 10.
29
	 * @param integer      $redirects       Optional. The number of allowed redirects. Default 5.
30
	 * @param string|array $headers         Optional. Array or string of headers to send with the request.
0 ignored issues
show
Should the type for parameter $headers not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
31
	 *                                      Default null.
32
	 * @param string       $useragent       Optional. User-agent value sent. Default null.
33
	 * @param boolean      $force_fsockopen Optional. Whether to force opening internet or unix domain socket
34
	 *                                      connection or not. Default false.
35
	 */
36
	public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
37
		$this->url = $url;
38
		$this->timeout = $timeout;
0 ignored issues
show
The property timeout does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
39
		$this->redirects = $redirects;
40
		$this->headers = $headers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $headers can also be of type string or null. However, the property $headers is declared as type array. 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...
41
		$this->useragent = $useragent;
42
43
		$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
44
45
		if ( preg_match('/^http(s)?:\/\//i', $url) ) {
46
			$args = array(
47
				'timeout' => $this->timeout,
48
				'redirection' => $this->redirects,
49
			);
50
51
			if ( !empty($this->headers) )
52
				$args['headers'] = $this->headers;
53
54
			if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
55
				$args['user-agent'] = $this->useragent;
56
57
			$res = wp_safe_remote_request($url, $args);
58
59
			if ( is_wp_error($res) ) {
60
				$this->error = 'WP HTTP Error: ' . $res->get_error_message();
61
				$this->success = false;
62
			} else {
63
				$this->headers = wp_remote_retrieve_headers( $res );
0 ignored issues
show
Documentation Bug introduced by
It seems like wp_remote_retrieve_headers($res) can also be of type object<Requests_Utility_...eInsensitiveDictionary>. However, the property $headers is declared as type array. 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...
64
				$this->body = wp_remote_retrieve_body( $res );
65
				$this->status_code = wp_remote_retrieve_response_code( $res );
66
			}
67
		} else {
68
			$this->error = '';
69
			$this->success = false;
70
		}
71
	}
72
}
73