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 (4873)

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.

include/PluginsAdministrationActions.class.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
 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4
 * Copyright (c) Enalean, 2015. All Rights Reserved.
5
 *
6
 * This file is a part of Tuleap.
7
 *
8
 * Tuleap is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Tuleap is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
23
class PluginsAdministrationActions extends Actions {
24
25
    /** @var PluginManager */
26
    private $plugin_manager;
27
28
    /** @var PluginDependencySolver */
29
    private $dependency_solver;
30
31
    public function __construct(&$controler, $view = null) {
32
        $this->Actions($controler);
33
        $this->plugin_manager = PluginManager::instance();
34
        $this->dependency_solver = new PluginDependencySolver($this->plugin_manager);
35
    }
36
    
37
    // {{{ Actions
38
    function available() {
39
        $plugin_data = $this->_getPluginFromRequest();
40
        if ($plugin_data) {
41
            $plugin_manager = $this->plugin_manager;
42
            $dependencies = $this->dependency_solver->getUnmetAvailableDependencies($plugin_data['plugin']);
43
            if ($dependencies) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $dependencies of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
44
                $error_msg = $GLOBALS['Language']->getText(
45
                    'plugin_pluginsadministration',
46
                    'error_unavail_dependency',
47
                    array($plugin_data['plugin']->getName(), implode(', ', $dependencies))
48
                );
49
                $GLOBALS['Response']->addFeedback('error', $error_msg);
50
                return;
51
            }
52
            if (!$plugin_manager->isPluginAvailable($plugin_data['plugin'])) {
53
                $plugin_manager->availablePlugin($plugin_data['plugin']);
54
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_pluginsadministration', 'feedback_available', array($plugin_data['name'])));
55
            }
56
        }
57
    }
58
    
59
    function install() {
60
        $request =& HTTPRequest::instance();
61
        $name = $request->get('name');
62
        if ($name) {
63
            $this->plugin_manager->installPlugin($name);
64
        }
65
    }
66
    
67
    function unavailable() {
68
        $plugin_data = $this->_getPluginFromRequest();
69
        if ($plugin_data) {
70
            $plugin_manager = $this->plugin_manager;
71
            $dependencies = $this->dependency_solver->getAvailableDependencies($plugin_data['plugin']);
72
            if ($dependencies) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $dependencies of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
73
                $error_msg = $GLOBALS['Language']->getText(
74
                    'plugin_pluginsadministration',
75
                    'error_avail_dependency',
76
                    array($plugin_data['plugin']->getName(), implode(', ', $dependencies))
77
                );
78
                $GLOBALS['Response']->addFeedback('error', $error_msg);
79
                return;
80
            }
81
            if ($plugin_manager->isPluginAvailable($plugin_data['plugin'])) {
82
                $plugin_manager->unavailablePlugin($plugin_data['plugin']);
83
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_pluginsadministration', 'feedback_unavailable', array($plugin_data['name'])));
84
            }
85
        }
86
    }
87
    
88
    function uninstall() {
89
        $plugin = $this->_getPluginFromRequest();
90
        if ($plugin) {
91
            $plugin_manager = $this->plugin_manager;
92
            $uninstalled = $plugin_manager->uninstallPlugin($plugin['plugin']);
93
            if (!$uninstalled) {
94
                 $GLOBALS['feedback'] .= '<div>'.$GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_not_uninstalled', array($plugin['name'])).'</div>';
95
            } else {
96
                 $GLOBALS['feedback'] .= '<div>'.$GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_uninstalled', array($plugin['name'])).'</div>';
97
            }
98
        }
99
    }
100
101
    // Secure args: force each value to be an integer.    
102
    function _validateProjectList($usList) {
103
        $sPrjList = null;
104
        $usList = trim(rtrim($usList));
105
        if($usList) {
106
            $usPrjList = explode(',', $usList);
107
            $sPrjList = array_map('intval', $usPrjList);
108
        }
109
        return $sPrjList;
110
    }
111
112
    function _addAllowedProjects($prjList) {
113
        $plugin = $this->_getPluginFromRequest();
114
        $plugin_manager = $this->plugin_manager;
115
        $plugin_manager->addProjectForPlugin($plugin['plugin'], $prjList);
116
    }
117
118
    function _delAllowedProjects($prjList) {
119
        $plugin = $this->_getPluginFromRequest();
120
        $plugin_manager = $this->plugin_manager;
121
        $plugin_manager->delProjectForPlugin($plugin['plugin'], $prjList);
122
    }
123
124
    function _changePluginGenericProperties($properties) {
125
        if(isset($properties['allowed_project'])) {
126
            $sPrjList = $this->_validateProjectList($properties['allowed_project']);
127
            if($sPrjList !== null) {
128
                $this->_addAllowedProjects($sPrjList);
129
            }
130
        }
131
        if(isset($properties['disallowed_project'])) {
132
            $sPrjList = $this->_validateProjectList($properties['disallowed_project']);
133
            if($sPrjList !== null) {
134
                $this->_delAllowedProjects($sPrjList);
135
            }
136
        }
137
        if(isset($properties['prj_restricted'])) {
138
            $plugin = $this->_getPluginFromRequest();
139
            $plugin_manager = $this->plugin_manager;
140
            $resricted = ($properties['prj_restricted'] == 1 ? true : false);
141
            $plugin_manager->updateProjectPluginRestriction($plugin['plugin'], $resricted);
142
        }
143
    }
144
145
    function changePluginProperties() {
146
        $request =& HTTPRequest::instance();
147
        if($request->exist('gen_prop')) {
148
            $this->_changePluginGenericProperties($request->get('gen_prop'));
149
        }
150
        $user_properties = $request->get('properties');
151
        if ($user_properties) {
152
            $plugin = $this->_getPluginFromRequest();
153
            $plug_info =& $plugin['plugin']->getPluginInfo();
154
            $descs =& $plug_info->getPropertyDescriptors();
155
            $keys  =& $descs->getKeys();
156
            $iter  =& $keys->iterator();
157
            $props = '';
158
            while($iter->valid()) {
159
                $key   =& $iter->current();
160
                $desc  =& $descs->get($key);
161
                $prop_name = $desc->getName();
162
                if (isset($user_properties[$prop_name])) {
163
                    $val = $user_properties[$prop_name];
164
                    if (is_bool($desc->getValue())) {
165
                        $val = $val ? true : false;
166
                    }
167
                    $desc->setValue($val);
168
                }
169
                $iter->next();
170
            }
171
            $plug_info->saveProperties();
172
        }
173
    }
174
    // }}}
175
    
176
    
177
    function _getPluginFromRequest() {
178
        $return = false;
179
        $request =& HTTPRequest::instance();
180
        if ($request->exist('plugin_id') && is_numeric($request->get('plugin_id'))) {
181
            $plugin_manager = $this->plugin_manager;
182
            $plugin =& $plugin_manager->getPluginById($request->get('plugin_id'));
183
            if ($plugin) {
184
                $plug_info  =& $plugin->getPluginInfo();
185
                $descriptor =& $plug_info->getPluginDescriptor();
186
                $name = $descriptor->getFullName();
187
                if (strlen(trim($name)) === 0) {
188
                    $name = get_class($plugin);
189
                }
190
                $return = array();
191
                $return['name'] = $name;
192
                $return['plugin'] =& $plugin;
193
            }
194
        }
195
        return $return;
196
    }
197
198
    public function setPluginRestriction() {
199
        $request                    = HTTPRequest::instance();
200
        $plugin_id                  = $request->get('plugin_id');
201
        $plugin_data                = $this->_getPluginFromRequest();
202
        $all_allowed                = $request->get('all-allowed');
203
204
        if ($plugin_data) {
205
            $plugin = $plugin_data['plugin'];
206
207
            $this->checkSynchronizerToken(
208
                '/plugins/pluginsadministration/?action=set-plugin-restriction&plugin_id=' . $plugin_id
209
            );
210
211
            if ($all_allowed) {
212
                $this->unsetPluginRestricted($plugin);
213
214
            } else {
215
                $this->setPluginRestricted($plugin);
216
            }
217
218
            $this->redirectToPluginAdministration($plugin_id);
219
        }
220
    }
221
222
    private function setPluginRestricted(Plugin $plugin) {
223
        if ($this->getPluginResourceRestrictor()->setPluginRestricted($plugin)) {
224
            $GLOBALS['Response']->addFeedback(
225
                Feedback::INFO,
226
                $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_set_restricted')
227
            );
228
        } else {
229
            $this->sendProjectRestrictedError();
230
        }
231
    }
232
233
    private function unsetPluginRestricted(Plugin $plugin) {
234
        if ($this->getPluginResourceRestrictor()->unsetPluginRestricted($plugin)) {
235
            $GLOBALS['Response']->addFeedback(
236
                Feedback::INFO,
237
                $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_unset_restricted')
238
            );
239
        } else {
240
            $this->sendProjectRestrictedError();
241
        }
242
    }
243
244
    private function sendProjectRestrictedError() {
245
        $GLOBALS['Response']->addFeedback(
246
            Feedback::ERROR,
247
            $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_restricted_error')
248
        );
249
    }
250
251
    public function updateAllowedProjectList() {
252
        $request                    = HTTPRequest::instance();
253
        $plugin_id                  = $request->get('plugin_id');
254
        $plugin_data                = $this->_getPluginFromRequest();
255
        $project_to_add             = $request->get('project-to-allow');
256
        $project_ids_to_remove      = $request->get('project-ids-to-revoke');
257
258
        if ($plugin_data) {
259
            $plugin = $plugin_data['plugin'];
260
261
            $this->checkSynchronizerToken('/plugins/pluginsadministration/?action=update-allowed-project-list&plugin_id=' . $plugin_id);
262
263
            if ($request->get('allow-project') && ! empty($project_to_add)) {
264
                $this->allowProjectOnPlugin($plugin, $project_to_add);
265
266
            } elseif ($request->get('revoke-project') && ! empty($project_ids_to_remove)) {
267
                $this->revokeProjectsFromPlugin($plugin, $project_ids_to_remove);
268
            }
269
        }
270
271
        $this->redirectToPluginAdministration($plugin->getId());
272
    }
273
274
    private function redirectToPluginAdministration($plugin_id) {
275
        $GLOBALS['Response']->redirect(
276
            '/plugins/pluginsadministration/?view=restrict&plugin_id=' . $plugin_id
277
        );
278
    }
279
280
    private function allowProjectOnPlugin(Plugin $plugin, $project_to_add) {
281
        $project_manager            = ProjectManager::instance();
282
        $plugin_resource_restrictor = $this->getPluginResourceRestrictor();
283
        $project                    = $project_manager->getProjectFromAutocompleter($project_to_add);
284
285
        if ($project && $plugin_resource_restrictor->allowProjectOnPlugin($plugin, $project)) {
286
            $GLOBALS['Response']->addFeedback(
287
                Feedback::INFO,
288
                $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_allow_project')
289
            );
290
        } else {
291
            $this->sendUpdateProjectListError();
292
        }
293
294
    }
295
296
    private function revokeProjectsFromPlugin(Plugin $plugin, $project_ids) {
297
        $plugin_resource_restrictor = $this->getPluginResourceRestrictor();
298
299
        if (count($project_ids) > 0 && $plugin_resource_restrictor->revokeProjectsFromPlugin($plugin, $project_ids)) {
300
            $GLOBALS['Response']->addFeedback(
301
                Feedback::INFO,
302
                $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_revoke_projects')
303
            );
304
        } else {
305
            $this->sendUpdateProjectListError();
306
        }
307
308
    }
309
310
    private function sendUpdateProjectListError() {
311
        $GLOBALS['Response']->addFeedback(
312
            Feedback::ERROR,
313
            $GLOBALS['Language']->getText('plugin_pluginsadministration', 'plugin_allowed_project_update_project_list_error')
314
        );
315
    }
316
317
    private function checkSynchronizerToken($url) {
318
        $token = new CSRFSynchronizerToken($url);
319
        $token->check();
320
    }
321
322
    private function getPluginResourceRestrictor() {
323
        return new PluginResourceRestrictor(
324
            new RestrictedPluginDao()
325
        );
326
    }
327
}
328