Issues (3098)

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.

tests/KochTest/Debug/DebugTest.php (1 issue)

Severity

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 KochTest\Debug;
4
5
use Koch\Debug\Debug;
6
7
class DebugTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var Debug
11
     */
12
    protected $object;
13
14
    /**
15
     * Sets up the fixture, for example, opens a network connection.
16
     * This method is called before a test is executed.
17
     */
18
    public function setUp()
19
    {
20
        $this->object = new Debug();
21
    }
22
23
    /**
24
     * Tears down the fixture, for example, closes a network connection.
25
     * This method is called after a test is executed.
26
     */
27
    public function tearDown()
28
    {
29
        unset($this->object);
30
    }
31
32
    /**
33
     * @covers Koch\Debug\Debug::printR
34
     */
35
    public function testPrintR()
36
    {
37
38
// NOTE: this is NOWDOC instead of HEREDOC
39
// so its without parsing, because of the inlined $var
40
$expectedOutput = <<<'EOD'
41
<pre><b>Debugging <font color=red>DebugTest.php</font> on line <font color=red>64</font></b>:
42
<div style='background: #f5f5f5; padding: 0.2em 0em;'>        \Koch\Debug\Debug::printR($var, $var2, $string);
43
</div>
44
<b>Type</b>: array
45
<b>Length</b>: 1
46
<b>Value</b>: Array
47
(
48
    [Key] =&gt; Value
49
)
50
<b>Length</b>: 1
51
<b>Value</b>: Array
52
(
53
    [Key2] =&gt; Value2
54
)
55
<b>Length</b>: 13
56
<b>Value</b>: Just a string</pre>
57
EOD;
58
59
        $this->expectOutputString($expectedOutput);
60
61
        $var    = ['Key' => 'Value'];
62
        $var2   = ['Key2' => 'Value2'];
63
        $string = 'Just a string';
64
        \Koch\Debug\Debug::printR($var, $var2, $string);
65
    }
66
67
    /**
68
     * @covers Koch\Debug\Debug::dump
69
     */
70
    public function testDump()
71
    {
72
        /*
73
 * finally after 18 or something years, someone decided to add <pre> tags to var_dump()
74
 * in PHP 5.5.0alpha1! thats utterly impressive!
75
 * are you fucking serious? Come get some!
76
 */
77
78
// NOTE: this is NOWDOC instead of HEREDOC
79
// so its without parsing, because of the inlined $var
80
$expectedOutput = <<<'EOD'
81
Debugging DebugTest.php on line 92: \Koch\Debug\Debug::dump($var);
82
array(1) {
83
  'Key' =>
84
  string(5) "Value"
85
}
86
87
EOD;
88
89
        $this->expectOutputString($expectedOutput);
90
91
        $var = ['Key' => 'Value'];
92
        \Koch\Debug\Debug::dump($var);
93
    }
94
95
    /**
96
     * @covers Koch\Debug\Debug::getOriginOfDebugCall
97
     */
98
    public function testGetOriginOfDebugCall()
0 ignored issues
show
testGetOriginOfDebugCall 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...
99
    {
100
        // NOTE: this is NOWDOC instead of HEREDOC
101
// so its without parsing, because of the inlined $var
102
$expectedOutput = <<<'EOD'
103
Debugging DebugTest.php on line 109: \Koch\Debug\Debug::getOriginOfDebugCall(0);
104
105
EOD;
106
        $this->expectOutputString($expectedOutput);
107
108
        $_SERVER['REMOTE_ADDR'] = null;
109
        \Koch\Debug\Debug::getOriginOfDebugCall(0);
110
    }
111
112
    /**
113
     * @covers Koch\Debug\Debug::getIncludedFiles
114
     */
115
    public function testGetIncludedFiles()
116
    {
117
        $returnArray = true;
118
        $array       = \Koch\Debug\Debug::getIncludedFiles($returnArray);
119
120
        $this->assertTrue(is_array($array));
121
        $this->assertArrayHasKey('count', $array);
122
        $this->assertArrayHasKey('size', $array);
123
        $this->assertArrayHasKey('files', $array);
124
125
        $this->assertTrue(is_array($array['files']));
126
        $this->assertTrue(is_array($array['files'][0]));
127
        $this->assertArrayHasKey('name', $array['files'][0]);
128
        $this->assertArrayHasKey('size', $array['files'][0]);
129
    }
130
131
    /**
132
     * @covers Koch\Debug\Debug::getApplicationConstants
133
     */
134
    public function testGetApplicationConstants()
135
    {
136
        $returnArray = true;
137
        $array       = \Koch\Debug\Debug::getApplicationConstants($returnArray);
138
139
        $this->assertTrue(is_array($array));
140
    }
141
142
    /**
143
     * @covers Koch\Debug\Debug::getBacktrace
144
     */
145
    public function testGetBacktrace()
146
    {
147
        $returnArray = true;
148
        $limit       = 1;
149
        $array       = \Koch\Debug\Debug::getBacktrace($limit, $returnArray);
150
151
        $this->assertTrue(is_array($array));
152
    }
153
154
    /**
155
     * @covers Koch\Debug\Debug::getInterfaces
156
     */
157
    public function testGetInterfaces()
158
    {
159
        $returnArray = true;
160
        $array       = \Koch\Debug\Debug::getInterfaces($returnArray);
161
162
        $this->assertTrue(is_array($array));
163
    }
164
165
    /**
166
     * @covers Koch\Debug\Debug::getClasses
167
     */
168
    public function testGetClasses()
169
    {
170
        $returnArray = true;
171
        $array       = \Koch\Debug\Debug::getClasses($returnArray);
172
173
        $this->assertTrue(is_array($array));
174
    }
175
176
    /**
177
     * @covers Koch\Debug\Debug::getFunctions
178
     */
179
    public function testGetFunctions()
180
    {
181
        $returnArray = true;
182
        $array       = \Koch\Debug\Debug::getFunctions($returnArray);
183
184
        $this->assertTrue(is_array($array));
185
    }
186
187
    /**
188
     * @covers Koch\Debug\Debug::getExtensions
189
     */
190
    public function testGetExtensions()
191
    {
192
        $returnArray = true;
193
        $array       = \Koch\Debug\Debug::getExtensions($returnArray);
194
195
        $this->assertTrue(is_array($array));
196
    }
197
198
    /**
199
     * @covers Koch\Debug\Debug::getPhpIni
200
     */
201
    public function testGetPhpIni()
202
    {
203
        $returnArray = true;
204
        $array       = \Koch\Debug\Debug::getPhpIni($returnArray);
205
206
        $this->assertTrue(is_array($array));
207
    }
208
209
    /**
210
     * @covers Koch\Debug\Debug::getWrappers
211
     */
212
    public function testGetWrappers()
213
    {
214
        $returnArray = true;
215
        $array       = \Koch\Debug\Debug::getWrappers($returnArray);
216
217
        $this->assertTrue(is_array($array));
218
        $this->assertArrayHasKey('openssl', $array);
219
        $this->assertArrayHasKey('http', $array);
220
        $this->assertArrayHasKey('https', $array);
221
        $this->assertArrayHasKey('all', $array);
222
    }
223
}
224