Issues (1131)

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/SecureWebRequest.class.php (17 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
namespace Agavi\Request;
3
4
// +---------------------------------------------------------------------------+
5
// | This file is part of the Agavi package.                                   |
6
// | Copyright (c) 2005-2011 the Agavi Project.                                |
7
// |                                                                           |
8
// | For the full copyright and license information, please view the LICENSE   |
9
// | file that was distributed with this source code. You can also view the    |
10
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
11
// |   vi: set noexpandtab:                                                    |
12
// |   Local Variables:                                                        |
13
// |   indent-tabs-mode: t                                                     |
14
// |   End:                                                                    |
15
// +---------------------------------------------------------------------------+
16
17
/**
18
 * SecureWebRequest provides additional support for HTTPS client requests
19
 * such as SSL certificate inspection.
20
 *
21
 * @package    agavi
22
 * @subpackage request
23
 *
24
 * @author     Markus Lervik <[email protected]>
25
 * @author     David Zülke <[email protected]>
26
 * @copyright  Authors
27
 * @copyright  The Agavi Project
28
 *
29
 * @since      0.10.0.0
30
 *
31
 * @deprecated To be removed in Agavi 1.1
32
 *
33
 * @version    $Id$
34
 */
35
class SecureWebRequest extends WebRequest
36
{
37
38
    /**
39
     * Check whether or not the current request is over a secure connection
40
     * (HTTPS)
41
     *
42
     * @return     bool true if HTTPS is on, false otherwise
43
     *
44
     * @author     Markus Lervik <[email protected]>
45
     * @author     David Zülke <[email protected]>
46
     * @since      0.10.0
47
     */
48
    public function isHTTPS()
0 ignored issues
show
isHTTPS uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
49
    {
50
51
        return (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on');
52
    }
53
54
    /**
55
     * Check if the client certificate is a valid one
56
     *
57
     * @return     bool true if the certificate is valid, false otherwise
58
     *
59
     * @author     Markus Lervik <[email protected]>
60
     * @author     David Zülke <[email protected]>
61
     * @since      0.10.0
62
     */
63
    public function hasValidClientCert()
0 ignored issues
show
hasValidClientCert uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
64
    {
65
66
        return (isset($_SERVER['SSL_CLIENT_VERIFY']) && strtoupper($_SERVER['SSL_CLIENT_VERIFY']) == 'SUCCESS');
67
    }
68
69
// -------------------------------------------------------------------------
70
71
    /**
72
     * Get the client CN (Common Name) field from the client X.509 certificate
73
     * if one is available
74
     *
75
     * @return     mixed the CN field if it's available, otherwise null
76
     *
77
     * @author     Markus Lervik <[email protected]>
78
     * @author     David Zülke <[email protected]>
79
     * @since      0.10.0
80
     */
81
    public function getClientCertCN()
0 ignored issues
show
getClientCertCN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
82
    {
83
84
        if (isset($_SERVER['SSL_CLIENT_S_DN_CN'])) {
85
            return $_SERVER['SSL_CLIENT_S_DN_CN'];
86
        }
87
    }
88
89
// -------------------------------------------------------------------------
90
91
    /**
92
     * Get the client DN (Distinguished Name) field from the client X.509
93
     * certificate if one is available
94
     *
95
     * @return     mixed the DN field if it's available, otherwise null
96
     *
97
     * @author     Markus Lervik <[email protected]>
98
     * @author     David Zülke <[email protected]>
99
     * @since      0.10.0
100
     */
101
    public function getClientCertDN()
0 ignored issues
show
getClientCertDN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
102
    {
103
104
        if (isset($_SERVER['SSL_CLIENT_S_DN'])) {
105
            return $_SERVER['SSL_CLIENT_S_DN'];
106
        }
107
    }
108
109
    /**
110
     * Get the client GN (General Name) field from the client X.509 certificate
111
     * if one is available
112
     *
113
     * @return     mixed the GN field if it's available, otherwise null
114
     *
115
     * @author     Markus Lervik <[email protected]>
116
     * @author     David Zülke <[email protected]>
117
     * @since      0.10.0
118
     */
119
    public function getClientCertGN()
0 ignored issues
show
getClientCertGN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
120
    {
121
122
        if (isset($_SERVER['SSL_CLIENT_S_DN_G'])) {
123
            return $_SERVER['SSL_CLIENT_S_DN_G'];
124
        }
125
    }
126
127
    /**
128
     * Get the client SN (Subject Name) field from the client X.509 certificate
129
     * if one is available
130
     *
131
     * @return     mixed the SN field if it's available, otherwise null
132
     *
133
     * @author     Markus Lervik <[email protected]>
134
     * @author     David Zülke <[email protected]>
135
     * @since      0.10.0
136
     */
137
    public function getClientCertSN()
0 ignored issues
show
getClientCertSN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
138
    {
139
140
        if (isset($_SERVER['SSL_CLIENT_S_DN_S'])) {
141
            return $_SERVER['SSL_CLIENT_S_DN_S'];
142
        }
143
    }
144
145
    /**
146
     * Get the client O (Organisation) field from the client X.509 certificate
147
     * if one is available
148
     *
149
     * @return     mixed the O field if it's available, otherwise null
150
     *
151
     * @author     Markus Lervik <[email protected]>
152
     * @author     David Zülke <[email protected]>
153
     * @since      0.10.0
154
     */
155
    public function getClientCertO()
0 ignored issues
show
getClientCertO uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
156
    {
157
158
        if (isset($_SERVER['SSL_CLIENT_S_DN_O'])) {
159
            return $_SERVER['SSL_CLIENT_S_DN_O'];
160
        }
161
    }
162
163
    /**
164
     * Get the client OU (Organisation Unit) field from the client X.509
165
     * certificate if one is available
166
     *
167
     * @return     mixed the OU field if it's available, otherwise null
168
     *
169
     * @author     Markus Lervik <[email protected]>
170
     * @author     David Zülke <[email protected]>
171
     * @since      0.10.0
172
     */
173
    public function getClientCertOU()
0 ignored issues
show
getClientCertOU uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
174
    {
175
176
        if (isset($_SERVER['SSL_CLIENT_S_DN_OU'])) {
177
            return $_SERVER['SSL_CLIENT_S_DN_OU'];
178
        }
179
    }
180
181
    /**
182
     * Get the date from which the client certificate is valid
183
     * if one is available
184
     *
185
     * @return     mixed the date field if it's available, otherwise null
186
     *
187
     * @author     Markus Lervik <[email protected]>
188
     * @author     David Zülke <[email protected]>
189
     * @since      0.10.0
190
     */
191
    public function getClientCertValidityStart()
0 ignored issues
show
getClientCertValidityStart uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
192
    {
193
194
        if (isset($_SERVER['SSL_CLIENT_V_START'])) {
195
            return $_SERVER['SSL_CLIENT_V_START'];
196
        }
197
    }
198
199
    /**
200
     * Get the date until which the client certificate is valid
201
     * if one is available
202
     *
203
     * @return     mixed the date field if it's available, otherwise null
204
     * @author     Markus Lervik <[email protected]>
205
     * @author     David Zülke <[email protected]>
206
     * @since      0.10.0
207
     */
208
    public function getClientCertValidityEnd()
0 ignored issues
show
getClientCertValidityEnd uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
209
    {
210
211
        if (isset($_SERVER['SSL_CLIENT_V_END'])) {
212
            return $_SERVER['SSL_CLIENT_V_END'];
213
        }
214
    }
215
216
    /**
217
     * Get the cipher type used for this connection
218
     * if one is available
219
     *
220
     * @return     mixed the cipher type if it's available, otherwise null
221
     * @author     Markus Lervik <[email protected]>
222
     * @author     David Zülke <[email protected]>
223
     * @since      0.10.0
224
     */
225
    public function getSSLChipherType()
0 ignored issues
show
getSSLChipherType uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
226
    {
227
228
        if (isset($_SERVER['SSL_CIPHER'])) {
229
            return $_SERVER['SSL_CIPHER'];
230
        }
231
    }
232
233
    /**
234
     * Get the issuer DN (Distinguished Name) field from the issuer X.509
235
     * certificate if one is available
236
     *
237
     * @return     mixed the DN field if it's available, otherwise null
238
     * @author     Markus Lervik <[email protected]>
239
     * @author     David Zülke <[email protected]>
240
     * @since      0.10.0
241
     */
242
    public function getIssuerCertDN()
0 ignored issues
show
getIssuerCertDN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
243
    {
244
245
        if (isset($_SERVER['SSL_CLIENT_I_DN'])) {
246
            return $_SERVER['SSL_CLIENT_I_DN'];
247
        }
248
    }
249
250
    /**
251
     * Get the issuer CN (Common Name) field from the issuer X.509 certificate
252
     * if one is available
253
     *
254
     * @return     mixed the CN field if it's available, otherwise null
255
     * @author     Markus Lervik <[email protected]>
256
     * @author     David Zülke <[email protected]>
257
     * @since      0.10.0
258
     */
259
    public function getIssuerCertCN()
0 ignored issues
show
getIssuerCertCN uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
260
    {
261
262
        if (isset($_SERVER['SSL_CLIENT_I_CN'])) {
263
            return $_SERVER['SSL_CLIENT_I_CN'];
264
        }
265
    }
266
267
    /**
268
     * Get the issuer C (Country) field from the issuer X.509 certificate
269
     * if one is available
270
     *
271
     * @return     mixed the C field if it's available, otherwise null
272
     * @author     Markus Lervik <[email protected]>
273
     * @author     David Zülke <[email protected]>
274
     * @since      0.10.0
275
     */
276
    public function getIssuerCertC()
0 ignored issues
show
getIssuerCertC uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
277
    {
278
279
        if (isset($_SERVER['SSL_CLIENT_I_C'])) {
280
            return $_SERVER['SSL_CLIENT_I_C'];
281
        }
282
    }
283
284
    /**
285
     * Get the issuer O (Organisation) field from the issuer X.509 certificate
286
     * if one is available
287
     *
288
     * @return     mixed the O field if it's available, otherwise null
289
     * @author     Markus Lervik <[email protected]>
290
     * @author     David Zülke <[email protected]>
291
     * @since      0.10.0
292
     */
293
    public function getIssuerCertO()
0 ignored issues
show
getIssuerCertO uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
294
    {
295
296
        if (isset($_SERVER['SSL_CLIENT_I_O'])) {
297
            return $_SERVER['SSL_CLIENT_I_O'];
298
        }
299
    }
300
301
    /**
302
     * Get the issuer OU (Organisation Unit) field from the issuer X.509
303
     * certificate if one is available
304
     *
305
     * @return     mixed the OU field if it's available, otherwise null
306
     * @author     Markus Lervik <[email protected]>
307
     * @author     David Zülke <[email protected]>
308
     * @since      0.10.0
309
     */
310
    public function getIssuerCertOU()
0 ignored issues
show
getIssuerCertOU uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
311
    {
312
313
        if (isset($_SERVER['SSL_CLIENT_I_OU'])) {
314
            return $_SERVER['SSL_CLIENT_I_OU'];
315
        }
316
    }
317
318
    /**
319
     * Get the issuer ST (State) field from the issuer X.509 certificate
320
     * if one is available
321
     *
322
     * @return     mixed the ST field if it's available, otherwise null
323
     * @author     Markus Lervik <[email protected]>
324
     * @author     David Zülke <[email protected]>
325
     * @since      0.10.0.0
326
     */
327
    public function getIssuerCertST()
0 ignored issues
show
getIssuerCertST uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
328
    {
329
330
        if (isset($_SERVER['SSL_CLIENT_I_ST'])) {
331
            return $_SERVER['SSL_CLIENT_I_ST'];
332
        }
333
    }
334
}
335