GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (2)

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/Feature.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
 *
4
 */
5
6
namespace Opensoft\Rollout;
7
8
/**
9
 * @author Richard Fullmer <[email protected]>
10
 */
11
class Feature
12
{
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18
    /**
19
     * @var array
20
     */
21
    private $groups = array();
22
23
    /**
24
     * @var array
25
     */
26
    private $users = array();
27
28
    /**
29
     * @var integer
30
     */
31
    private $percentage = 0;
32
33
    /**
34
     * @var string|null
35
     */
36
    private $requestParam;
37
38
    /**
39
     * @var array
40
     */
41
    private $data = array();
42
43
    /**
44
     * @param string $name
45
     * @param string|null $settings
46
     */
47
    public function __construct($name, $settings = null)
48
    {
49
        $this->name = $name;
50
        if ($settings) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $settings of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
51
            $settings = explode('|', $settings);
52
53
            if (isset($settings[3])) {
54
                $rawRequestParam = $settings[3];
55
                $this->requestParam = $rawRequestParam;
56
            }
57
58
            //We can not trust the list function because of backwords compatibility
59
            if (isset($settings[4])) {
60
                $rawData = $settings[4];
61
                $this->data = !empty($rawData)? json_decode($rawData, true) : array();
0 ignored issues
show
Documentation Bug introduced by
It seems like !empty($rawData) ? json_...awData, true) : array() of type * is incompatible with the declared type array of property $data.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
62
            }
63
64
            list($rawPercentage, $rawUsers, $rawGroups) = $settings;
65
            $this->percentage = (int) $rawPercentage;
66
            $this->users = !empty($rawUsers) ? explode(',', $rawUsers) : array();
67
            $this->groups = !empty($rawGroups) ? explode(',', $rawGroups) : array();
68
        } else {
69
            $this->clear();
70
        }
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getName()
77
    {
78
        return $this->name;
79
    }
80
81
    /**
82
     * @param integer $percentage
83
     */
84
    public function setPercentage($percentage)
85
    {
86
        $this->percentage = $percentage;
87
    }
88
89
    /**
90
     * @return integer
91
     */
92
    public function getPercentage()
93
    {
94
        return $this->percentage;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function serialize()
101
    {
102
        return implode('|', array(
103
            $this->percentage,
104
            implode(',', $this->users),
105
            implode(',', $this->groups),
106
            $this->requestParam,
107
            json_encode($this->data)
108
        ));
109
    }
110
111
    /**
112
     * @param RolloutUserInterface $user
113
     */
114
    public function addUser(RolloutUserInterface $user)
115
    {
116
        if (!in_array($user->getRolloutIdentifier(), $this->users)) {
117
            $this->users[] = $user->getRolloutIdentifier();
118
        }
119
    }
120
121
    /**
122
     * @param RolloutUserInterface $user
123
     */
124
    public function removeUser(RolloutUserInterface $user)
125
    {
126
        if (($key = array_search($user->getRolloutIdentifier(), $this->users)) !== false) {
127
            unset($this->users[$key]);
128
        }
129
    }
130
131
    /**
132
     * @return array
133
     */
134
    public function getUsers()
135
    {
136
        return $this->users;
137
    }
138
139
    /**
140
     * @param string $group
141
     */
142
    public function addGroup($group)
143
    {
144
        if (!in_array($group, $this->groups)) {
145
            $this->groups[] = $group;
146
        }
147
    }
148
149
    /**
150
     * @param string $group
151
     */
152
    public function removeGroup($group)
153
    {
154
        if (($key = array_search($group, $this->groups)) !== false) {
155
            unset($this->groups[$key]);
156
        }
157
    }
158
159
    /**
160
     * @return array
161
     */
162
    public function getGroups()
163
    {
164
        return $this->groups;
165
    }
166
167
    /**
168
     * @return string|null
169
     */
170
    public function getRequestParam()
171
    {
172
        return $this->requestParam;
173
    }
174
175
    /**
176
     * @param string|null $requestParam
177
     */
178
    public function setRequestParam($requestParam)
179
    {
180
        $this->requestParam = $requestParam;
181
    }
182
183
    /**
184
     * @return array
185
     */
186
    public function getData()
187
    {
188
        return $this->data;
189
    }
190
191
    /**
192
     * @param array $data
193
     */
194
    public function setData(array $data)
195
    {
196
        $this->data = $data;
197
    }
198
199
    /**
200
     * Clear the feature of all configuration
201
     */
202
    public function clear()
203
    {
204
        $this->groups = array();
205
        $this->users = array();
206
        $this->percentage = 0;
207
        $this->requestParam = '';
208
        $this->data = array();
209
    }
210
211
    /**
212
     * Is the feature active?
213
     *
214
     * @param Rollout $rollout
215
     * @param RolloutUserInterface|null $user
216
     * @param array $requestParameters
217
     * @return bool
218
     */
219
    public function isActive(Rollout $rollout, RolloutUserInterface $user = null, array $requestParameters = array())
220
    {
221
        if (null == $user) {
222
            return $this->isParamInRequestParams($requestParameters)
223
                || $this->percentage == 100
224
                || $this->isInActiveGroup($rollout);
225
        }
226
227
        return $this->isParamInRequestParams($requestParameters) ||
228
            $this->isUserInPercentage($user) ||
229
            $this->isUserInActiveUsers($user) ||
230
            $this->isInActiveGroup($rollout, $user);
231
    }
232
233
    /**
234
     * @return array
235
     */
236
    public function toArray()
237
    {
238
        return array(
239
            'percentage' => $this->percentage,
240
            'groups' => $this->groups,
241
            'users' => $this->users,
242
            'requestParam' => $this->requestParam,
243
            'data'=> $this->data
244
        );
245
    }
246
247
    /**
248
     * @param array $requestParameters
249
     * @return bool
250
     */
251
    private function isParamInRequestParams(array $requestParameters)
252
    {
253
        $param = explode('=', $this->requestParam);
254
        $key = array_shift($param);
255
        $value = array_shift($param);
256
257
        return $key && array_key_exists($key, $requestParameters) &&
258
            (empty($value) || $requestParameters[$key] == $value);
259
    }
260
261
    /**
262
     * @param RolloutUserInterface $user
263
     * @return bool
264
     */
265
    private function isUserInPercentage(RolloutUserInterface $user)
266
    {
267
        return abs(crc32($user->getRolloutIdentifier()) % 100) < $this->percentage;
268
    }
269
270
    /**
271
     * @param RolloutUserInterface $user
272
     * @return boolean
273
     */
274
    private function isUserInActiveUsers(RolloutUserInterface $user)
275
    {
276
        return in_array($user->getRolloutIdentifier(), $this->users);
277
    }
278
279
    /**
280
     * @param Rollout $rollout
281
     * @param RolloutUserInterface|null $user
282
     * @return bool
283
     */
284
    private function isInActiveGroup(Rollout $rollout, RolloutUserInterface $user = null)
285
    {
286
        foreach ($this->groups as $group) {
287
            if ($rollout->isActiveInGroup($group, $user)) {
288
                return true;
289
            }
290
        }
291
292
        return false;
293
    }
294
}
295