Issues (159)

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.

LanguageConstructs/NewLanguageConstructsSniff.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
/**
3
 * PHPCompatibility, an external standard for PHP_CodeSniffer.
4
 *
5
 * @package   PHPCompatibility
6
 * @copyright 2012-2019 PHPCompatibility Contributors
7
 * @license   https://opensource.org/licenses/LGPL-3.0 LGPL3
8
 * @link      https://github.com/PHPCompatibility/PHPCompatibility
9
 */
10
11
namespace PHPCompatibility\Sniffs\LanguageConstructs;
12
13
use PHPCompatibility\AbstractNewFeatureSniff;
14
use PHP_CodeSniffer_File as File;
15
16
/**
17
 * Detect use of new PHP language constructs.
18
 *
19
 * PHP version All
20
 *
21
 * @link https://wiki.php.net/rfc/namespaceseparator
22
 * @link https://wiki.php.net/rfc/variadics
23
 * @link https://wiki.php.net/rfc/argument_unpacking
24
 *
25
 * @since 5.6
26
 * @since 7.1.0 Now extends the `AbstractNewFeatureSniff` instead of the base `Sniff` class..
27
 * @since 9.0.0 Detection for new operator tokens has been moved to the `NewOperators` sniff.
28
 */
29
class NewLanguageConstructsSniff extends AbstractNewFeatureSniff
30
{
31
32
    /**
33
     * A list of new language constructs, not present in older versions.
34
     *
35
     * The array lists : version number with false (not present) or true (present).
36
     * If's sufficient to list the first version where the keyword appears.
37
     *
38
     * @since 5.6
39
     *
40
     * @var array(string => array(string => bool|string))
41
     */
42
    protected $newConstructs = array(
43
        'T_NS_SEPARATOR' => array(
44
            '5.2' => false,
45
            '5.3' => true,
46
            'description' => 'the \ operator (for namespaces)',
47
        ),
48
        'T_ELLIPSIS' => array(
49
            '5.5' => false,
50
            '5.6' => true,
51
            'description' => 'the ... spread operator',
52
        ),
53
    );
54
55
56
    /**
57
     * Returns an array of tokens this test wants to listen for.
58
     *
59
     * @since 5.6
60
     *
61
     * @return array
62
     */
63 View Code Duplication
    public function register()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $tokens = array();
66
        foreach ($this->newConstructs as $token => $versions) {
67
            $tokens[] = constant($token);
68
        }
69
        return $tokens;
70
    }
71
72
73
    /**
74
     * Processes this test, when one of its tokens is encountered.
75
     *
76
     * @since 5.6
77
     *
78
     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
79
     * @param int                   $stackPtr  The position of the current token in
80
     *                                         the stack passed in $tokens.
81
     *
82
     * @return void
83
     */
84
    public function process(File $phpcsFile, $stackPtr)
85
    {
86
        $tokens    = $phpcsFile->getTokens();
87
        $tokenType = $tokens[$stackPtr]['type'];
88
89
        $itemInfo = array(
90
            'name' => $tokenType,
91
        );
92
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
93
    }
94
95
96
    /**
97
     * Get the relevant sub-array for a specific item from a multi-dimensional array.
98
     *
99
     * @since 7.1.0
100
     *
101
     * @param array $itemInfo Base information about the item.
102
     *
103
     * @return array Version and other information about the item.
104
     */
105
    public function getItemArray(array $itemInfo)
106
    {
107
        return $this->newConstructs[$itemInfo['name']];
108
    }
109
110
111
    /**
112
     * Get an array of the non-PHP-version array keys used in a sub-array.
113
     *
114
     * @since 7.1.0
115
     *
116
     * @return array
117
     */
118
    protected function getNonVersionArrayKeys()
119
    {
120
        return array('description');
121
    }
122
123
124
    /**
125
     * Retrieve the relevant detail (version) information for use in an error message.
126
     *
127
     * @since 7.1.0
128
     *
129
     * @param array $itemArray Version and other information about the item.
130
     * @param array $itemInfo  Base information about the item.
131
     *
132
     * @return array
133
     */
134
    public function getErrorInfo(array $itemArray, array $itemInfo)
135
    {
136
        $errorInfo                = parent::getErrorInfo($itemArray, $itemInfo);
137
        $errorInfo['description'] = $itemArray['description'];
138
139
        return $errorInfo;
140
    }
141
142
143
    /**
144
     * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
145
     *
146
     * @since 7.1.0
147
     *
148
     * @param array $data      The error data array which was created.
149
     * @param array $itemInfo  Base information about the item this error message applies to.
150
     * @param array $errorInfo Detail information about an item this error message applies to.
151
     *
152
     * @return array
153
     */
154
    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
155
    {
156
        $data[0] = $errorInfo['description'];
157
        return $data;
158
    }
159
}
160