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/response/ConsoleResponse.class.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 Agavi\Response;
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
use Agavi\Dispatcher\OutputType;
17
18
/**
19
 * ConsoleResponse handles command line responses.
20
 *
21
 * @package    agavi
22
 * @subpackage response
23
 *
24
 * @author     David Zülke <[email protected]>
25
 * @copyright  Authors
26
 * @copyright  The Agavi Project
27
 *
28
 * @since      1.0.0
29
 *
30
 * @version    $Id$
31
 */
32
class ConsoleResponse extends Response
33
{
34
    /**
35
     * @var        string The content to send back with this response.
36
     */
37
    protected $content = '';
38
    
39
    /**
40
     * @var        int The shell exit code.
41
     */
42
    protected $exitCode = 0;
43
    
44
    /**
45
     * Import response metadata (nothing in this case) from another response.
46
     *
47
     * @param      Response $otherResponse The other response to import information from.
48
     *
49
     * @author     David Zülke <[email protected]>
50
     * @since      1.0.0
51
     */
52
    public function merge(Response $otherResponse)
53
    {
54
        parent::merge($otherResponse);
55
    }
56
    
57
    /**
58
     * Redirect externally. Not implemented here.
59
     *
60
     * @param      mixed $to Where to redirect.
61
     *
62
     * @throws     \BadMethodCallException
63
     *
64
     * @author     David Zülke <[email protected]>
65
     * @since      1.0.0
66
     */
67
    public function setRedirect($to)
68
    {
69
        throw new \BadMethodCallException('Redirects are not implemented for Console.');
70
    }
71
    
72
    /**
73
     * Get info about the set redirect. Not implemented here.
74
     *
75
     * @return     array An assoc array of redirect info, or null if none set.
76
     *
77
     * @throws     \BadMethodCallException
78
     *
79
     * @author     David Zülke <[email protected]>
80
     * @since      1.0.0
81
     */
82
    public function getRedirect()
83
    {
84
        throw new \BadMethodCallException('Redirects are not implemented for Console.');
85
    }
86
87
    /**
88
     * Check if a redirect is set. Not implemented here.
89
     *
90
     * @return     bool true, if a redirect is set, otherwise false
91
     *
92
     * @throws     \BadMethodCallException
93
     *
94
     * @author     David Zülke <[email protected]>
95
     * @since      1.0.0
96
     */
97
    public function hasRedirect()
98
    {
99
        throw new \BadMethodCallException('Redirects are not implemented for Console.');
100
    }
101
102
    /**
103
     * Clear any set redirect information. Not implemented here.
104
     *
105
     * @throws     \BadMethodCallException
106
     *
107
     * @author     David Zülke <[email protected]>
108
     * @since      1.0.0
109
     */
110
    public function clearRedirect()
111
    {
112
        throw new \BadMethodCallException('Redirects are not implemented for Console.');
113
    }
114
    
115
    /**
116
     * Set the shell exit code of this response.
117
     *
118
     * @param      int $exitCode The exit code.
119
     *
120
     * @author     David Zülke <[email protected]>
121
     * @since      1.0.0
122
     */
123
    public function setExitCode($exitCode)
124
    {
125
        $this->exitCode = (int)$exitCode;
126
    }
127
    
128
    /**
129
     * Get the shell exit code of this response.
130
     *
131
     * @return     int The exit code.
132
     *
133
     * @author     David Zülke <[email protected]>
134
     * @since      1.0.0
135
     */
136
    public function getExitCode()
137
    {
138
        return $this->exitCode;
139
    }
140
    
141
    /**
142
     * Determine whether the content in the response may be modified by appending
143
     * or prepending data using string operations. Typically false for streams,
144
     * and for responses like XMLRPC where the content is an array.
145
     *
146
     * @return     bool If the content can be treated as / changed like a string.
147
     *
148
     * @author     David Zülke <[email protected]>
149
     * @since      1.0.0
150
     */
151
    public function isContentMutable()
152
    {
153
        return !is_resource($this->content);
154
    }
155
    
156
    /**
157
     * Send all response data to the client.
158
     *
159
     * @author     David Zülke <[email protected]>
160
     * @since      1.0.0
161
     */
162
    public function send(OutputType $outputType = null)
163
    {
164
        $this->sendContent();
165
        
166
        register_shutdown_function(array($this, 'sendExit'));
167
    }
168
    
169
    /**
170
     * Clear all response data.
171
     *
172
     * @author     David Zülke <[email protected]>
173
     * @since      1.0.0
174
     */
175
    public function clear()
176
    {
177
        $this->clearContent();
178
        $this->setExitCode(0);
179
    }
180
    
181
    /**
182
     * Send the content for this response
183
     *
184
     * @author     David Zülke <[email protected]>
185
     * @since      1.0.0
186
     */
187
    protected function sendContent()
188
    {
189
        $isContentMutable = $this->isContentMutable();
190
        
191
        parent::sendContent();
192
        
193
        if ($isContentMutable && $this->getParameter('append_eol', true)) {
194
            echo PHP_EOL;
195
        }
196
    }
197
    
198
    /**
199
     * Call exit() and submit the exit code.
200
     * This is called by PHP during script shutdown.
201
     * It gets registered as a shutdown function in ConsoleResponse::send().
202
     *
203
     * @author     David Zülke <[email protected]>
204
     * @since      1.0.0
205
     */
206
    public function sendExit()
207
    {
208
        exit($this->exitCode);
0 ignored issues
show
Coding Style Compatibility introduced by
The method sendExit() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
209
    }
210
}
211