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/Object/BlobTest.php (25 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_Object_BlobTest extends KintTestCase
0 ignored issues
show
Kint_Object_BlobTest 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 blobProvider()
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
        $b = Kint_Object::blank('$v');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. 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...
9
10
        Kint_Object_Blob::$char_encodings = array(
11
            'ASCII',
12
            'UTF-8',
13
        );
14
15
        $strings = array(
16
            'empty' => array(
17
                '',
18
                'ASCII',
19
                'string',
20
            ),
21
            'ASCII' => array(
22
                "The quick brown fox jumps<br>\r\n\tover the lazy dog",
23
                'ASCII',
24
                'string',
25
            ),
26
            'UTF-8' => array(
27
                "El zorro marrón rápido salta sobre<br>\r\n\tel perro perezoso",
28
                'UTF-8',
29
                'UTF-8 string',
30
            ),
31
            'fail' => array(
32
                "The quick brown fox jumps<br>\r\n\tover the lazy dog\x90\x1b",
33
                false,
34
                'binary string',
35
            ),
36
        );
37
38
        if (!defined('HHVM_VERSION')) {
39
            Kint_Object_Blob::$char_encodings[] = 'SJIS';
40
            Kint_Object_Blob::$char_encodings[] = 'EUC-JP';
41
            Kint_Object_Blob::$char_encodings[] = 'Windows-1252';
42
            $strings['SJIS'] = array(
43
                mb_convert_encoding("キント最強<br>\r\n\tASCII", 'SJIS', 'UTF-8'),
44
                'SJIS',
45
                'SJIS string',
46
            );
47
            $strings['EUC-JP'] = array(
48
                mb_convert_encoding("キント最強<br>\r\n\tASCII", 'EUC-JP', 'UTF-8'),
49
                'EUC-JP',
50
                'EUC-JP string',
51
            );
52
            $strings['yuck'] = array(
53
                mb_convert_encoding("El zorro marrón rápido salta sobre<br>\r\n\tel perro perezoso", 'Windows-1252', 'UTF-8'),
54
                'Windows-1252',
55
                'Windows-1252 string',
56
            );
57
        }
58
59
        foreach ($strings as $encoding => &$string) {
60
            array_unshift($string, $p->parse($string[0], clone $b));
61
        }
62
63
        return $strings;
64
    }
65
66
    /**
67
     * @dataProvider blobProvider
68
     */
69
    public function testGetType(Kint_Object_Blob $object, $string, $encoding, $type)
0 ignored issues
show
The parameter $string is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $encoding is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
70
    {
71
        $this->assertEquals($type, $object->getType());
72
    }
73
74
    /**
75
     * @dataProvider blobProvider
76
     */
77
    public function testGetValueShort(Kint_Object_Blob $object, $string, $encoding)
78
    {
79
        if ($encoding) {
80
            $string = mb_convert_encoding($string, 'UTF-8', $encoding);
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
81
            $string = '"'.$string.'"';
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
82
            $string = mb_convert_encoding($string, $encoding, 'UTF-8');
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
83
        } else {
84
            $string = '"'.$string.'"';
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
85
        }
86
87
        $this->assertEquals($string, $object->getValueShort());
88
    }
89
90
    public function testTransplant()
91
    {
92
        $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...
93
        $b = Kint_Object::blank('$v');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. 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...
94
95
        $string = 'How now brown cow';
96
97
        $o = $p->parse($string, clone $b);
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...
98
99
        $this->assertNotFalse($o->encoding);
0 ignored issues
show
The property encoding does not seem to exist in Kint_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
100
        $this->assertNotNull($o->encoding);
101
        $this->assertNotEmpty($o->encoding);
102
103
        $o2 = $o->transplant(new Kint_Object_Blob());
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
104
105
        $o->hints[] = 'string';
106
107
        $this->assertEquals($o, $o2);
108
        $this->assertNotSame($o, $o2);
109
        $this->assertSame($o->encoding, $o2->encoding);
110
    }
111
112
    /**
113
     * @dataProvider blobProvider
114
     */
115
    public function testStrlen(Kint_Object_Blob $object, $string, $encoding)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
116
    {
117
        if ($encoding === false) {
118
            $this->assertEquals(strlen($string), Kint_Object_Blob::strlen($string));
119
            $this->assertEquals(strlen($string), Kint_Object_Blob::strlen($string, false));
120
        } else {
121
            $this->assertEquals(mb_strlen($string, $encoding), Kint_Object_Blob::strlen($string));
122
            $this->assertEquals(mb_strlen($string, $encoding), Kint_Object_Blob::strlen($string, $encoding));
123
        }
124
    }
125
126
    /**
127
     * @dataProvider blobProvider
128
     */
129
    public function testDetectEncoding(Kint_Object_Blob $object, $string, $encoding)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
130
    {
131
        $this->assertEquals($encoding, Kint_Object_Blob::detectEncoding($string));
132
    }
133
134
    /**
135
     * @dataProvider blobProvider
136
     * @expectedException \PHPUnit_Framework_Error_Deprecated
137
     */
138
    public function testEscapeText(Kint_Object_Blob $object, $string, $encoding)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
139
    {
140
        Kint::$enabled_mode = Kint::MODE_TEXT;
141
142
        $this->assertEquals($string, Kint_Object_Blob::escape($string, $encoding));
143
    }
144
145
    /**
146
     * @dataProvider blobProvider
147
     * @expectedException \PHPUnit_Framework_Error_Deprecated
148
     */
149
    public function testEscapeTextNoEncoding(Kint_Object_Blob $object, $string)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
150
    {
151
        Kint::$enabled_mode = Kint::MODE_TEXT;
152
153
        $this->assertEquals($string, Kint_Object_Blob::escape($string));
154
    }
155
156
    /**
157
     * @dataProvider blobProvider
158
     * @expectedException \PHPUnit_Framework_Error_Deprecated
159
     */
160
    public function testEscapeCli(Kint_Object_Blob $object, $string, $encoding)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
161
    {
162
        Kint::$enabled_mode = Kint::MODE_CLI;
163
164
        $this->assertNotContains("\x1b", Kint_Object_Blob::escape($string, $encoding));
165
    }
166
167
    /**
168
     * @dataProvider blobProvider
169
     * @expectedException \PHPUnit_Framework_Error_Deprecated
170
     */
171
    public function testEscapeCliNoEncoding(Kint_Object_Blob $object, $string)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
172
    {
173
        Kint::$enabled_mode = Kint::MODE_CLI;
174
175
        $this->assertNotContains("\x1b", Kint_Object_Blob::escape($string));
176
    }
177
178
    /**
179
     * @dataProvider blobProvider
180
     * @expectedException \PHPUnit_Framework_Error_Deprecated
181
     */
182
    public function testEscapeHtml(Kint_Object_Blob $object, $string, $encoding)
0 ignored issues
show
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
183
    {
184
        Kint::$enabled_mode = Kint::MODE_RICH;
185
186
        if ($encoding === false || $encoding === 'ASCII') {
187
            $new_encoding = 'UTF-8';
0 ignored issues
show
$new_encoding 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...
188
        } else {
189
            $new_encoding = $encoding;
0 ignored issues
show
$new_encoding 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...
190
        }
191
192
        $expect = htmlspecialchars($string, ENT_NOQUOTES, $new_encoding);
0 ignored issues
show
$new_encoding 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...
193
        $expect = mb_encode_numericentity($expect, array(0x80, 0xffff, 0, 0xffff), $new_encoding);
0 ignored issues
show
$new_encoding 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...
194
195
        $this->assertEquals($expect, Kint_Object_Blob::escape($string, $encoding));
196
    }
197
}
198