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.

mediawiki/include/MediawikiManager.class.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
/**
3
 * Copyright (c) Enalean, 2014. All rights reserved
4
 *
5
 * This file is a part of Tuleap.
6
 *
7
 * Tuleap is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * Tuleap is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/
19
 */
20
21
class MediawikiManager {
22
23
    const READ_ACCESS  = 'PLUGIN_MEDIAWIKI_READ';
24
    const WRITE_ACCESS = 'PLUGIN_MEDIAWIKI_WRITE';
25
26
    /** @var MediawikiDao */
27
    private $dao;
28
29
    public function __construct(MediawikiDao $dao) {
30
        $this->dao = $dao;
31
    }
32
33
    public function saveCompatibilityViewOption(Project $project, $compatibility_view_option) {
34
        $project_id                = $project->getID();
35
        $enable_compatibility_view = $compatibility_view_option ? $compatibility_view_option : 0;
36
37
        return $this->dao->updateCompatibilityViewOption($project_id, $enable_compatibility_view);
38
    }
39
40
    /**
41
     * @return int[]
42
     */
43
    public function getReadAccessControl(Project $project) {
44
        $ugroup_ids = $this->getAccessControl($project, self::READ_ACCESS);
45
46
        if (! $ugroup_ids) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $ugroup_ids 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...
47
            return $this->getDefaultReadAccessControl($project);
48
        }
49
50
        return $ugroup_ids;
51
    }
52
53
    /**
54
     * @return int[]
55
     */
56
    private function getDefaultReadAccessControl(Project $project) {
57
        if ($project->isPublic()) {
58
            return array(ProjectUGroup::REGISTERED);
59
        }
60
61
        return array(ProjectUGroup::PROJECT_MEMBERS);
62
    }
63
64
    /**
65
     * @return int[]
66
     */
67
    public function getWriteAccessControl(Project $project) {
68
        $ugroup_ids =  $this->getAccessControl($project, self::WRITE_ACCESS);
69
70
        if (! $ugroup_ids) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $ugroup_ids 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...
71
            return $this->getDefaultWriteAccessControl();
72
        }
73
74
        return $ugroup_ids;
75
    }
76
77
    /**
78
     * @return int[]
79
     */
80
    private function getDefaultWriteAccessControl() {
81
        return array(ProjectUGroup::PROJECT_MEMBERS);
82
    }
83
84
    /**
85
     * @return array
86
     */
87
    private function getAccessControl(Project $project, $access) {
88
        $result     = $this->dao->getAccessControl($project->getID(), $access);
89
        $ugroup_ids = array();
90
91
        foreach ($result as $row) {
0 ignored issues
show
The expression $result of type false|object is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
92
            $ugroup_ids[] = $row['ugroup_id'];
93
        }
94
95
        return $ugroup_ids;
96
    }
97
98
99
    public function saveReadAccessControl(Project $project, array $ugroup_ids) {
100
        return $this->saveAccessControl($project, self::READ_ACCESS, $ugroup_ids);
101
    }
102
103
    public function saveWriteAccessControl(Project $project, array $ugroup_ids) {
104
        return $this->saveAccessControl($project, self::WRITE_ACCESS, $ugroup_ids);
105
    }
106
107
    private function saveAccessControl(Project $project, $access, array $ugroup_ids) {
108
        return $this->dao->saveAccessControl($project->getID(), $access, $ugroup_ids);
109
    }
110
111
    public function updateAccessControlInProjectChangeContext(
112
        Project $project,
113
        $old_access,
114
        $new_access
115
    ) {
116
        if ($new_access == Project::ACCESS_PRIVATE) {
117
            return $this->dao->disableAnonymousRegisteredAuthenticated($project->getID());
118
        }
119
        if ($new_access == Project::ACCESS_PUBLIC && $old_access == Project::ACCESS_PUBLIC_UNRESTRICTED) {
120
            return $this->dao->disableAuthenticated($project->getID());
121
        }
122
    }
123
124
    public function updateSiteAccess($old_value) {
125
        if ($old_value == ForgeAccess::ANONYMOUS) {
126
            $this->dao->updateAllAnonymousToRegistered();
127
        }
128
        if ($old_value == ForgeAccess::RESTRICTED) {
129
            $this->dao->updateAllAuthenticatedToRegistered();
130
        }
131
    }
132
133
    /**
134
     * @return bool
135
     */
136
    public function isCompatibilityViewEnabled(Project $project) {
137
        $plugin_has_view_enabled = (bool) forge_get_config('enable_compatibility_view', 'mediawiki');
138
        $result                  = $this->dao->getCompatibilityViewUsage($project->getID());
139
140
        if (! $result) {
141
            return false;
142
        }
143
144
        return ($plugin_has_view_enabled && (bool) $result['enable_compatibility_view']);
145
    }
146
147
    public function instanceUsesProjectID(Project $project) {
148
        return is_dir(forge_get_config('projects_path', 'mediawiki') . "/". $project->getID());
149
    }
150
151
    private function restrictedUserCanRead(PFUser $user, Project $project) {
152
        return in_array(ProjectUGroup::AUTHENTICATED, $this->getReadAccessControl($project)) || in_array(ProjectUGroup::ANONYMOUS, $this->getReadAccessControl($project));
153
    }
154
155
    private function restrictedUserCanWrite(PFUser $user, Project $project) {
156
        return in_array(ProjectUGroup::AUTHENTICATED, $this->getWriteAccessControl($project)) || in_array(ProjectUGroup::ANONYMOUS, $this->getWriteAccessControl($project));
157
    }
158
159
    private function getUpgroupsPermissionsManager() {
160
        return new User_ForgeUserGroupPermissionsManager(
161
            new User_ForgeUserGroupPermissionsDao()
162
        );
163
    }
164
165
    private function hasDelegatedAccess(PFUser $user) {
166
        return $this->getUpgroupsPermissionsManager()->doesUserHavePermission(
167
            $user,
168
            new User_ForgeUserGroupPermission_MediawikiAdminAllProjects()
169
        );
170
    }
171
    /**
172
     * @param PFUser $user
173
     * @param Project $project
174
     * @return bool true if user can read
175
     */
176
    public function userCanRead(PFUser $user, Project $project) {
177
        if ($this->hasDelegatedAccess($user)) {
178
            return true;
179
        }
180
181
        if ($this->userIsRestrictedAndNotProjectMember($user, $project)) {
182
            return $this->restrictedUserCanRead($user, $project);
183
        }
184
185
        $common_ugroups_ids = array_intersect(
186
            $this->getReadAccessControl($project),
187
            $user->getUgroups($project->getID(), array())
188
        );
189
190
        return !empty($common_ugroups_ids);
191
    }
192
193
    /**
194
     * @param PFUser $user
195
     * @param Project $project
196
     * @return bool true if user can write
197
     */
198
    public function userCanWrite(PFUser $user, Project $project) {
199
        if ($this->hasDelegatedAccess($user)) {
200
            return true;
201
        }
202
203
        if ($this->userIsRestrictedAndNotProjectMember($user, $project)) {
204
            return $this->restrictedUserCanWrite($user, $project);
205
        }
206
207
        $common_ugroups_ids = array_intersect(
208
            $this->getWriteAccessControl($project),
209
            $user->getUgroups($project->getID(), array())
210
        );
211
212
        return !empty($common_ugroups_ids);
213
    }
214
215
    private function userIsRestrictedAndNotProjectMember(PFUser $user, Project $project) {
216
        return $project->allowsRestricted() && $user->isRestricted() && ! $user->isMember($project->getID());
217
    }
218
}
219