Issues (4)

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/Api/Requests/RequestsContainer.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
namespace seregazhuk\SmsIntel\Api\Requests;
4
5
use GuzzleHttp\Client;
6
use ReflectionClass;
7
use seregazhuk\SmsIntel\Api\GuzzleHttpClient;
8
use seregazhuk\SmsIntel\Exceptions\WrongRequest;
9
10
/**
11
 * @method send(string|array $phoneNumber, string $from, string $message) To send message to one phone number
12
 * @method getGroups
13
 * @method editGroup
14
 * @method addContact
15
 * @method getContacts
16
 * @method createGroup
17
 * @method getPhoneInfo
18
 * @method requestSource
19
 * @method removeContact
20
 *
21
 * @method cancel(int $smsId) Cancel sms by id
22
 * @method getBalance
23
 * @method checkCoupon
24
 * @method getReportBySms
25
 * @method getReportBySource
26
 * @method getReportByNumber
27
 */
28
class RequestsContainer
29
{
30
    /**
31
     * @var Client
32
     */
33
    protected $http;
34
35
    /**
36
     * @var string
37
     */
38
    protected $login;
39
40
    /**
41
     * @var string
42
     */
43
    protected $password;
44
45
    /**
46
     * @var Request[]
47
     */
48
    protected $requests = [];
49
50
    public function __construct(GuzzleHttpClient $http, $login, $password)
51
    {
52
        $this->http = $http;
0 ignored issues
show
Documentation Bug introduced by
It seems like $http of type object<seregazhuk\SmsIntel\Api\GuzzleHttpClient> is incompatible with the declared type object<GuzzleHttp\Client> of property $http.

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...
53
        $this->login = $login;
54
        $this->password = $password;
55
    }
56
57
    /**
58
     * @return array
59
     */
60
    protected function getRequestsActionsMap()
61
    {
62
        return [
63
            XMLRequest::class  => XMLRequest::$allowedMethods,
64
            JSONRequest::class => JSONRequest::$allowedMethods,
65
        ];
66
    }
67
68
    /**
69
     * Proxies all methods to the appropriate Request object
70
     *
71
     * @param string $method
72
     * @param array $arguments
73
     * @return array
74
     */
75
    public function __call($method, $arguments)
76
    {
77
        $request = $this->resolveRequestByAction($method);
78
79
        return $request->$method(...$arguments);
80
    }
81
82
    /**
83
     * Gets request object by name. If there is no such request
84
     * in requests array, it will try to create it, then save
85
     * it, and then return.
86
     *
87
     * @param string $requestClass
88
     *
89
     * @throws WrongRequest
90
     *
91
     * @return Request
92
     */
93
    public function getRequest($requestClass)
94
    {
95
        // Check if an instance has already been initiated
96
        if (!isset($this->requests[$requestClass])) {
97
            $this->addRequest($requestClass);
98
        }
99
        return $this->requests[$requestClass];
100
    }
101
102
    /**
103
     * @param $action
104
     * @return string
105
     * @throws WrongRequest
106
     */
107
    public function resolveRequestByAction($action)
108
    {
109
        foreach ($this->getRequestsActionsMap() as $requestClass => $actions) {
110
            if(in_array($action, $actions)) {
111
                return $this->getRequest($requestClass);
112
            }
113
        }
114
115
        throw new WrongRequest("Action $action doesn't exist!");
116
    }
117
118
    /**
119
     * Creates request by class name, and if success saves
120
     * it to requests array.
121
     *
122
     * @param string $requestClass
123
     *
124
     * @throws WrongRequest
125
     */
126
    protected function addRequest($requestClass)
127
    {
128
        if (!class_exists($requestClass)) {
129
            throw new WrongRequest("Request $requestClass not found.");
130
        }
131
        $this->requests[$requestClass] = $this->buildRequest($requestClass);
132
    }
133
134
    /**
135
     * Build RequestInterface object with reflection API.
136
     *
137
     * @param string $className
138
     *
139
     * @return object
140
     */
141
    protected function buildRequest($className)
142
    {
143
        return (new ReflectionClass($className))
144
            ->newInstanceArgs([$this->http])
145
            ->setCredentials($this->login, $this->password);
146
    }
147
}
148