Issues (100)

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.

lib/Solidifier/ConfigurationHandler.php (8 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
namespace Solidifier;
4
5
use Solidifier\Visitors\Encapsulation\PublicAttributes;
6
use Solidifier\Visitors\GetterSetter\FluidSetters;
7
use Solidifier\Visitors\Encapsulation\EncapsulationViolation;
8
use Solidifier\Visitors\DependencyInjection\MagicalInstantiation;
9
use Solidifier\Visitors\DependencyInjection\StrongCoupling;
10
use Solidifier\Visitors\PreAnalyze\ObjectTypes;
11
use Solidifier\Visitors\DependencyInjection\InterfaceSegregation;
12
use Solidifier\Visitors\Encapsulation\PublicClass;
13
14
class ConfigurationHandler
15
{
16
    private
17
        $configuration,
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
The visibility should be declared for property $configuration.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
18
        $objectTypesList,
19
        $visitors;
20
    
21
    public function __construct(array $configuration, ObjectTypes $objectTypesList)
22
    {
23
        $this->configuration = $configuration;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24
        $this->objectTypesList = $objectTypesList;    
25
        
26
        $this->initializeVisitors();
27
    }
28
    
29
    public function configure(VisitableAnalyzer $analyzer)
30
    {
31
        $this->addPreAnalyzeVisitors($analyzer);            
32
        $this->addAnalyzeVisitors($analyzer);            
33
    }
34
    
35
    private function addPreAnalyzeVisitors(VisitableAnalyzer $analyzer)
36
    {
37
        $traverseName = 'preAnalyze';
38
        
39
        // this visitor must not be disabled
40
        $analyzer->addVisitor($traverseName, $this->objectTypesList);
41
        
42
        $visitors = array();
43
        
44
        return $this->addVisitors($analyzer, $visitors, $traverseName);
45
    }
46
    
47
    private function initializeVisitors()
48
    {        
49
        $this->visitors = array(
50
                        
51
            'property.public' => function(array $config) {
0 ignored issues
show
The parameter $config 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...
52
                return new PublicAttributes();    
53
            },
54
            
55
            'class.public' => function(array $config) {
56
                $visitor = new PublicClass();
57
58
                if(isset($config['threshold']) && is_numeric($config['threshold']))
59
                {
60
                    $visitor->setThreshold($config['threshold']);
61
                }
62
63
                if(isset($config['minMethodCount']) && is_numeric($config['minMethodCount']))
64
                {
65
                    $visitor->setMinMethodCount($config['minMethodCount']);
66
                }
67
                
68
                return $visitor;
69
            },
70
            
71
            'getterSetter.fluid' => function(array $config) {
0 ignored issues
show
The parameter $config 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...
72
                return new FluidSetters();    
73
            },
74
            
75
            'getterSetter.encapsulationViolation' => function(array $config) {
0 ignored issues
show
The parameter $config 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...
76
                return new EncapsulationViolation();    
77
            },
78
            
79
            'dependency.magical' => function(array $config) {
0 ignored issues
show
The parameter $config 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...
80
                return new MagicalInstantiation();    
81
            },
82
            
83
            'dependency.strongCoupling' => function(array $config) {
84
                $visitor = new StrongCoupling();
85
                
86
                $visitor->addExcludePattern('~Iterator$~')
87
                    ->addExcludePattern('~^Null~')
88
                    ->addExcludePattern('~Exception$~');
89
                
90
                if(isset($config['excludePatterns']))
91
                {
92
                    foreach($config['excludePatterns'] as $pattern)
93
                    {
94
                        $visitor->addExcludePattern("~$pattern~");
95
                    }            
96
                }
97
                
98
                if(isset($config['allowedClasses']))
99
                {
100
                    foreach($config['allowedClasses'] as $fullyQualifiedClassName)
101
                    {
102
                        $visitor->addAllowedClass($fullyQualifiedClassName);
103
                    }            
104
                }
105
                
106
               return $visitor;
107
            },
108
            
109
            'dependency.interfaceSegregation' => function(array $config) {
0 ignored issues
show
The parameter $config 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...
110
                return new InterfaceSegregation($this->objectTypesList);    
111
            },
112
        );
113
    }
114
    
115
    private function addAnalyzeVisitors(VisitableAnalyzer $analyzer)
116
    {
117
        return $this->addVisitors($analyzer, $this->visitors, 'analyze');
118
    }
119
    
120
    private function addVisitors(VisitableAnalyzer $analyzer, array $visitors, $traverse)
121
    {
122
        foreach($visitors as $key => $closure)
123
        {
124
            $config = array();
125
            if(isset($this->configuration[$key]))
126
            {
127
                $config = $this->configuration[$key];
128
            }
129
            
130
            if(! isset($config['enabled']) || $config['enabled'] === true)
131
            {
132
                $analyzer->addVisitor($traverse, $closure($config));
133
            }
134
        }
135
    }
136
}