Issues (432)

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/Form/UserForm.php (10 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Suico\Form;
4
5
use XoopsModules\Suico\{
6
    Helper,
7
    Profile,
8
    ProfileHandler
9
};
10
use XoopsThemeForm;
11
use XoopsFormButton;
12
use XoopsFormHidden;
13
use XoopsFormLabel;
14
use XoopsFormSelectUser;
15
16
/**
17
 * Get {@link XoopsThemeForm} for editing a user
18
 *
19
 * @param \XoopsUser $user {@link \XoopsUser} to edit
20
 * @param Profile    $profile
21
 * @param bool       $action
22
 *
23
 */
24
class UserForm extends XoopsThemeForm
25
{
26
    /**
27
     * UserForm constructor.
28
     * @param \XoopsUser                       $user
29
     * @param \XoopsModules\Suico\Profile|null $profile
30
     * @param bool $action
31
     */
32
    public function __construct(\XoopsUser $user, Profile $profile = null, $action = false)
33
    {
34
        $helper = Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
35
        if (!$action) {
36
            $action = $_SERVER['REQUEST_URI'];
37
        }
38
        if (empty($GLOBALS['xoopsConfigUser'])) {
39
            /** @var \XoopsConfigHandler $configHandler */
40
            $configHandler              = \xoops_getHandler('config');
41
            $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(\XOOPS_CONF_USER);
42
        }
43
        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
44
        $title = $user->isNew() ? \_AM_SUICO_ADDUSER : \_US_EDITPROFILE;
45
        parent::__construct($title, 'userinfo', $action, 'post', true);
46
        /** @var ProfileHandler $profileHandler */
47
        $profileHandler = Helper::getInstance()->getHandler('Profile');
48
        // Dynamic fields
49
        if (!$profile) {
50
            /** @var ProfileHandler $profileHandler */
51
            $profileHandler = Helper::getInstance()->getHandler('Profile');
52
            $profile        = $profileHandler->get($user->getVar('uid'));
53
        }
54
        // Get fields
55
        $fields = $profileHandler->loadFields();
56
        // Get ids of fields that can be edited
57
        /** @var \XoopsGroupPermHandler $grouppermHandler */
58
        $grouppermHandler = \xoops_getHandler('groupperm');
59
        $editable_fields  = $grouppermHandler->getItemIds('profile_edit', $GLOBALS['xoopsUser']->getGroups(), $GLOBALS['xoopsModule']->getVar('mid'));
60
        if ($user->isNew() || $GLOBALS['xoopsUser']->isAdmin()) {
61
            $elements[0][] = [
0 ignored issues
show
Comprehensibility Best Practice introduced by
$elements was never initialized. Although not strictly required by PHP, it is generally a good practice to add $elements = array(); before regardless.
Loading history...
62
                'element'  => new \XoopsFormText(\_MD_SUICO_NICKNAME, 'uname', 25, $GLOBALS['xoopsUser']->isAdmin() ? 60 : $GLOBALS['xoopsConfigUser']['maxuname'], $user->getVar('uname', 'e')),
0 ignored issues
show
It seems like $user->getVar('uname', 'e') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

62
                'element'  => new \XoopsFormText(\_MD_SUICO_NICKNAME, 'uname', 25, $GLOBALS['xoopsUser']->isAdmin() ? 60 : $GLOBALS['xoopsConfigUser']['maxuname'], /** @scrutinizer ignore-type */ $user->getVar('uname', 'e')),
Loading history...
63
                'required' => 1,
64
            ];
65
            $email_text    = new \XoopsFormText('', 'email', 30, 60, $user->getVar('email'));
66
        } else {
67
            $elements[0][] = ['element' => new XoopsFormLabel(\_MD_SUICO_NICKNAME, $user->getVar('uname')), 'required' => 0];
0 ignored issues
show
It seems like $user->getVar('uname') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

67
            $elements[0][] = ['element' => new XoopsFormLabel(\_MD_SUICO_NICKNAME, /** @scrutinizer ignore-type */ $user->getVar('uname')), 'required' => 0];
Loading history...
68
            $email_text    = new XoopsFormLabel('', $user->getVar('email'));
69
        }
70
        $email_tray = new \XoopsFormElementTray(\_MD_SUICO_EMAILADDRESS, '<br>');
71
        $email_tray->addElement($email_text, ($user->isNew() || $GLOBALS['xoopsUser']->isAdmin()) ? 1 : 0);
0 ignored issues
show
$user->isNew() || $GLOBA...er']->isAdmin() ? 1 : 0 of type integer is incompatible with the type boolean expected by parameter $required of XoopsFormElementTray::addElement(). ( Ignorable by Annotation )

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

71
        $email_tray->addElement($email_text, /** @scrutinizer ignore-type */ ($user->isNew() || $GLOBALS['xoopsUser']->isAdmin()) ? 1 : 0);
Loading history...
72
        $weights[0][]  = 0;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$weights was never initialized. Although not strictly required by PHP, it is generally a good practice to add $weights = array(); before regardless.
Loading history...
73
        $elements[0][] = ['element' => $email_tray, 'required' => 0];
74
        $weights[0][]  = 0;
75
        if ($GLOBALS['xoopsUser']->isAdmin() && $user->getVar('uid') != $GLOBALS['xoopsUser']->getVar('uid')) {
76
            //If the user is an admin and is editing someone else
77
            $pwd_text  = new \XoopsFormPassword('', 'password', 10, 32);
78
            $pwd_text2 = new \XoopsFormPassword('', 'vpass', 10, 32);
79
            $pwd_tray  = new \XoopsFormElementTray(\_MD_SUICO_PASSWORD . '<br>' . \_MD_SUICO_CONFIRMPASSWORD);
80
            $pwd_tray->addElement($pwd_text);
81
            $pwd_tray->addElement($pwd_text2);
82
            $elements[0][] = ['element' => $pwd_tray, 'required' => 0]; //cannot set an element tray required
83
            $weights[0][]  = 0;
84
            $level_radio   = new \XoopsFormRadio(\_MD_SUICO_USERLEVEL, 'level', $user->getVar('level'));
0 ignored issues
show
It seems like $user->getVar('level') can also be of type array and array; however, parameter $value of XoopsFormRadio::__construct() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

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

84
            $level_radio   = new \XoopsFormRadio(\_MD_SUICO_USERLEVEL, 'level', /** @scrutinizer ignore-type */ $user->getVar('level'));
Loading history...
85
            $level_radio->addOption(1, \_MD_SUICO_ACTIVE);
86
            $level_radio->addOption(0, \_MD_SUICO_INACTIVE);
87
            //$level_radio->addOption(-1, _MD_SUICO_DISABLED);
88
            $elements[0][] = ['element' => $level_radio, 'required' => 0];
89
            $weights[0][]  = 0;
90
        }
91
        $elements[0][]   = ['element' => new XoopsFormHidden('uid', $user->getVar('uid')), 'required' => 0];
0 ignored issues
show
It seems like $user->getVar('uid') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

91
        $elements[0][]   = ['element' => new XoopsFormHidden('uid', /** @scrutinizer ignore-type */ $user->getVar('uid')), 'required' => 0];
Loading history...
92
        $weights[0][]    = 0;
93
        $elements[0][]   = ['element' => new XoopsFormHidden('op', 'save'), 'required' => 0];
94
        $weights[0][]    = 0;
95
        $categoryHandler = Helper::getInstance()->getHandler('Category');
96
        $categories      = [];
97
        $all_categories  = $categoryHandler->getObjects(null, true, false);
98
        $count_fields    = \count($fields);
99
        foreach (\array_keys($fields) as $i) {
100
            if (\in_array($fields[$i]->getVar('field_id'), $editable_fields, true)) {
101
                // Set default value for user fields if available
102
                if ($user->isNew()) {
103
                    $default = $fields[$i]->getVar('field_default');
104
                    if ('' !== $default && null !== $default) {
105
                        $user->setVar($fields[$i]->getVar('field_name'), $default);
106
                    }
107
                }
108
                if (null === $profile->getVar($fields[$i]->getVar('field_name'), 'n')) {
109
                    $default = $fields[$i]->getVar('field_default', 'n');
110
                    $profile->setVar($fields[$i]->getVar('field_name'), $default);
111
                }
112
                $fieldinfo['element']  = $fields[$i]->getEditElement($user, $profile);
113
                $fieldinfo['required'] = $fields[$i]->getVar('field_required');
114
                $key                   = @$all_categories[$fields[$i]->getVar('cat_id')]['cat_weight'] * $count_fields + $fields[$i]->getVar('cat_id');
115
                $elements[$key][]      = $fieldinfo;
116
                $weights[$key][]       = $fields[$i]->getVar('field_weight');
117
                $categories[$key]      = @$all_categories[$fields[$i]->getVar('cat_id')];
118
            }
119
        }
120
        if ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->isAdmin()) {
121
            \xoops_loadLanguage('admin', 'profile');
122
            /** @var \XoopsGroupPermHandler $grouppermHandler */
123
            $grouppermHandler = \xoops_getHandler('groupperm');
124
            //If user has admin rights on groups
125
            require_once $GLOBALS['xoops']->path('modules/system/constants.php');
126
            if ($grouppermHandler->checkRight('system_admin', \XOOPS_SYSTEM_GROUP, $GLOBALS['xoopsUser']->getGroups(), 1)) {
127
                //add group selection
128
                $group_select  = new \XoopsFormSelectGroup(\_MD_SUICO_USERGROUPS, 'groups', false, $user->getGroups(), 5, true);
129
                $elements[0][] = ['element' => $group_select, 'required' => 0];
130
                //set as latest;
131
                $weights[0][] = $count_fields + 1;
132
            }
133
        }
134
        \ksort($elements);
135
        foreach (\array_keys($elements) as $k) {
136
            \array_multisort($weights[$k], \SORT_ASC, \array_keys($elements[$k]), \SORT_ASC, $elements[$k]);
0 ignored issues
show
array_keys($elements[$k]) cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

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

136
            \array_multisort($weights[$k], \SORT_ASC, /** @scrutinizer ignore-type */ \array_keys($elements[$k]), \SORT_ASC, $elements[$k]);
Loading history...
SORT_ASC cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

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

136
            \array_multisort($weights[$k], /** @scrutinizer ignore-type */ \SORT_ASC, \array_keys($elements[$k]), \SORT_ASC, $elements[$k]);
Loading history...
137
            $title = isset($categories[$k]) ? $categories[$k]['cat_title'] : \_MD_SUICO_DEFAULT;
138
            $desc  = isset($categories[$k]) ? $categories[$k]['cat_description'] : '';
139
            $this->addElement(new XoopsFormLabel("<h3>{$title}</h3>", $desc), false);
140
            foreach (\array_keys($elements[$k]) as $i) {
141
                $this->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']);
142
            }
143
        }
144
        $this->addElement(new XoopsFormHidden('uid', $user->getVar('uid')));
145
        $this->addElement(new XoopsFormButton('', 'submit', \_MD_SUICO_SAVECHANGES, 'submit'));
146
    }
147
}
148