Issues (6)

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/Request.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
/*
4
 * This file is part of the Bouncer package.
5
 *
6
 * (c) François Hodierne <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bouncer;
13
14
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest;
15
16
class Request extends HttpFoundationRequest
17
{
18
19
    protected $addr;
20
21
    protected $protocol;
22
23
    protected $body;
24
25
    protected $connection;
26
27
    public function getUserAgent()
28
    {
29
        $userAgent = $this->getHeader('User-Agent');
30
        return $userAgent ? $userAgent : '';
31
    }
32
33
    public function getHeader($name)
34
    {
35
        return $this->headers->get($name);
36
    }
37
38
    public function getAllHeaders($ignore = array())
39
    {
40
        $headers = array();
41
        foreach ($this->headers->all() as $name => $value) {
42
            if (empty($ignore) || !in_array($name, $ignore)) {
43
                $headers[$name] = $this->headers->get($name);
44
            }
45
        }
46
        return $headers;
47
    }
48
49
    public function getHeaders()
50
    {
51
        $ignore = array('host', 'cookie', 'connection');
52
53
        $headers = $this->getAllHeaders($ignore);
54
55
        $connection = $this->getConnection();
56
        if (isset($connection)) {
57
            $headers['connection'] = $connection;
58
        }
59
60
        return $headers;
61
    }
62
63
    public function getCookie($name)
64
    {
65
        return $this->cookies->get($name);
66
    }
67
68
    public function getCookies($names = array())
69
    {
70
        $cookies = array();
71
        foreach ($this->cookies->all() as $name => $value) {
72
            if (in_array($name, $names)) {
73
                $cookies[$name] = $this->cookies->get($name);
74
            }
75
        }
76
        return $cookies;
77
    }
78
79
    public function getAddr()
80
    {
81
        if ($this->addr) {
82
            return $this->addr;
83
        }
84
85
        return $this->getClientIp();
86
    }
87
88
    public function setAddr($addr)
89
    {
90
        $this->addr = $addr;
91
92
        return $this;
93
    }
94
95
    /*
96
     * @return string|null
97
     */
98
    public function getProtocol()
99
    {
100
        if ($this->protocol) {
101
            return $this->protocol;
102
        }
103
104
        return $this->server->get('SERVER_PROTOCOL');
105
    }
106
107
    /*
108
     * @param string
109
     */
110
    public function setProtocol($protocol)
111
    {
112
        $this->protocol = $protocol;
113
114
        return $this;
115
    }
116
117
    /*
118
     * @return string|null
119
     */
120
    public function getConnection()
121
    {
122
        if ($this->connection) {
123
            return $this->connection;
124
        }
125
126
        return $this->headers->get('connection');
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->headers->get('connection'); of type string|array adds the type array to the return on line 126 which is incompatible with the return type documented by Bouncer\Request::getConnection of type string|null.
Loading history...
127
    }
128
129
    /*
130
     * @param string
131
     */
132
    public function setConnection($connection)
133
    {
134
        $this->connection = $connection;
135
136
        return $this;
137
    }
138
139
    /*
140
     * @return string|null
141
     */
142
    public function getBody()
143
    {
144
        if ($this->body) {
145
            return $this->body;
146
        }
147
    }
148
149
    /*
150
     * @param string
151
     */
152
    public function setBody($body)
153
    {
154
        $this->body = $body;
155
156
        return $this;
157
    }
158
159
    public function __toString()
160
    {
161
        return $this->getMethod() . ' ' . $this->getHost() . ' ' . $this->getPort() . ' ' . $this->getRequestUri();
162
    }
163
164
    public function toArray()
165
    {
166
        $request = array();
167
168
        $request['scheme']  = $this->getScheme();
169
        $request['method']  = $this->getMethod();
170
        $request['host']    = $this->getHost();
171
        $request['port']    = $this->getPort();
172
        $request['url']     = $this->getRequestUri();
173
        $request['headers'] = $this->getHeaders();
174
175
        $protocol = $this->getProtocol();
176
        if (isset($protocol)) {
177
            $request['protocol'] = $protocol;
178
        }
179
180
        $body = $this->getBody();
181
        if (isset($body)) {
182
            $request['body'] = $body;
183
        }
184
185
        return $request;
186
    }
187
188
}
189