Issues (3)

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/AbstractRequest.php (2 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
 * This file is part of :project_name
4
 *
5
 * PHP version 7
6
 *
7
 * @category  PHP
8
 * @package   WilliamEspindola\AbstractHTTPClient
9
 * @author    William Espindola <[email protected]>
10
 * @copyright Free
11
 * @license   MIT
12
 * @link      https://github.com/williamespindola/abstract-http-client
13
 */
14
declare(strict_types=1);
15
16
namespace WilliamEspindola\AbstractHTTPClient;
17
18
use Exception;
19
use InvalidArgumentException;
20
use WilliamEspindola\AbstractHTTPClient\HTTPClient;
21
22
/**
23
 * Abstracts request resources
24
 *
25
 * @category  PHP
26
 * @package   WilliamEspindola\AbstractHTTPClient
27
 * @author    William Espindola <[email protected]>
28
 * @copyright Free
29
 * @license   MIT
30
 * @version   Release: 1.0.0
31
 * @link      https://github.com/williamespindola/abstract-http-client
32
 */
33
abstract class AbstractRequest
34
{
35
    /**
36
     * @var array
37
     */
38
    protected $config;
39
40
    /**
41
     * @var Client $client Cliente implementation
42
     */
43
    protected $client;
44
45
    /**
46
     * @var string $baseUrl Base API URL
47
     */
48
    protected $baseUrl;
49
50
    /**
51
     * @var string $uri String that identifies resource
52
     */
53
    private $uri;
54
55
    /**
56
     * Initializes new AbstractNuxeoIntegration
57
     *
58
     * @param HTTPClient $client HTTPClient implementation
59
     * @param string     $baseUrl    Base API URL
60
     */
61
    public function __construct(HTTPClient $client, string $baseUrl)
62
    {
63
        $this->baseUrl = $baseUrl;
64
65
        $this->client = $client;
0 ignored issues
show
Documentation Bug introduced by
It seems like $client of type object<WilliamEspindola\...tHTTPClient\HTTPClient> is incompatible with the declared type object<WilliamEspindola\...tractHTTPClient\Client> of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
66
    }
67
68
    /**
69
     * Get URI concatenating base url api with resource end point
70
     *
71
     * @return string URI end point
72
     *
73
     * @throws Exception If AbstractRequest::baseUrl or AbstractRequest::uri was empty
74
     */
75
    protected function getURI(): string
76
    {
77
        if (empty($this->baseUrl) || empty($this->uri)) {
78
            throw new Exception('Url or end point can not be null');
79
        }
80
81
        return $this->baseUrl . $this->uri;
82
    }
83
84
    /**
85
     * Set url parameters
86
     *
87
     * @param array $parameters array with parameters that must be setted
88
     *
89
     * <code>
90
     *  $this->setParameters([
91
     *      ':paramkey' => 'my param value'
92
     *  ]);
93
     * </code>
94
     *
95
     * @throws InvalidArgumentException If parameters param was empty
96
     * @throws Exception                If parametes not match with request endPoint
97
     *
98
     * @return void
99
     */
100
    protected function setParameters(array $parameters)
101
    {
102
        if (empty($parameters)) {
103
            throw new InvalidArgumentException('Parameters can not be null');
104
        }
105
106
        $this->uri = null;
107
108
        foreach ($parameters as $key => $param) {
109
            if (preg_match("/{$key}/i", $this->endPoint)) {
110
                if (is_null($this->uri)) {
111
                    $this->uri = $this->endPoint;
0 ignored issues
show
The property endPoint 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...
112
                }
113
114
                $this->uri = str_replace($key, $param, $this->uri);
115
            }
116
        }
117
118
        if (empty($this->uri)) {
119
            throw new Exception(
120
                'Parameters definition not matches with request end point'
121
            );
122
        }
123
    }
124
}
125