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/Configuration.php (2 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
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
use PhpParser\ParserFactory;
9
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
10
use Symfony\Component\Config\Definition\ConfigurationInterface;
11
use Symfony\Component\Config\Definition\Processor;
12
13
/**
14
 * PHPSA configuration
15
 */
16
class Configuration implements ConfigurationInterface
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $configuration;
22
23
    /**
24
     * @var string
25
     */
26
    protected $path;
27
28
    /**
29
     * Create a configuration from array.
30
     *
31
     * @param array $configuration
32
     * @param array $analyzersConfiguration
33
     */
34 1
    public function __construct(array $configuration = [], array $analyzersConfiguration = [], $path = "")
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $analyzersConfiguration exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
35
    {
36 1
        $this->path = $path;
37
38 1
        $processor = new Processor();
39
40 1
        $configTree = $this->getConfigTreeBuilder($analyzersConfiguration);
41
42 1
        $this->configuration = $processor->process(
43 1
            $configTree->buildTree(),
44 1
            $configuration
45
        );
46 1
    }
47
48
    /**
49
     * Generates the configuration tree.
50
     *
51
     * @param array $analyzersConfiguration
52
     *
53
     * @return TreeBuilder
54
     */
55 1
    public function getConfigTreeBuilder(array $analyzersConfiguration = [])
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $analyzersConfiguration exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
56
    {
57 1
        $treeBuilder = new TreeBuilder();
58 1
        $root = $treeBuilder->root('phpsa');
59
60
        $root
61 1
            ->children()
62 1
                ->booleanNode('blame')->defaultFalse()->end()
63 1
                ->scalarNode('language_level')
64 1
                    ->defaultValue(PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION)
65 1
                    ->attribute('example', '5.3')
66 1
                    ->attribute('info', 'Will be used to automatically disable the analyzers that require a greater version of PHP.')
67 1
                ->end()
68 1
                ->enumNode('parser')
69 1
                    ->defaultValue('prefer-7')
70 1
                    ->attribute('label', 'Check types of Arguments.')
71 1
                    ->values([
72 1
                        ParserFactory::PREFER_PHP7 => 'prefer-7',
73 1
                        ParserFactory::PREFER_PHP5 => 'prefer-5',
74 1
                        ParserFactory::ONLY_PHP7 => 'only-7',
75 1
                        ParserFactory::ONLY_PHP5 => 'only-5'
76
                    ])
77 1
                ->end()
78 1
            ->end()
79
        ;
80
81
        $ignoredFilesAndDirs = $root
82 1
            ->children()
83 1
                ->arrayNode('ignore')
84 1
                ->scalarPrototype()->end()
85 1
                ->defaultValue(['/vendor'])
86 1
            ->end();
87
88
        $analyzersConfigRoot = $root
89 1
            ->children()
90 1
                ->arrayNode('analyzers')
91 1
                ->addDefaultsIfNotSet();
92
93 1
        $language_error = (new TreeBuilder())->root('language_error')
94 1
            ->info("Contains all compiler notices. Those are raised when PHP with strict error reporting would create at least a Notice message. (mostly experimental)")
95 1
            ->canBeDisabled();
96
97 1
        $analyzersConfigRoot->append($language_error);
98
99 1
        foreach ($analyzersConfiguration as $config) {
100 1
            $analyzersConfigRoot->append($config);
101
        }
102
103 1
        return $treeBuilder;
104
    }
105
106
    /**
107
     * Sets a configuration setting.
108
     *
109
     * @param string $key
110
     * @param mixed $value
111
     */
112 1
    public function setValue($key, $value)
113
    {
114 1
        $this->configuration[$key] = $value;
115 1
    }
116
117
    /**
118
     * Gets a configuration setting.
119
     *
120
     * @param string $key
121
     * @param mixed $default
122
     *
123
     * @return mixed
124
     */
125 1
    public function getValue($key, $default = null)
126
    {
127 1
        if (array_key_exists($key, $this->configuration)) {
128 1
            return $this->configuration[$key];
129
        }
130
131
        return $default;
132
    }
133
134
    /**
135
     * Checks if a configuration setting is set.
136
     *
137
     * @param string $key
138
     * @return bool
139
     */
140
    public function valueIsTrue($key)
141
    {
142
        return (bool) $this->configuration[$key];
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getPath()
149
    {
150
        return $this->path;
151
    }
152
}
153