Issues (1236)

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/Psalm/Config/IssueHandler.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 Psalm\Config;
3
4
use function array_filter;
5
use function array_map;
6
use function dirname;
7
use function in_array;
8
use function scandir;
9
use SimpleXMLElement;
10
use function strtolower;
11
use function substr;
12
use const SCANDIR_SORT_NONE;
13
14
class IssueHandler
15
{
16
    /**
17
     * @var string
18
     */
19
    private $error_level = \Psalm\Config::REPORT_ERROR;
20
21
    /**
22
     * @var array<ErrorLevelFileFilter>
23
     */
24
    private $custom_levels = [];
25
26
    /**
27
     * @param  SimpleXMLElement $e
28
     * @param  string           $base_dir
29
     *
30
     * @return self
31
     */
32
    public static function loadFromXMLElement(SimpleXMLElement $e, $base_dir)
33
    {
34
        $handler = new self();
35
36 View Code Duplication
        if (isset($e['errorLevel'])) {
0 ignored issues
show
This code seems to be duplicated across 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...
37
            $handler->error_level = (string) $e['errorLevel'];
38
39
            if (!in_array($handler->error_level, \Psalm\Config::$ERROR_LEVELS, true)) {
40
                throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $handler->error_level);
41
            }
42
        }
43
44
        /** @var \SimpleXMLElement $error_level */
45
        foreach ($e->errorLevel as $error_level) {
46
            $handler->custom_levels[] = ErrorLevelFileFilter::loadFromXMLElement($error_level, $base_dir, true);
47
        }
48
49
        return $handler;
50
    }
51
52
    /**
53
     * @param string $error_level
54
     *
55
     * @return void
56
     */
57
    public function setErrorLevel($error_level)
58
    {
59
        if (!in_array($error_level, \Psalm\Config::$ERROR_LEVELS, true)) {
60
            throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $error_level);
61
        }
62
63
        $this->error_level = $error_level;
64
    }
65
66
    /**
67
     * @param string $file_path
68
     *
69
     * @return string
70
     */
71
    public function getReportingLevelForFile($file_path)
72
    {
73
        foreach ($this->custom_levels as $custom_level) {
74
            if ($custom_level->allows($file_path)) {
75
                return $custom_level->getErrorLevel();
76
            }
77
        }
78
79
        return $this->error_level;
80
    }
81
82
    /**
83
     * @param string $fq_classlike_name
84
     *
85
     * @return string|null
86
     */
87
    public function getReportingLevelForClass($fq_classlike_name)
88
    {
89
        foreach ($this->custom_levels as $custom_level) {
90
            if ($custom_level->allowsClass($fq_classlike_name)) {
91
                return $custom_level->getErrorLevel();
92
            }
93
        }
94
    }
95
96
    /**
97
     * @param string $method_id
98
     *
99
     * @return string|null
100
     */
101
    public function getReportingLevelForMethod($method_id)
102
    {
103
        foreach ($this->custom_levels as $custom_level) {
104
            if ($custom_level->allowsMethod(strtolower($method_id))) {
105
                return $custom_level->getErrorLevel();
106
            }
107
        }
108
    }
109
110
    /**
111
     * @return string|null
112
     */
113
    public function getReportingLevelForFunction(string $function_id)
114
    {
115
        foreach ($this->custom_levels as $custom_level) {
116
            if ($custom_level->allowsMethod(strtolower($function_id))) {
117
                return $custom_level->getErrorLevel();
118
            }
119
        }
120
    }
121
122
    /**
123
     * @return string|null
124
     */
125
    public function getReportingLevelForArgument(string $function_id)
126
    {
127
        foreach ($this->custom_levels as $custom_level) {
128
            if ($custom_level->allowsMethod(strtolower($function_id))) {
129
                return $custom_level->getErrorLevel();
130
            }
131
        }
132
    }
133
134
    /**
135
     * @param string $property_id
136
     *
137
     * @return string|null
138
     */
139
    public function getReportingLevelForProperty($property_id)
140
    {
141
        foreach ($this->custom_levels as $custom_level) {
142
            if ($custom_level->allowsProperty($property_id)) {
143
                return $custom_level->getErrorLevel();
144
            }
145
        }
146
    }
147
148
    /**
149
     * @param string $var_name
150
     *
151
     * @return string|null
152
     */
153
    public function getReportingLevelForVariable($var_name)
154
    {
155
        foreach ($this->custom_levels as $custom_level) {
156
            if ($custom_level->allowsVariable($var_name)) {
157
                return $custom_level->getErrorLevel();
158
            }
159
        }
160
    }
161
162
    /**
163
     * @return       string[]
164
     * @psalm-return array<string>
165
     */
166
    public static function getAllIssueTypes()
167
    {
168
        return array_filter(
169
            array_map(
170
                /**
171
                 * @param string $file_name
172
                 *
173
                 * @return string
174
                 */
175
                function ($file_name) {
176
                    return substr($file_name, 0, -4);
177
                },
178
                scandir(dirname(__DIR__) . '/Issue', SCANDIR_SORT_NONE)
179
            ),
180
            /**
181
             * @param string $issue_name
182
             *
183
             * @return bool
184
             */
185
            function ($issue_name) {
186
                return !empty($issue_name)
187
                    && $issue_name !== 'MethodIssue'
188
                    && $issue_name !== 'PropertyIssue'
189
                    && $issue_name !== 'FunctionIssue'
190
                    && $issue_name !== 'ArgumentIssue'
191
                    && $issue_name !== 'VariableIssue'
192
                    && $issue_name !== 'ClassIssue'
193
                    && $issue_name !== 'CodeIssue'
194
                    && $issue_name !== 'PsalmInternalError'
195
                    && $issue_name !== 'ParseError'
196
                    && $issue_name !== 'PluginIssue';
197
            }
198
        );
199
    }
200
}
201