Issues (9)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

CurlRequest/CurlRequest.php (1 issue)

1
<?php
2
/**
3
 * Curl request class
4
 *
5
 * @file      CurlRequest.php
6
 *
7
 * PHP version 8.0+
8
 *
9
 * @author    Yancharuk Alexander <alex at itvault dot info>
10
 * @copyright © 2012-2021 Alexander Yancharuk
11
 * @date      2015-01-20 18:12
12
 * @license   The BSD 3-Clause License
13
 *            <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
14
 */
15
16
namespace Veles\CurlRequest;
17
18
use Veles\CurlRequest\AuthStrategies\AuthStrategyInterface;
19
20
/**
21
 * Class CurlRequest
22
 * @author  Yancharuk Alexander <alex at itvault dot info>
23
 */
24
class CurlRequest extends CurlAbstract
25
{
26
	/**
27
	 * Creates cURL handler and sets options
28
	 *
29
	 * @param       $url
30
	 * @param array $options
31
	 */
32 14
	public function __construct($url, array $options = [])
33
	{
34 14
		$this->curl = curl_init();
0 ignored issues
show
Documentation Bug introduced by
It seems like curl_init() can also be of type CurlHandle. However, the property $curl is declared as type resource. 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...
35 14
		$options   += $this->default_options;
36
37 14
		$this->setOption(CURLOPT_URL, $url)
38 14
			->setArrayOptions($options);
39
	}
40
41 1
	public function __destruct()
42
	{
43 1
		curl_close($this->curl);
44
	}
45
46
	/**
47
	 * Executes request and by default returns result as string
48
	 *
49
	 * @return mixed
50
	 */
51 1
	public function exec()
52
	{
53 1
		return curl_exec($this->curl);
54
	}
55
56
	/**
57
	 * Sets additional header for request
58
	 *
59
	 * @param array $headers Array of additional headers
60
	 *
61
	 * @return $this
62
	 */
63 3
	public function setHeaders(array $headers)
64
	{
65 3
		$this->options[CURLOPT_HTTPHEADER] = $headers;
66 3
		curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
67
68 3
		return $this;
69
	}
70
71
	/**
72
	 * Get headers set for prepared request
73
	 *
74
	 * @return array
75
	 */
76 3
	public function getHeaders()
77
	{
78 3
		return isset($this->options[CURLOPT_HTTPHEADER])
79 3
			? $this->options[CURLOPT_HTTPHEADER]
80 3
			: [];
81
	}
82
83
	/**
84
	 * Set curl option
85
	 *
86
	 * @param $option
87
	 * @param $value
88
	 *
89
	 * @return $this
90
	 */
91 14
	public function setOption($option, $value)
92
	{
93 14
		$this->options[$option] = $value;
94 14
		curl_setopt($this->curl, $option, $value);
95
96 14
		return $this;
97
	}
98
99
	/**
100
	 * Sets additional options to curl-request
101
	 *
102
	 * @param array $options
103
	 *
104
	 * @return $this
105
	 */
106 14
	public function setArrayOptions(array $options)
107
	{
108 14
		foreach ($options as $option => $value) {
109 14
			$this->options[$option] = $value;
110
		}
111
112 14
		curl_setopt_array($this->curl, $options);
113
114 14
		return $this;
115
	}
116
117
	/**
118
	 * Set request authentication strategy
119
	 *
120
	 * @param AuthStrategyInterface $auth Authentication strategy
121
	 *
122
	 * @return $this
123
	 */
124 1
	public function setAuth(AuthStrategyInterface $auth)
125
	{
126 1
		$auth->apply($this);
127 1
		$this->auth = $auth;
128
129 1
		return $this;
130
	}
131
}
132