Issues (94)

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/Settings/CacheSettingsProvider.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 declare(strict_types=1);
2
3
namespace Limoncello\Application\Settings;
4
5
/**
6
 * Copyright 2015-2020 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\Application\CoreSettings\CoreData;
22
use Limoncello\Application\Exceptions\AmbiguousSettingsException;
23
use Limoncello\Application\Exceptions\NotRegisteredSettingsException;
24
use Limoncello\Contracts\Application\ApplicationConfigurationInterface;
25
use Limoncello\Contracts\Application\CacheSettingsProviderInterface;
26
use ReflectionException;
27
use function array_key_exists;
28
29
/**
30
 * @package Limoncello\Application
31
 */
32
class CacheSettingsProvider implements CacheSettingsProviderInterface
33
{
34
    /** Internal data index */
35
    const KEY_APPLICATION_CONFIGURATION = 0;
36
37
    /** Internal data index */
38
    const KEY_CORE_DATA = self::KEY_APPLICATION_CONFIGURATION + 1;
39
40
    /** Internal data index */
41
    const KEY_SETTINGS_MAP = self::KEY_CORE_DATA + 1;
42
43
    /** Internal data index */
44
    const KEY_SETTINGS_DATA = self::KEY_SETTINGS_MAP + 1;
45
46
    /** Internal data index */
47
    const KEY_AMBIGUOUS_MAP = self::KEY_SETTINGS_DATA + 1;
48
49
    /**
50
     * @var array
51
     */
52
    private $appConfig = [];
53
54
    /**
55
     * @var array
56
     */
57
    private $coreData = [];
58
59
    /**
60
     * @var array
61
     */
62
    private $settingsMap = [];
63
64
    /**
65
     * @var array
66
     */
67
    private $settingsData = [];
68
69
    /**
70
     * @var array
71
     */
72
    private $ambiguousMap = [];
73
74 3
    /**
75
     * @inheritdoc
76 3
     */
77 2
    public function get(string $className): array
78 1
    {
79
        if ($this->has($className) === false) {
80 1
            if (array_key_exists($className, $this->ambiguousMap) === true) {
81
                throw new AmbiguousSettingsException($className);
82
            }
83 1
            throw new NotRegisteredSettingsException($className);
84
        }
85 1
86
        $data = $this->settingsData[$this->settingsMap[$className]];
87
88
        return $data;
89
    }
90
91 1
    /**
92
     * @inheritdoc
93 1
     */
94
    public function getApplicationConfiguration(): array
95
    {
96
        return $this->appConfig;
97
    }
98
99 2
    /**
100
     * @inheritdoc
101 2
     */
102
    public function getCoreData(): array
103
    {
104
        return $this->coreData;
105
    }
106
107 3
    /**
108
     * @inheritdoc
109 3
     */
110
    public function has(string $className): bool
111 3
    {
112
        $result = array_key_exists($className, $this->settingsMap);
113
114
        return $result;
115
    }
116
117 1
    /**
118
     * @inheritdoc
119 1
     */
120
    public function isAmbiguous(string $className): bool
121 1
    {
122
        $result = array_key_exists($className, $this->ambiguousMap);
123
124
        return $result;
125
    }
126
127
    /**
128
     * @param ApplicationConfigurationInterface $appConfig
129
     * @param CoreData                          $coreData
130
     * @param InstanceSettingsProvider          $provider
131
     *
132
     * @return self
133 6
     *
134
     * @throws ReflectionException
135
     */
136
    public function setInstanceSettings(
137
        ApplicationConfigurationInterface $appConfig,
138 6
        CoreData $coreData,
139 6
        InstanceSettingsProvider $provider
140 6
    ): self {
141 6
        $this->unserialize([
0 ignored issues
show
The call to the method Limoncello\Application\S...Provider::unserialize() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
142 6
            static::KEY_APPLICATION_CONFIGURATION => $appConfig->get(),
143 6
            static::KEY_CORE_DATA                 => $coreData->get(),
144
            static::KEY_SETTINGS_MAP              => $provider->getSettingsMap(),
145
            static::KEY_SETTINGS_DATA             => $provider->getSettingsData(),
146 6
            static::KEY_AMBIGUOUS_MAP             => $provider->getAmbiguousMap(),
147
        ]);
148
149
        return $this;
150
    }
151
152 2
    /**
153
     * @inheritdoc
154
     */
155 2
    public function serialize(): array
156 2
    {
157 2
        return [
158 2
            static::KEY_APPLICATION_CONFIGURATION => $this->appConfig,
159 2
            static::KEY_CORE_DATA                 => $this->coreData,
160
            static::KEY_SETTINGS_MAP              => $this->settingsMap,
161
            static::KEY_SETTINGS_DATA             => $this->settingsData,
162
            static::KEY_AMBIGUOUS_MAP             => $this->ambiguousMap,
163
        ];
164
    }
165
166 6
    /**
167
     * @inheritdoc
168
     */
169 6
    public function unserialize(array $serialized): void
170 6
    {
171 6
        [
172 6
            static::KEY_APPLICATION_CONFIGURATION => $this->appConfig,
173 6
            static::KEY_CORE_DATA                 => $this->coreData,
174
            static::KEY_SETTINGS_MAP              => $this->settingsMap,
175
            static::KEY_SETTINGS_DATA             => $this->settingsData,
176
            static::KEY_AMBIGUOUS_MAP             => $this->ambiguousMap,
177
         ] = $serialized;
178
    }
179
}
180