Issues (32)

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/Config/VaultConfiguration.php (1 issue)

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 Storeman\Config;
4
5
use Storeman\Validation\Constraints as StoremanAssert;
6
use Symfony\Component\Validator\Constraints as Assert;
7
use Symfony\Component\Validator\Mapping\ClassMetadata;
8
use Zend\Stdlib\ArraySerializableInterface;
9
10
class VaultConfiguration implements ArraySerializableInterface
11
{
12
    /**
13
     * @var Configuration
14
     */
15
    protected $configuration;
16
17
    /**
18
     * An arbitrary user-defined title that helps to identity a vault by some user-specific information.
19
     *
20
     * @var string
21
     */
22
    protected $title = 'unknown';
23
24
    /**
25
     * Identifier for the vault layout to use.
26
     *
27
     * @var string
28
     */
29
    protected $vaultLayout = 'amberjack';
30
31
    /**
32
     * Identifier for the vault adapter to use.
33
     *
34
     * @var string
35
     */
36
    protected $adapter = 'unknown';
37
38
    /**
39
     * Identifier for the lock adapter to use.
40
     *
41
     * @var string
42
     */
43
    protected $lockAdapter = 'storage';
44
45
    /**
46
     * Identifier for the index merger to be used.
47
     *
48
     * @var string
49
     */
50
    protected $indexMerger = 'standard';
51
52
    /**
53
     * Identifier for the conflict handler to use.
54
     *
55
     * @var string
56
     */
57
    protected $conflictHandler = 'panicking';
58
59
    /**
60
     * Identifier for the operation list builder to use.
61
     *
62
     * @var string
63
     */
64
    protected $operationListBuilder = 'standard';
65
66
    /**
67
     * The vault priority is used for cases where some data has to be read from a vault and a decision has to be made which vault to use.
68
     *
69
     * @var int
70
     */
71
    protected $priority = 0;
72
73
    /**
74
     * Map with additional component-specific settings.
75
     *
76
     * @var array
77
     */
78
    protected $settings = [];
79
80
    public function __construct(Configuration $configuration)
81
    {
82
        $this->configuration = $configuration;
83
        $this->configuration->addVault($this);
84
    }
85
86
    public function getConfiguration(): Configuration
87
    {
88
        return $this->configuration;
89
    }
90
91
    public function getTitle(): string
92
    {
93
        return $this->title;
94
    }
95
96
    public function setTitle(string $title): VaultConfiguration
97
    {
98
        $this->title = $title;
99
100
        return $this;
101
    }
102
103
    public function getVaultLayout(): string
104
    {
105
        return $this->vaultLayout;
106
    }
107
108
    public function setVaultLayout(string $vaultLayout): VaultConfiguration
109
    {
110
        $this->vaultLayout = $vaultLayout;
111
112
        return $this;
113
    }
114
115
    public function getAdapter(): string
116
    {
117
        return $this->adapter;
118
    }
119
120
    public function setAdapter(string $adapter): VaultConfiguration
121
    {
122
        $this->adapter = $adapter;
123
124
        return $this;
125
    }
126
127
    public function getLockAdapter(): string
128
    {
129
        return $this->lockAdapter;
130
    }
131
132
    public function setLockAdapter(string $lockAdapter): VaultConfiguration
133
    {
134
        $this->lockAdapter = $lockAdapter;
135
136
        return $this;
137
    }
138
139
    public function getIndexMerger(): string
140
    {
141
        return $this->indexMerger;
142
    }
143
144
    public function setIndexMerger(string $indexMerger): VaultConfiguration
145
    {
146
        $this->indexMerger = $indexMerger;
147
148
        return $this;
149
    }
150
151
    public function getConflictHandler(): string
152
    {
153
        return $this->conflictHandler;
154
    }
155
156
    public function setConflictHandler(string $conflictHandler): VaultConfiguration
157
    {
158
        $this->conflictHandler = $conflictHandler;
159
160
        return $this;
161
    }
162
163
    public function getOperationListBuilder(): string
164
    {
165
        return $this->operationListBuilder;
166
    }
167
168
    public function setOperationListBuilder(string $operationListBuilder): VaultConfiguration
169
    {
170
        $this->operationListBuilder = $operationListBuilder;
171
172
        return $this;
173
    }
174
175
    public function getPriority(): int
176
    {
177
        return $this->priority;
178
    }
179
180
    public function setPriority(int $priority): VaultConfiguration
181
    {
182
        $this->priority = $priority;
183
184
        return $this;
185
    }
186
187
    public function getSettings(): array
188
    {
189
        return $this->settings;
190
    }
191
192
    public function hasSetting(string $name): bool
193
    {
194
        return array_key_exists($name, $this->settings);
195
    }
196
197
    public function getSetting(string $name)
198
    {
199
        return array_key_exists($name, $this->settings) ? $this->settings[$name] : null;
200
    }
201
202
    public function setSettings(array $settings): VaultConfiguration
203
    {
204
        $this->settings = $settings;
205
206
        return $this;
207
    }
208
209
    public function setSetting(string $name, $value): VaultConfiguration
210
    {
211
        $this->settings[$name] = $value;
212
213
        return $this;
214
    }
215
216
    /**
217
     * {@inheritdoc}
218
     */
219
    public function exchangeArray(array $array)
220
    {
221 View Code Duplication
        if ($diff = array_diff(array_keys($array), array_keys($this->getArrayCopy())))
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
222
        {
223
            throw new \InvalidArgumentException("Invalid index(es): " . implode(',', $diff));
224
        }
225
226
        foreach ($array as $key => $value)
227
        {
228
            // using setter to prevent skipping validation
229
            call_user_func([$this, 'set' . ucfirst($key)], $value);
230
        }
231
    }
232
233
    /**
234
     * {@inheritdoc}
235
     */
236
    public function getArrayCopy()
237
    {
238
        $array = get_object_vars($this);
239
240
        unset($array['configuration']);
241
242
        return $array;
243
    }
244
245
    public static function loadValidatorMetadata(ClassMetadata $metadata)
246
    {
247
        $metadata->addPropertyConstraint('title', new Assert\NotBlank());
248
        $metadata->addPropertyConstraint('adapter', new StoremanAssert\StorageAdapterExists());
249
        $metadata->addPropertyConstraint('conflictHandler', new StoremanAssert\ConflictHandlerExists());
250
        $metadata->addPropertyConstraint('indexMerger', new StoremanAssert\IndexMergerExists());
251
        $metadata->addPropertyConstraint('lockAdapter', new StoremanAssert\LockAdapterExists());
252
        $metadata->addPropertyConstraint('operationListBuilder', new StoremanAssert\OperationListBuilderExists());
253
    }
254
}
255