Issues (1165)

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.

tests/Parser/TraceTest.php (13 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
3
class Kint_Parser_TraceTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Kint_Parser_TraceTest does not seem to conform to the naming convention (^[A-Z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
4
{
5
    public function testParse()
6
    {
7
        $p = new Kint_Parser();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $p. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
8
        $p->addPlugin(new Kint_Parser_Trace());
9
10
        $bt = defined('DEBUG_BACKTRACE_IGNORE_ARGS')
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $bt. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
11
            ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)
12
            : debug_backtrace();
13
14
        $o = Kint_Object::blank();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
15
16
        $o = $p->parse($bt, $o);
17
18
        $this->assertContains('trace', $o->hints);
19
        $this->assertInstanceOf('Kint_Object_Trace', $o);
20
        $this->assertInstanceOf('Kint_Object_TraceFrame', $o->value->contents[0]);
21
    }
22
23
    public function provideTraces()
24
    {
25
        $bt = debug_backtrace(true);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $bt. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
26
        $bad_bt_1 = $bt;
0 ignored issues
show
$bad_bt_1 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
27
        $bad_bt_1[0]['test'] = 'woot';
0 ignored issues
show
$bad_bt_1 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
28
        $bad_bt_2 = $bt;
0 ignored issues
show
$bad_bt_2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
$bad_bt_2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
        $bat_bt_2[0]['function'] = 1234;
0 ignored issues
show
$bat_bt_2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style Comprehensibility introduced by
$bat_bt_2 was never initialized. Although not strictly required by PHP, it is generally a good practice to add $bat_bt_2 = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
30
31
        return array(
32
            'empty' => array(
33
                'trace' => array(),
34
                'expect' => false,
35
            ),
36
            'backtrace' => array(
37
                'trace' => $bt,
38
                'expect' => true,
39
            ),
40
            'bad backtrace, extra key' => array(
41
                'trace' => $bad_bt_1,
0 ignored issues
show
$bad_bt_1 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
42
                'expect' => false,
43
            ),
44
            'bad backtrace, wrong type' => array(
45
                'trace' => $bad_bt_1,
0 ignored issues
show
$bad_bt_1 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
46
                'expect' => false,
47
            ),
48
            'mythical' => array(
49
                'trace' => array(
50
                    array(
51
                        'function' => 'mythical_internal_function_with_no_args_that_results_in_a_backtrace',
52
                        'file' => __FILE__,
53
                        'line' => 1,
54
                    ),
55
                ),
56
                'expect' => true,
57
            ),
58
        );
59
    }
60
61
    /**
62
     * @dataProvider provideTraces
63
     */
64
    public function testIsTrace(array $trace, $expected)
65
    {
66
        $this->assertEquals($expected, Kint_Parser_Trace::isTrace($trace));
67
    }
68
69
    public function provideFrames()
70
    {
71
        return array(
72
            'function match' => array(
73
                'frame' => array(
74
                    'function' => 'testAWeirdFunctionName',
75
                ),
76
                'matches' => array('testaweirdfunctionname'),
77
                'expected' => true,
78
            ),
79
            'function no match denormalized' => array(
80
                'frame' => array(
81
                    'function' => 'testAWeirdFunctionName',
82
                ),
83
                'matches' => array('testAWeirdFunctionName'),
84
                'expected' => false,
85
            ),
86
            'function no match method' => array(
87
                'frame' => array(
88
                    'function' => 'testAWeirdFunctionName',
89
                ),
90
                'matches' => array(array('test', 'testaweirdfunctionname')),
91
                'expected' => false,
92
            ),
93
            'method no match function' => array(
94
                'frame' => array(
95
                    'function' => 'testAWeirdFunctionName',
96
                    'class' => 'test',
97
                ),
98
                'matches' => array('testAWeirdFunctionName'),
99
                'expected' => false,
100
            ),
101
            'method match' => array(
102
                'frame' => array(
103
                    'function' => 'testAWeirdFunctionName',
104
                    'class' => 'test',
105
                ),
106
                'matches' => array(array('test', 'testaweirdfunctionname')),
107
                'expected' => true,
108
            ),
109
        );
110
    }
111
112
    /**
113
     * @dataProvider provideFrames
114
     */
115
    public function testFrameIsListed(array $frame, array $matches, $expected)
116
    {
117
        $this->assertEquals($expected, Kint_Parser_Trace::frameIsListed($frame, $matches));
118
    }
119
120
    public function testNormalizeAliases()
121
    {
122
        $input = array(
123
            'CamelCaseFunction',
124
            'snake_case_function',
125
            'One_of_the_FunctionsMyColleaguesMADE__',
126
            'stringThatCan\'tBeAfunction',
127
            'another string that can not be a function',
128
            array('clASs', 'meThod'),
129
            array($this, 'meThod'),
130
            array('a', 'b', 'c'),
131
        );
132
133
        $expected = array(
134
            'camelcasefunction',
135
            'snake_case_function',
136
            'one_of_the_functionsmycolleaguesmade__',
137
            array('class', 'method'),
138
        );
139
140
        Kint_Parser_Trace::normalizeAliases($input);
141
142
        $this->assertEquals($expected, $input);
143
    }
144
}
145