Issues (132)

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.

src/Analyzer/Factory.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
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer;
7
8
use PHPSA\Analyzer;
9
use PHPSA\Configuration;
10
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
11
use Webiny\Component\EventManager\EventManager;
12
use PHPSA\Analyzer\Pass as AnalyzerPass;
13
14
class Factory
15
{
16
    /**
17
     * @return NodeDefinition[]
18
     */
19
    public static function getPassesConfigurations()
20
    {
21
        $configs = [];
22
23
        foreach (self::getExpressionPasses() as $passClass) {
24
            $configs[] = $passClass::getMetadata()->getConfiguration();
25
        }
26
27
        foreach (self::getStatementPasses() as $passClass) {
28
            $configs[] = $passClass::getMetadata()->getConfiguration();
29
        }
30
31
        foreach (self::getScalarPasses() as $passClass) {
32
            $configs[] = $passClass::getMetadata()->getConfiguration();
33
        }
34
35
        return $configs;
36
    }
37
38
    /**
39
     * @return \PHPSA\Analyzer\Pass\Metadata[]
40
     */
41
    public static function getPassesMetadata()
42
    {
43
        $meta = [];
44
45
        foreach (self::getExpressionPasses() as $passClass) {
46
            $meta[] = $passClass::getMetadata();
47
        }
48
49
        foreach (self::getStatementPasses() as $passClass) {
50
            $meta[] = $passClass::getMetadata();
51
        }
52
53
        foreach (self::getScalarPasses() as $passClass) {
54
            $meta[] = $passClass::getMetadata();
55
        }
56
57
        return $meta;
58
    }
59
60
    /**
61
     * @param EventManager $eventManager
62
     * @param Configuration $config
63
     * @return Analyzer
64
     */
65 1
    public static function factory(EventManager $eventManager, Configuration $config)
0 ignored issues
show
Using PHP4-style constructors that are named like the class is not recommend; better use the more explicit __construct method.
Loading history...
66
    {
67 1
        $analyzersConfig = $config->getValue('analyzers');
68
69 1
        $filterEnabled = function ($passClass) use ($config, $analyzersConfig) {
70
            /** @var AnalyzerPass\Metadata $passMetadata */
71 1
            $passMetadata = $passClass::getMetadata();
72
73 1
            if (!isset($analyzersConfig[$passMetadata->getName()])) {
74 1
                return false;
75
            }
76
77 1
            if (!$analyzersConfig[$passMetadata->getName()]['enabled']) {
78
                return false;
79
            }
80
81 1
            if (!$passMetadata->allowsPhpVersion($config->getValue('language_level'))) {
82
                return false;
83
            }
84
85 1
            return true;
86 1
        };
87
88 1
        $instanciate = function ($passClass) use ($analyzersConfig) {
89 1
            $passName = $passClass::getMetadata()->getName();
90
91 1
            return new $passClass($analyzersConfig[$passName]);
92 1
        };
93
94 1
        $analyzer = new Analyzer($eventManager);
95 1
        $analyzer->registerExpressionPasses(
96 1
            array_map($instanciate, array_filter(self::getExpressionPasses(), $filterEnabled))
97
        );
98 1
        $analyzer->registerStatementPasses(
99 1
            array_map($instanciate, array_filter(self::getStatementPasses(), $filterEnabled))
100
        );
101 1
        $analyzer->registerScalarPasses(
102 1
            array_map($instanciate, array_filter(self::getScalarPasses(), $filterEnabled))
103
        );
104 1
        $analyzer->bind();
105
106 1
        return $analyzer;
107
    }
108
109
    /**
110
     * @return array
111
     */
112 1
    private static function getStatementPasses()
113
    {
114
        return [
115 1
            AnalyzerPass\Statement\MagicMethodParameters::class,
116
            AnalyzerPass\Statement\GotoUsage::class,
117
            AnalyzerPass\Statement\GlobalUsage::class,
118
            AnalyzerPass\Statement\HasMoreThanOneProperty::class,
119
            AnalyzerPass\Statement\MissingBreakStatement::class,
120
            AnalyzerPass\Statement\MissingVisibility::class,
121
            AnalyzerPass\Statement\MethodCannotReturn::class,
122
            AnalyzerPass\Statement\UnexpectedUseOfThis::class,
123
            AnalyzerPass\Statement\TestAnnotation::class,
124
            AnalyzerPass\Statement\MissingDocblock::class,
125
            AnalyzerPass\Statement\OldConstructor::class,
126
            AnalyzerPass\Statement\ConstantNaming::class,
127
            AnalyzerPass\Statement\MissingBody::class,
128
            AnalyzerPass\Statement\InlineHtmlUsage::class,
129
            AnalyzerPass\Statement\AssignmentInCondition::class,
130
            AnalyzerPass\Statement\StaticUsage::class,
131
            AnalyzerPass\Statement\OptionalParamBeforeRequired::class,
132
            AnalyzerPass\Statement\YodaCondition::class,
133
            AnalyzerPass\Statement\ForCondition::class,
134
            AnalyzerPass\Statement\PropertyDefinitionDefaultValue::class,
135
            AnalyzerPass\Statement\ReturnAndYieldInOneMethod::class,
136
            AnalyzerPass\Statement\ReturnVoid::class,
137
        ];
138
    }
139
140
    /**
141
     * @return array
142
     */
143 1
    private static function getExpressionPasses()
144
    {
145
        return [
146
            // Another
147 1
            AnalyzerPass\Expression\ErrorSuppression::class,
148
            AnalyzerPass\Expression\MultipleUnaryOperators::class,
149
            AnalyzerPass\Expression\StupidUnaryOperators::class,
150
            AnalyzerPass\Expression\VariableVariableUsage::class,
151
            AnalyzerPass\Expression\Casts::class,
152
            AnalyzerPass\Expression\EvalUsage::class,
153
            AnalyzerPass\Expression\FinalStaticUsage::class,
154
            AnalyzerPass\Expression\CompareWithArray::class,
155
            AnalyzerPass\Expression\DivisionFromZero::class,
156
            AnalyzerPass\Expression\DivisionByOne::class,
157
            AnalyzerPass\Expression\BacktickUsage::class,
158
            AnalyzerPass\Expression\LogicInversion::class,
159
            AnalyzerPass\Expression\ExitUsage::class,
160
            AnalyzerPass\Expression\NestedTernary::class,
161
            AnalyzerPass\Expression\AssignRefNew::class,
162
            // Arrays
163
            AnalyzerPass\Expression\ArrayShortDefinition::class,
164
            AnalyzerPass\Expression\ArrayDuplicateKeys::class,
165
            AnalyzerPass\Expression\ArrayIllegalOffsetType::class,
166
            // Closures
167
            AnalyzerPass\Expression\DuplicatedVariablesInUseClosure::class,
168
            // Function call
169
            AnalyzerPass\Expression\FunctionCall\AliasCheck::class,
170
            AnalyzerPass\Expression\FunctionCall\DebugCode::class,
171
            AnalyzerPass\Expression\FunctionCall\RandomApiMigration::class,
172
            AnalyzerPass\Expression\FunctionCall\SleepUsage::class,
173
            AnalyzerPass\Expression\FunctionCall\UseCast::class,
174
            AnalyzerPass\Expression\FunctionCall\DeprecatedIniOptions::class,
175
            AnalyzerPass\Expression\FunctionCall\RegularExpressions::class,
176
            AnalyzerPass\Expression\FunctionCall\ArgumentUnpacking::class,
177
            AnalyzerPass\Expression\FunctionCall\UnsafeUnserialize::class,
178
            AnalyzerPass\Expression\FunctionCall\DeprecatedFunctions::class,
179
            AnalyzerPass\Expression\FunctionCall\FunctionStringFormater::class,
180
        ];
181
    }
182
183
    /**
184
     * @return array
185
     */
186 1
    private static function getScalarPasses()
187
    {
188
        return [
189 1
            AnalyzerPass\Scalar\CheckLNumberKind::class,
190
        ];
191
    }
192
}
193