Issues (330)

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/GroupPermForm.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace XoopsModules\Lexikon;
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program 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.
13
 */
14
15
use XoopsForm;
16
use XoopsFormButton;
17
use XoopsFormElementTray;
18
use XoopsFormHidden;
19
use XoopsFormHiddenToken;
20
21
/**
22
 * @copyright    XOOPS Project (https://xoops.org)
23
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
24
 * @author      XOOPS Development Team, Kazumi Ono (AKA onokazu)
25
 */
26
27
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php';
28
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhidden.php';
29
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhiddentoken.php';
30
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formbutton.php';
31
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php';
32
require_once XOOPS_ROOT_PATH . '/class/xoopsform/form.php';
33
34
/**
35
 * Renders a form for setting module specific group permissions
36
 *
37
 * @author       Kazumi Ono    <[email protected]>
38
 * @copyright    copyright (c) 2000-2003 XOOPS.org
39
 *
40
 * @package      kernel
41
 * @subpackage   form
42
 */
43
class GroupPermForm extends XoopsForm
44
{
45
    /**
46
     * Module ID
47
     * @var int
48
     */
49
    public $_modid;
50
    /**
51
     * Tree structure of items
52
     * @var array
53
     */
54
    public $_itemTree = [];
55
    /**
56
     * Name of permission
57
     * @var string
58
     */
59
    public $_permName;
60
    /**
61
     * Description of permission
62
     * @var string
63
     */
64
    public $_permDesc;
65
    /**
66
     * Appendix
67
     * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
68
     */
69
    public $_appendix = [];
70
71
    /**
72
     * Constructor
73
     * @param $title
74
     * @param $modid
75
     * @param $permname
76
     * @param $permdesc
77
     */
78
    public function __construct($title, $modid, $permname, $permdesc)
79
    {
80
        //      $this->XoopsForm($title, 'groupperm_form', XOOPS_URL.'/modules/system/admin/groupperm.php', 'post'); GIJ
81
        parent::__construct($title, 'groupperm_form', '', 'post');
82
        $this->_modid    = (int)$modid;
83
        $this->_permName = $permname;
84
        $this->_permDesc = $permdesc;
85
        $this->addElement(new XoopsFormHidden('modid', $this->_modid));
86
        $this->addElement(new XoopsFormHiddenToken($permname));
87
    }
88
89
    /**
90
     * Adds an item to which permission will be assigned
91
     *
92
     * @param string $itemName
93
     * @param int    $itemId
94
     * @param int    $itemParent
95
     * @access public
96
     */
97
    public function addItem($itemId, $itemName, $itemParent = 0)
98
    {
99
        $this->_itemTree[$itemParent]['children'][] = $itemId;
100
        $this->_itemTree[$itemId]['parent']         = $itemParent;
101
        $this->_itemTree[$itemId]['name']           = $itemName;
102
        $this->_itemTree[$itemId]['id']             = $itemId;
103
    }
104
105
    /**
106
     * Add appendix
107
     *
108
     * @access public
109
     * @param $permName
110
     * @param $itemId
111
     * @param $itemName
112
     */
113
    public function addAppendix($permName, $itemId, $itemName)
114
    {
115
        $this->_appendix[] = [
116
            'permname' => $permName,
117
            'itemid'   => $itemId,
118
            'itemname' => $itemName,
119
            'selected' => false,
120
        ];
121
    }
122
123
    /**
124
     * Loads all child ids for an item to be used in javascript
125
     *
126
     * @param int   $itemId
127
     * @param array $childIds
128
     * @access private
129
     */
130
    public function _loadAllChildItemIds($itemId, &$childIds)
131
    {
132
        if (!empty($this->_itemTree[$itemId]['children'])) {
133
            $first_child = $this->_itemTree[$itemId]['children'];
134
            foreach ($first_child as $fcid) {
135
                $childIds[] = $fcid;
136
                if (!empty($this->_itemTree[$fcid]['children'])) {
137
                    foreach ($this->_itemTree[$fcid]['children'] as $_fcid) {
138
                        $childIds[] = $_fcid;
139
                        $this->_loadAllChildItemIds($_fcid, $childIds);
140
                    }
141
                }
142
            }
143
        }
144
    }
145
146
    /**
147
     * Renders the form
148
     *
149
     * @return string
150
     * @access public
151
     */
152
    public function render()
153
    {
154
        // load all child ids for javascript codes
155
        foreach (\array_keys($this->_itemTree) as $item_id) {
156
            $this->_itemTree[$item_id]['allchild'] = [];
157
            $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
158
        }
159
        /** @var \XoopsGroupPermHandler $grouppermHandler */
160
        $grouppermHandler = \xoops_getHandler('groupperm');
161
        /** @var \XoopsMemberHandler $memberHandler */
162
        $memberHandler = \xoops_getHandler('member');
163
        $glist         = $memberHandler->getGroupList();
164
        foreach (\array_keys($glist) as $i) {
165
            // get selected item id(s) for each group
166
            $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid);
167
            $ele      = new GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
168
            $ele->setOptionTree($this->_itemTree);
169
170
            foreach ($this->_appendix as $key => $append) {
171
                $this->_appendix[$key]['selected'] = $grouppermHandler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid);
172
            }
173
            $ele->setAppendix($this->_appendix);
174
            $this->addElement($ele);
175
            unset($ele);
176
        }
177
178
        // GIJ start
179
        $jstray          = new XoopsFormElementTray(' &nbsp; ');
180
        $jsuncheckbutton = new XoopsFormButton('', 'none', _NONE, 'button');
181
        $jsuncheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox') {elements[i].checked=false;}}}\"");
182
        $jscheckbutton = new XoopsFormButton('', 'all', _ALL, 'button');
183
        $jscheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if(elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)) {elements[i].checked=true;}}}\"");
184
        $jstray->addElement($jsuncheckbutton);
185
        $jstray->addElement($jscheckbutton);
186
        $this->addElement($jstray);
187
        // GIJ end
188
189
        $tray = new XoopsFormElementTray('');
190
        $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset'));
191
        $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
192
        $this->addElement($tray);
193
194
        $ret      = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br>';
195
        $ret      .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1'>\n";
196
        $elements = $this->getElements();
197
        foreach (\array_keys($elements) as $i) {
198
            if (!\is_object($elements[$i])) {
199
                $ret .= $elements[$i];
200
            } elseif (!$elements[$i]->isHidden()) {
201
                $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption();
202
                if ('' != $elements[$i]->getDescription()) {
203
                    $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>';
204
                }
205
                $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
0 ignored issues
show
Are you sure the usage of $elements[$i]->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
206
            } else {
207
                $ret .= $elements[$i]->render();
0 ignored issues
show
Are you sure the usage of $elements[$i]->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
208
            }
209
        }
210
        $ret .= '</table>' . $GLOBALS['xoopsSecurity']->getTokenHTML('myblocksadmin') . '</form>';
211
212
        return $ret;
213
    }
214
}
215