Issues (50)

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/SiteAliasWithConfig.php (3 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
namespace Consolidation\SiteAlias;
3
4
use Consolidation\Config\Config;
5
use Consolidation\Config\ConfigInterface;
6
use Consolidation\Config\Util\ConfigRuntimeInterface;
7
use Consolidation\SiteAlias\SiteAlias;
8
use Consolidation\SiteAlias\SiteAliasInterface;
9
use Consolidation\SiteAlias\SiteAliasTrait;
10
11
/**
12
 * SiteAliasWithConfig delegates to a site alias, and
13
 * also combines it with two config stores:
14
 *
15
 *   - Runtime config (set on commandline): Options that override site alias contents
16
 *   - Default config (set from config files): Default options
17
 */
18
class SiteAliasWithConfig implements SiteAliasInterface, ConfigRuntimeInterface
19
{
20
    use SiteAliasTrait;
21
22
    protected $runtimeConfig;
23
    protected $siteAlias;
24
    protected $defaultConfig;
25
26
    public function __construct(SiteAliasInterface $siteAlias, ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig)
27
    {
28
        $this->siteAlias = $siteAlias;
29
        $this->defaultConfig = $defaultConfig;
30
        $this->runtimeConfig = $runtimeConfig;
31
    }
32
33
    /**
34
     * combine the provided site alias with configuration.
35
     *
36
     * @return SiteAlias read-only site alias combined with the runtime
37
     *   config (overrides the site alias values) and the default config.
38
     */
39
    public static function create(SiteAliasInterface $siteAlias, ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig = null)
40
    {
41
        $runtimeConfig = static::determineCorrectRuntimeConfig($defaultConfig, $runtimeConfig);
0 ignored issues
show
It seems like $runtimeConfig defined by static::determineCorrect...Config, $runtimeConfig) on line 41 can be null; however, Consolidation\SiteAlias\...eCorrectRuntimeConfig() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
42
43
        return new self($siteAlias, $defaultConfig, $runtimeConfig);
44
    }
45
46
    /**
47
     * Determine what object to use for the runtime config. If a specific
48
     * runtime config is given, use that. Otherwise, pull it from the default
49
     * configuration if available.
50
     */
51
    protected static function determineCorrectRuntimeConfig(ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig)
52
    {
53
        if ($runtimeConfig) {
54
            return $runtimeConfig;
55
        }
56
57
        if ($defaultConfig instanceof ConfigRuntimeInterface) {
58
            return $defaultConfig->runtimeConfig();
59
        }
60
61
        return new Config();
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function runtimeConfig()
68
    {
69
        return $this->runtimeConfig;
70
    }
71
72
    /**
73
     * @inheritdoc
74
     */
75
    public function name()
76
    {
77
        return $this->siteAlias->name();
78
    }
79
80
    /**
81
     * @inheritdoc
82
     */
83
    public function has($key)
84
    {
85
        return
86
            $this->runtimeConfig->has($key) ||
87
            $this->siteAlias->has($key) ||
88
            $this->defaultConfig->has($key);
89
    }
90
91
    /**
92
     * @inheritdoc
93
     */
94
    public function get($key, $defaultFallback = null)
95
    {
96
        if ($this->runtimeConfig->has($key)) {
97
            return $this->runtimeConfig->get($key);
98
        }
99
        if ($this->siteAlias->has($key)) {
100
            return $this->siteAlias->get($key);
101
        }
102
        if ($this->defaultConfig->has($key)) {
103
            return $this->defaultConfig->get($key);
104
        }
105
106
        return $defaultFallback;
107
    }
108
109
    /**
110
     * @inheritdoc
111
     */
112
    public function set($key, $value)
113
    {
114
        $this->changesProhibited();
115
    }
116
117
    /**
118
     * @inheritdoc
119
     */
120
    public function import($data)
121
    {
122
        $this->changesProhibited();
123
    }
124
125
    /**
126
     * @inheritdoc
127
     */
128
    public function replace($data)
0 ignored issues
show
The parameter $data 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...
129
    {
130
        $this->changesProhibited();
131
    }
132
133
    /**
134
     * @inheritdoc
135
     */
136
    public function combine($data)
0 ignored issues
show
The parameter $data 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...
137
    {
138
        $this->changesProhibited();
139
    }
140
141
    /**
142
     * Export all configuration as a nested array.
143
     */
144
    public function export()
145
    {
146
        throw new \Exception('SiteAliasWithConfig::export() not supported.');
147
    }
148
149
    /**
150
     * @inheritdoc
151
     */
152
    public function hasDefault($key)
153
    {
154
        return false;
155
    }
156
157
    /**
158
     * @inheritdoc
159
     */
160
    public function getDefault($key, $defaultFallback = null)
161
    {
162
        return $defaultFallback;
163
    }
164
165
    /**
166
     * @inheritdoc
167
     */
168
    public function setDefault($key, $value)
169
    {
170
        $this->changesProhibited();
171
    }
172
173
    /**
174
     * @inheritdoc
175
     */
176
    public function exportConfig()
177
    {
178
        throw new \Exception('SiteAliasWithConfig::exportConfig() not supported.');
179
    }
180
181
    protected function changesProhibited()
182
    {
183
        throw new \Exception('Changing a SiteAliasWithConfig is not permitted.');
184
    }
185
}
186