Issues (127)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

class/PermissionsHandler.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace XoopsModules\Wgfilemanager;
7
8
/*
9
 You may not change or alter any portion of this comment or credits
10
 of supporting developers from this source code or any supporting source code
11
 which is considered copyrighted (c) material of the original comment or credit authors.
12
13
 This program 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.
16
*/
17
18
/**
19
 * wgFileManager module for xoops
20
 *
21
 * @copyright    2021 XOOPS Project (https://xoops.org)
22
 * @license      GPL 2.0 or later
23
 * @package      wgfilemanager
24
 * @author       Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
25
 */
26
27
use XoopsModules\Wgfilemanager;
28
use XoopsModule;
29
30
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
31
32
/**
33
 * Class Object PermissionsHandler
34
 */
35
class PermissionsHandler extends \XoopsPersistableObjectHandler
36
{
37
    /**
38
     * Constructor
39
     *
40
     */
41
    public function __construct()
42
    {
43
    }
44
45
46
    /******************************************
47
     * Global permissions
48
    /*******************************************/
49
50
51
    /**
52
     * @private function getPermGlobal
53
     * returns right for given perm
54
     * @param $constantPerm
55
     * @return bool
56
     */
57
    private function getPermGlobal($constantPerm)
58
    {
59
        global $xoopsUser;
60
61
        $moduleDirName = \basename(\dirname(__DIR__));
62
        $mid = XoopsModule::getByDirname($moduleDirName)->mid();
63
        $currentuid = 0;
64
        if (isset($xoopsUser) && \is_object($xoopsUser)) {
65
            if ($xoopsUser->isAdmin($mid)) {
66
                return true;
67
            }
68
            $currentuid = $xoopsUser->uid();
69
        }
70
        $grouppermHandler = \xoops_getHandler('groupperm');
71
72
        $memberHandler = \xoops_getHandler('member');
73
        if (0 === $currentuid) {
74
            $my_group_ids = [\XOOPS_GROUP_ANONYMOUS];
75
        } else {
76
            $my_group_ids = $memberHandler->getGroupsByUser($currentuid);
0 ignored issues
show
The method getGroupsByUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsMembershipHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

76
            /** @scrutinizer ignore-call */ 
77
            $my_group_ids = $memberHandler->getGroupsByUser($currentuid);
Loading history...
77
        }
78
        switch ($constantPerm) {
79
            //case Constants::PERM_GLOBAL_APPROVE:
80
            case Constants::PERM_GLOBAL_SUBMIT:
81
            case Constants::PERM_GLOBAL_VIEW:
82
            case Constants::PERM_GLOBAL_DOWNLOAD:
83
            //case Constants::PERM_GLOBAL_UPLOAD:
84
                $permName = 'wgfilemanager_global';
85
                break;
86
            case 0:
87
            default:
88
                $permName = '';
89
                break;
90
        }
91
        return $grouppermHandler->checkRight($permName, $constantPerm, $my_group_ids, $mid);
0 ignored issues
show
The method checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

91
        return $grouppermHandler->/** @scrutinizer ignore-call */ checkRight($permName, $constantPerm, $my_group_ids, $mid);
Loading history...
92
93
    }
94
95
    /**
96
     * @public function permGlobalApprove
97
     * returns right for global approve
98
     *
99
     * @return bool
100
     */
101
    /*public function getPermGlobalApprove()
102
    {
103
        return $this->getPermGlobal(Constants::PERM_GLOBAL_APPROVE);
104
    }*/
105
106
    /**
107
     * @public function permGlobalSubmit
108
     * returns right for global submit
109
     *
110
     * @return bool
111
     */
112
    public function getPermGlobalSubmit()
113
    {
114
        return $this->getPermGlobal(Constants::PERM_GLOBAL_SUBMIT);
115
    }
116
117
    /**
118
     * @public function permGlobalView
119
     * returns right for global view
120
     *
121
     * @return bool
122
     */
123
    public function getPermGlobalView()
124
    {
125
        return $this->getPermGlobal(Constants::PERM_GLOBAL_VIEW);
126
    }
127
128
    /**
129
     * @public function getPermGlobalDownload
130
     * returns right for global download
131
     *
132
     * @return bool
133
     */
134
    public function getPermGlobalDownload()
135
    {
136
        return $this->getPermGlobal(Constants::PERM_GLOBAL_DOWNLOAD);
137
    }
138
139
140
141
    /******************************************
142
     * Permissions for directories
143
    /*******************************************/
144
145
    /**
146
     * @private function getPermGlobal
147
     * returns right for given perm
148
     * @param $constantPerm
149
     * @return bool
150
     */
151
    private function getPermDirectory($constantPerm, $dirId)
152
    {
153
        global $xoopsUser;
154
155
        $moduleDirName = \basename(\dirname(__DIR__));
156
        $mid = XoopsModule::getByDirname($moduleDirName)->mid();
157
        $currentuid = 0;
158
        if (isset($xoopsUser) && \is_object($xoopsUser)) {
159
            if ($xoopsUser->isAdmin($mid)) {
160
                return true;
161
            }
162
            $currentuid = $xoopsUser->uid();
163
        }
164
        $grouppermHandler = \xoops_getHandler('groupperm');
165
166
        $memberHandler = \xoops_getHandler('member');
167
        if (0 === $currentuid) {
168
            $my_group_ids = [\XOOPS_GROUP_ANONYMOUS];
169
        } else {
170
            $my_group_ids = $memberHandler->getGroupsByUser($currentuid);
171
        }
172
        switch ($constantPerm) {
173
            //case Constants::PERM_DIRECTORY_APPROVE:
174
            case Constants::PERM_DIRECTORY_SUBMIT:
175
                $permName = 'wgfilemanager_submit_directory';
176
                break;
177
            case Constants::PERM_DIRECTORY_VIEW:
178
                $permName = 'wgfilemanager_view_directory';
179
                break;
180
            case Constants::PERM_FILE_DOWNLOAD_FROM_DIR:
181
                $permName = 'wgfilemanager_download_directory';
182
                break;
183
            case Constants::PERM_FILE_UPLOAD_TO_DIR:
184
                $permName = 'wgfilemanager_upload_directory';
185
                break;
186
            case 0:
187
            default:
188
                $permName = '';
189
                break;
190
        }
191
192
        return $grouppermHandler->checkRight($permName, $dirId, $my_group_ids, $mid);
193
194
    }
195
    /**
196
     * @public function getPermApproveDirectory
197
     * returns right for approve directory
198
     *
199
     * param int $dirId
200
     * @return bool
201
     */
202
    /*public function getPermApproveDirectory($dirId)
203
    {
204
205
        if ($this->getPermGlobalApprove()) {
206
            return true;
207
        }
208
        return $this->getPermDirectory(Constants::PERM_DIRECTORY_APPROVE, $dirId);
209
210
    }*/
211
212
    /**
213
     * @public function getPermSubmitDirectory
214
     * returns right for creating/editing directory
215
     *
216
     * param int $dirId
217
     * @return bool
218
     */
219
    public function getPermSubmitDirectory($dirId)
220
    {
221
222
        if ($this->getPermGlobalSubmit()) {
223
            return true;
224
        }
225
        return $this->getPermDirectory(Constants::PERM_DIRECTORY_SUBMIT, $dirId);
226
227
    }
228
229
    /**
230
     * @public function getPermViewDirectory
231
     * returns right for view directory
232
     *
233
     * param int $dirId
234
     * @return bool
235
     */
236
    public function getPermViewDirectory($dirId)
237
    {
238
239
        if ($this->getPermGlobalView()) {
240
            return true;
241
        }
242
        return $this->getPermDirectory(Constants::PERM_DIRECTORY_VIEW, $dirId);
243
244
    }
245
246
    /******************************************
247
     * Permissions for files
248
    /*******************************************/
249
250
    /**
251
     * @public function getPermDownloadDirectory
252
     * returns right for downloading files from directory
253
     *
254
     * param int $dirId
255
     * @return bool
256
     */
257
    public function getPermDownloadFileFromDir($dirId)
258
    {
259
        if ($this->getPermGlobalDownload()) {
260
            return true;
261
        }
262
        return $this->getPermDirectory(Constants::PERM_FILE_DOWNLOAD_FROM_DIR, $dirId);
263
264
    }
265
266
    /**
267
     * @public function getPermUploadDirectory
268
     * returns right for uploading file to directory
269
     *
270
     * param int $dirId
271
     * @return bool
272
     */
273
    public function getPermUploadFileToDir($dirId)
274
    {
275
        if ($this->getPermGlobalSubmit()) {
276
            return true;
277
        }
278
        return $this->getPermDirectory(Constants::PERM_FILE_UPLOAD_TO_DIR, $dirId);
279
280
    }
281
282
}
283