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.

plugins/phpwiki/include/phpwikiPlugin.class.php (1 issue)

Labels
Severity

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, 2015. All Rights Reserved.
4
 *
5
 * Tuleap is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * Tuleap is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with Tuleap; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 */
19
20
require_once 'constants.php';
21
22
class phpwikiPlugin extends Plugin {
23
24
    const SEARCH_PAGENAME_EN = 'FullTextSearch';
25
    const SEARCH_PAGENAME_FR = 'RechercheEnTexteIntégral';
26
27
    public function __construct($id) {
28
        parent::__construct($id);
29
        $this->setScope(self::SCOPE_PROJECT);
30
31
        $this->name = 'phpwiki';
32
        $this->text = 'PHPWiki';
33
34
        $this->addHook(Event::LAYOUT_SEARCH_ENTRY);
35
        $this->addHook(Event::SEARCH_TYPE);
36
        $this->addHook(Event::SEARCH_TYPES_PRESENTERS);
37
38
        $this->addHook('backend_system_purge_files', 'purgeFiles');
39
40
        $this->addHook(Event::SERVICE_ICON);
41
        $this->addHook(Event::SERVICES_ALLOWED_FOR_PROJECT);
42
        $this->addHook(Event::SERVICE_PUBLIC_AREAS);
43
44
        $this->addHook(Event::GET_SYSTEM_EVENT_CLASS);
45
        $this->addHook(Event::SYSTEM_EVENT_GET_TYPES_FOR_DEFAULT_QUEUE);
46
        $this->addHook('site_admin_option_hook');
47
48
        if ($this->isDocmanPluginActivated()) {
49
            $this->addHook(PLUGIN_DOCMAN_EVENT_GET_PHPWIKI_PAGE, 'getWikiPage');
50
        }
51
52
        $this->addHook('phpwiki_redirection');
53
54
        $this->addHook(Event::SERVICES_TRUNCATED_EMAILS);
55
56
        $this->addHook(Event::REST_PROJECT_GET_PHPWIKI);
57
        $this->addHook(Event::REST_PROJECT_OPTIONS_PHPWIKI);
58
        $this->addHook(EVENT::REST_RESOURCES);
59
        $this->addHook(EVENT::REST_PROJECT_RESOURCES);
60
61
    }
62
63
    private function isDocmanPluginActivated() {
64
        return defined('PLUGIN_DOCMAN_BASE_DIR');
65
    }
66
67
    public function getPluginInfo() {
68
        if (!is_a($this->pluginInfo, 'PHPWikiPluginInfo')) {
69
            $this->pluginInfo = new PHPWikiPluginInfo($this);
70
        }
71
        return $this->pluginInfo;
72
    }
73
74
    public function getServiceShortname() {
75
        return 'plugin_phpwiki';
76
    }
77
78
    public function service_icon($params) {
79
        $params['list_of_icon_unicodes'][$this->getServiceShortname()] = '\e803';
80
    }
81
82
    public function service_public_areas($params) {
83
        if ($params['project']->usesService($this->getServiceShortname())) {
84
            $service   = $params['project']->getService($this->getServiceShortname());
85
            $wiki      = new PHPWiki($params['project']->getID());
86
87
            $presenter = new WidgetPublicAreaPresenter(
88
                $service->getUrl(),
89
                $GLOBALS['HTML']->getImagePath('ic/wiki.png'),
90
                $this->text,
91
                $wiki->getProjectPageCount()
92
            );
93
            $renderer          = TemplateRendererFactory::build()->getRenderer(PHPWIKI_TEMPLATE_DIR);
94
            $params['areas'][] = $renderer->renderToString('widget_public_area', $presenter);
95
        }
96
    }
97
98
    public function process(HTTPRequest $request) {
99
        $wiki = new PHPWikiService($request->get('group_id'));
100
        $wiki->process();
101
    }
102
103
    public function processAdmin(HTTPRequest $request) {
104
        $wiki = new PHPWikiServiceAdmin($request->get('group_id'));
105
        $wiki->process();
106
    }
107
108
    public function processUpload(HTTPRequest $request) {
109
        $attch       = new PHPWikiAttachment();
110
        $request_uri = preg_replace('/^\/wiki/', PHPWIKI_PLUGIN_BASE_URL, $request->getFromServer('REQUEST_URI'));
111
        $attch->setUri($request_uri);
0 ignored issues
show
It seems like $request_uri defined by preg_replace('/^\\/wiki/...mServer('REQUEST_URI')) on line 110 can also be of type array<integer,string>; however, PHPWikiAttachment::setUri() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
112
        if($attch->exist() && $attch->isActive()) {
113
            if($attch->isAutorized(user_getid())) {
114
                $attch->htmlDump();
115
            }
116
        }
117
        else {
118
            exit_error($GLOBALS['Language']->getText('global','error'),
119
                       $GLOBALS['Language']->getText('plugin_phpwiki_attachment_upload', 'err_not_exist'));
120
        }
121
    }
122
123
    public function layout_search_entry($params) {
124
        $is_in_phpwiki = strpos($_SERVER['REQUEST_URI'], PHPWIKI_PLUGIN_BASE_URL . '/') !== false;
125
        $params['search_entries'][] = array(
126
            'value'    => $this->name,
127
            'label'    => $this->text,
128
            'selected' => $is_in_phpwiki,
129
        );
130
    }
131
132
    public function search_type($params) {
133
        $query   = $params['query'];
134
        $project = $query->getProject();
135
        if ($query->getTypeOfSearch() === $this->name) {
136
            if (!$project->isError()) {
137
                util_return_to($this->getPhpwikiSearchURI($project, $query->getWords()));
138
            }
139
        }
140
    }
141
142
    public function search_types_presenters($params) {
143
        if ($this->isSearchEntryAvailable($params['project'])) {
144
            $params['project_presenters'][] = new Search_SearchTypePresenter(
145
                $this->name,
146
                $this->text,
147
                array(),
148
                $this->getPhpwikiSearchURI($params['project'], $params['words'])
149
            );
150
        }
151
    }
152
153
    private function isSearchEntryAvailable(Project $project = null) {
154
        if ($project && !$project->isError()) {
155
            return $project->usesService('plugin_phpwiki');
156
        }
157
        return false;
158
    }
159
160
    private function getPhpwikiSearchURI(Project $project, $words) {
161
        $project_id = $project->getID();
162
        $page_name  = $this->getSearchPageName($project->getID());
163
        return $this->getPluginPath() . '/index.php?group_id=' . $project_id . '&pagename=' . urlencode($page_name) . '&s=' . urlencode($words);
164
    }
165
166
    private function getSearchPageName($project_id) {
167
        $wiki_dao    = new PHPWikiDao();
168
        $search_page = self::SEARCH_PAGENAME_EN;
169
        if ($wiki_dao->searchLanguage($project_id) == 'fr_FR') {
170
            $search_page = self::SEARCH_PAGENAME_FR;
171
        }
172
173
        return $search_page;
174
    }
175
176
    public function purgeFiles($params) {
177
        $wiki_attachment = new PHPWikiAttachment();
178
        $wiki_attachment->purgeAttachments($params['time']);
179
    }
180
181
    public function getWikiPage($params) {
182
        $project_manager = ProjectManager::instance();
183
        $project         = $project_manager->getProject($params['project_id']);
184
        if ($project->usesService($this->getServiceShortname())) {
185
            $wiki_page              = new PHPWikiPage($params['project_id'], $params['wiki_page_name']);
186
            $params['phpwiki_page'] = $wiki_page;
187
        }
188
    }
189
190
    public function phpwiki_redirection($params) {
191
        $request       = HTTPRequest::instance();
192
        $project       = $request->getProject();
193
        if ($project && $project->usesService($this->getServiceShortname())) {
194
            $requested_uri = $request->getFromServer('REQUEST_URI');
195
            $new_uri       = preg_replace('/^\/wiki/', PHPWIKI_PLUGIN_BASE_URL, $requested_uri);
196
            $GLOBALS['Response']->redirect($new_uri);
197
        }
198
    }
199
200
    public function site_admin_option_hook() {
201
        echo '<li><a href="' . $this->getPluginPath() . '/admin.php?action=index">' . $this->text . '</a></li>';
202
    }
203
204
    public function system_event_get_types_for_default_queue(array &$params) {
205
        $params['types'] = array_merge($params['types'], array(SystemEvent_PHPWIKI_SWITCH_TO_PLUGIN::NAME));
206
    }
207
208
    public function get_system_event_class($params) {
209
        switch($params['type']) {
210
            case SystemEvent_PHPWIKI_SWITCH_TO_PLUGIN::NAME:
211
                $params['class']        = 'SystemEvent_PHPWIKI_SWITCH_TO_PLUGIN';
212
                $params['dependencies'] = array(
213
                    $this->getPHPWikiMigratorDao()
214
                );
215
        }
216
    }
217
218
    private function getPHPWikiMigratorDao() {
219
        return new PHPWikiMigratorDao();
220
    }
221
222
    public function services_truncated_emails($params) {
223
        $project = $params['project'];
224
        if ($project->usesService($this->getServiceShortname())) {
225
            $params['services'][] = $GLOBALS['Language']->getText('plugin_phpwiki', 'service_lbl_key');
226
        }
227
    }
228
229
    public function rest_project_get_phpwiki($params) {
230
        $user    = $params['user'];
231
        $project = $params['project'];
232
233
        if (! $this->userCanAccessPhpWikiService($user, $project)) {
234
            $class_exception = 'Luracast\Restler\RestException';
235
            throw new $class_exception(403, 'You are not allowed to access the PHPWiki plugin');
236
        }
237
238
        if ($project->usesService($this->getServiceShortname())) {
239
            $class            = 'Tuleap\PhpWiki\REST\v1\ProjectResource';
240
            $project_resource = new $class($this->getPaginatedPHPWikiPagesFactory());
241
            $project          = $params['project'];
242
243
            $params['result'] = $project_resource->getPhpWikiPlugin(
244
                $user,
245
                $project->getID(),
246
                $params['limit'],
247
                $params['offset'],
248
                $params['pagename']
249
            );
250
        }
251
    }
252
253
    public function rest_project_options_phpwiki($params) {
254
        $params['activated'] = true;
255
    }
256
257
    /**
258
     * @return bool
259
     */
260
    private function userCanAccessPhpWikiService(PFUser $user, Project $project) {
261
        $wiki = new PHPWiki($project->getID());
262
        return $wiki->isAutorized($user->getId());
263
    }
264
265
    /**
266
     * @return PaginatedPHPWikiPagesFactory
267
     */
268
    private function getPaginatedPHPWikiPagesFactory() {
269
        return new PaginatedPHPWikiPagesFactory(new PHPWikiDao());
270
    }
271
272
    /**
273
     * @see REST_RESOURCES
274
     */
275
    public function rest_resources($params) {
276
        $injector = new PHPWikiPlugin_REST_ResourcesInjector();
277
        $injector->populate($params['restler']);
278
    }
279
280
    /**
281
     * @see Event::REST_PROJECT_RESOURCES
282
     */
283
    public function rest_project_resources(array $params) {
284
        $injector = new PHPWikiPlugin_REST_ResourcesInjector();
285
        $injector->declarePhpWikiPluginResource($params['resources'], $params['project']);
286
    }
287
}
288