Issues (1507)

Security Analysis    not enabled

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.

PHPDaemon/Config/Entry/Generic.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 PHPDaemon\Config\Entry;
3
4
/**
5
 * Config entry
6
 *
7
 * @package    Core
8
 * @subpackage Config
9
 *
10
 * @author     Vasily Zorin <[email protected]>
11
 */
12
class Generic
13
{
14
    use \PHPDaemon\Traits\ClassWatchdog;
15
    use \PHPDaemon\Traits\StaticObjectWatchdog;
16
17
    /** @var */
18
    public $defaultValue;
19
    /** @var */
20
    public $value;
21
    /** @var */
22
    public $valueType;
23
    /** @var */
24
    public $humanValue;
25
    /** @var */
26
    public $source;
27
    /** @var */
28
    public $revision;
29
    /** @var bool */
30
    public $hasDefaultValue = false;
31
    /** @var bool */
32
    protected $stackable = false;
33
34
    /**
35
     * Constructor
36
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
37
     */
38
    public function __construct()
39
    {
40
        if (func_num_args() === 1) {
41
            $this->setDefaultValue(func_get_arg(0));
42
            $this->setHumanValue(func_get_arg(0));
43
        }
44
    }
45
46
    /**
47
     * Set default value
48
     * @param mixed
49
     * @return void
50
     */
51
    public function setDefaultValue($value)
52
    {
53
        $this->defaultValue = $value;
54
        $this->hasDefaultValue = true;
55
    }
56
57
    /**
58
     * Converts plain value to human-readable
59
     * @param mixed
60
     * @return mixed
61
     */
62
    public static function plainToHuman($value)
63
    {
64
        return $value;
65
    }
66
67
    /**
68
     * Get human value
69
     * @return mixed
70
     */
71
    public function getHumanValue()
72
    {
73
        return $this->humanValue;
74
    }
75
76
    /**
77
     * Set human-readable value
78
     * @param mixed
79
     * @return void
80
     */
81 View Code Duplication
    public function setHumanValue($value)
0 ignored issues
show
This method seems to be duplicated in 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...
82
    {
83
        $this->humanValue = $value;
84
        $old = $this->value;
85
        $this->value = static::humanToPlain($value);
86
        $this->onUpdate($old);
87
    }
88
89
    /**
90
     * Get value
91
     * @return mixed
92
     */
93
    public function getValue()
94
    {
95
        return $this->value;
96
    }
97
98
    /**
99
     * Set value
100
     * @param mixed
101
     * @return void
102
     */
103 View Code Duplication
    public function setValue($value)
0 ignored issues
show
This method seems to be duplicated in 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...
104
    {
105
        $old = $this->value;
106
        $this->value = $value;
107
        $this->humanValue = static::plainToHuman($value);
108
        $this->onUpdate($old);
109
    }
110
111
    /**
112
     * @return bool
113
     */
114
    public function isStackable()
115
    {
116
        return $this->stackable;
117
    }
118
119
    /**
120
     * @param bool $b
121
     */
122
    public function setStackable($b = true)
123
    {
124
        $this->stackable = $b;
125
    }
126
127
    /**
128
     * Push human-readable value
129
     * @param $value
130
     * @return void
131
     */
132
    public function pushHumanValue($value)
133
    {
134
        $this->pushValue(static::humanToPlain($value));
135
    }
136
137
    /**
138
     * Push plain value
139
     * @param $value
140
     * @return void
141
     */
142
    public function pushValue($value)
143
    {
144
        $old = $this->value;
145
        if (!$this->stackable) {
146
            $this->setValue($value);
147
            return;
148
        }
149
        if (!is_array($this->value)) {
150
            $this->value = [$this->value, $value];
151
        } else {
152
            $f = false;
153
            foreach ($this->value as $k => $v) {
154
                if (!is_int($k)) {
155
                    $f = true;
156
                    break;
157
                }
158
            }
159
            if (!$f) {
160
                $this->value[] = $value;
161
            } else {
162
                $this->value = [$this->value, $value];
163
            }
164
        }
165
        $this->onUpdate($old);
166
    }
167
168
    /**
169
     * Called when
170
     * @return void
171
     */
172
    public function onUpdate($old)
173
    {
174
    }
175
176
    /**
177
     * Converts human-readable value to plain
178
     * @param mixed
179
     * @return mixed
180
     */
181
    public static function humanToPlain($value)
182
    {
183
        return $value;
184
    }
185
186
    /**
187
     * Set value type
188
     * @param mixed
189
     * @return void
190
     */
191
    public function setValueType($type)
192
    {
193
        $this->valueType = $type;
194
    }
195
196
    /**
197
     * Reset to default
198
     * @return boolean Success
199
     */
200
    public function resetToDefault()
201
    {
202
        if ($this->hasDefaultValue) {
203
            $this->setHumanValue($this->defaultValue);
204
            return true;
205
        }
206
        return false;
207
    }
208
}
209