Issues (27)

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/firebaseStub.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
namespace Firebase;
3
4
require_once __DIR__ . '/firebaseInterface.php';
5
6
/**
7
 * Class FirebaseStub
8
 *
9
 * Stubs the Firebase interface without issuing any cURL requests.
10
 *
11
 * @package Firebase
12
 */
13
class FirebaseStub implements FirebaseInterface
14
{
15
    /**
16
     * @var null|string
17
     */
18
    private $_response = null;
19
20
    /**
21
     * @var
22
     */
23
    public $_baseURI;
24
25
    /**
26
     * @var
27
     */
28
    public $_token;
29
30
    /**
31
     * @param string $baseURI
32
     * @param string $token
33
     */
34
    function __construct($baseURI = '', $token = '')
35
    {
36
        if (!extension_loaded('curl')) {
37
            trigger_error('Extension CURL is not loaded.', E_USER_ERROR);
38
        }
39
40
        $this->setBaseURI($baseURI);
41
        $this->setTimeOut(10);
42
        $this->setToken($token);
43
    }
44
45
    /**
46
     * @param string $token
47
     * @return null
48
     */
49
    public function setToken($token)
50
    {
51
        $this->_token = $token;
52
    }
53
54
    /**
55
     * @param string $baseURI
56
     * @return null
57
     */
58
    public function setBaseURI($baseURI)
59
    {
60
        $baseURI .= (substr($baseURI, -1) == '/' ? '' : '/');
61
        $this->_baseURI = $baseURI;
62
    }
63
64
    /**
65
     * @param integer $seconds
66
     * @return null
67
     */
68
    public function setTimeOut($seconds)
69
    {
70
        $this->_timeout = $seconds;
71
    }
72
73
    /**
74
     * @param string $path
75
     * @param string|null $data
76
     * @param $options
77
     * @return null
78
     */
79
    public function set($path, $data, $options = array())
80
    {
81
        return $this->_getSetResponse($data);
82
    }
83
84
    /**
85
     * @param string $path
86
     * @param string $data
87
     * @param $options
88
     * @return null
89
     */
90
    public function push($path, $data, $options = array())
91
    {
92
        return $this->set($path, $data);
93
    }
94
95
    /**
96
     * @param string $path
97
     * @param string $data
98
     * @param $options
99
     * @return null
100
     */
101
    public function update($path, $data, $options = array())
102
    {
103
        return $this->set($path, $data);
104
    }
105
106
    /**
107
     * @param $path
108
     * @param $options
109
     * @return null
110
     */
111
    public function get($path, $options = array())
112
    {
113
        return $this->_getGetResponse();
114
    }
115
116
    /**
117
     * @param string $path
118
     * @param $options
119
     * @return null
120
     */
121
    public function delete($path, $options = array())
122
    {
123
        return $this->_getDeleteResponse();
124
    }
125
126
    /**
127
     * @param string $expectedResponse
128
     */
129
    public function setResponse($expectedResponse)
130
    {
131
        $this->_response = $expectedResponse;
132
    }
133
134
    /**
135
     * @uses $this->_baseURI
136
     * @return Error
137
     */
138
    private function _isBaseURIValid()
139
    {
140
        $error = preg_match('/^https:\/\//', $this->_baseURI);
141
        return new Error(($error == 0 ? true : false), 'Firebase does not support non-ssl traffic. Please try your request again over https.');
142
    }
143
144
    /**
145
     * @param $data
146
     * @return Error
147
     */
148
    private function _isDataValid($data)
149
    {
150
        if ($data == "" || $data == null) {
151
            return new Error(true, "Missing data; Perhaps you forgot to send the data.");
152
        }
153
        $error = json_decode($data);
154
        return new Error(($error !== null ? false : true), "Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names.");
155
    }
156
157
    /**
158
     * @param string|null $data
159
     * @return null
160
     */
161
    private function _getSetResponse($data)
162
    {
163
        $validBaseUriObject = $this->_isBaseURIValid();
164
        if ($validBaseUriObject->error) {
165
            return $validBaseUriObject->message;
166
        }
167
168
        $validDataObject = $this->_isDataValid($data);
169
        if ($validDataObject->error) {
170
            return $validDataObject->message;
171
        }
172
173
        return $this->_response;
174
    }
175
176
    /**
177
     * @return null
178
     */
179
    private function _getGetResponse()
180
    {
181
        $validBaseUriObject = $this->_isBaseURIValid();
182
        if ($validBaseUriObject->error) {
183
            return $validBaseUriObject->message;
184
        }
185
        return $this->_response;
186
    }
187
188
    /**
189
     * @return null
190
     */
191
    private function _getDeleteResponse()
192
    {
193
        return $this->_getGetResponse();
194
    }
195
}
196
197
/**
198
 * Class Error
199
 *
200
 * @package Firebase
201
 */
202
class Error
203
{
204
    /**
205
     * @param boolean $error
206
     * @param string $message
207
     */
208
    function __construct($error, $message)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
209
    {
210
        $this->error = $error;
211
        $this->message = $message;
212
    }
213
}
214