Issues (380)

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/CategoryHandler.php (1 issue)

1
<?php
2
3
namespace XoopsModules\Newbb;
4
5
/**
6
 * NewBB 5.0x,  the forum module for XOOPS project
7
 *
8
 * @copyright      XOOPS Project (https://xoops.org)
9
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
10
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
11
 * @since          4.00
12
 * @package        module::newbb
13
 */
14
15
use XoopsModules\Newbb;
16
17
 /**
18
 * Class CategoryHandler
19
 */
20
class CategoryHandler extends \XoopsPersistableObjectHandler
21
{
22
    /**
23
     * @param null|\XoopsDatabase $db
24
     */
25
    public function __construct(\XoopsDatabase $db = null)
26
    {
27
        parent::__construct($db, 'newbb_categories', Category::class, 'cat_id', 'cat_title');
28
    }
29
30
    /**
31
     * @param string $perm
32
     * @return mixed
33
     */
34
    public function getIdsByPermission($perm = 'access')
35
    {
36
        /** var Newbb\PermissionHandler $permHandler */
37
        $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
38
39
        return $permHandler->getCategories($perm);
40
    }
41
42
    /**
43
     * @param string $permission
44
     * @param null   $tags
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $tags is correct as it would always require null to be passed?
Loading history...
45
     * @param bool   $asObject
46
     * @return array
47
     */
48
    public function &getByPermission($permission = 'access', $tags = null, $asObject = true)
49
    {
50
        $categories = [];
51
        if (!$valid_ids = $this->getIdsByPermission($permission)) {
52
            return $categories;
53
        }
54
        $criteria = new \Criteria('cat_id', '(' . \implode(', ', $valid_ids) . ')', 'IN');
55
        $criteria->setSort('cat_order');
56
        $categories = $this->getAll($criteria, $tags, $asObject);
57
58
        return $categories;
59
    }
60
61
    /**
62
     * @param \XoopsObject $category
63
     * @param bool         $force
64
     * @return mixed
65
     */
66
    public function insert(\XoopsObject $category, $force = true)
67
    {
68
        $className = Category::class;
69
        if (!($category instanceof $className)) {
70
            return false;
71
        }
72
        parent::insert($category, $force);
73
        if ($category->isNew()) {
74
            $this->applyPermissionTemplate($category);
75
        }
76
77
        return $category->getVar('cat_id');
78
    }
79
80
    /**
81
     * @param \XoopsObject $category
82
     * @param bool         $force
83
     * @return bool|mixed
84
     * @internal param Category $category
85
     */
86
    public function delete(\XoopsObject $category, $force = false)//delete(Category $category)
87
    {
88
        $className = Category::class;
89
        if (!($category instanceof $className)) {
90
            return false;
91
        }
92
        /** @var Newbb\ForumHandler $forumHandler */
93
        $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
94
        $forumHandler->deleteAll(new \Criteria('cat_id', $category->getVar('cat_id')), true, true);
95
        $result = parent::delete($category);
96
        if ($result) {
97
            // Delete group permissions
98
            return $this->deletePermission($category);
99
        }
100
        $category->setErrors('delete category error');
101
102
        return false;
103
    }
104
105
    /**
106
     * Check permission for a category
107
     *
108
     * @param Category|int $category object or id
109
     * @param string       $perm     permission name
110
     *
111
     * @return bool
112
     */
113
    public function getPermission($category, $perm = 'access')
114
    {
115
        if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
116
            return true;
117
        }
118
119
        $cat_id = \is_object($category) ? $category->getVar('cat_id') : (int)$category;
120
        /** @var PermissionHandler $permHandler */
121
        $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
122
123
        return $permHandler->getPermission('category', $perm, $cat_id);
124
    }
125
126
    /**
127
     * @param Category $category
128
     * @return mixed
129
     */
130
    public function deletePermission(Category $category)
131
    {
132
        /** @var PermissionHandler $permHandler */
133
        $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
134
135
        return $permHandler->deleteByCategory($category->getVar('cat_id'));
136
    }
137
138
    /**
139
     * @param Category $category
140
     * @return mixed
141
     */
142
    public function applyPermissionTemplate(Category $category)
143
    {
144
        /** @var PermissionHandler $permHandler */
145
        $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
146
147
        return $permHandler->setCategoryPermission($category->getVar('cat_id'));
148
    }
149
150
    /**
151
     * @param mixed $object
152
     * @return bool
153
     */
154
    public function synchronization($object = null)
155
    {
156
        return true;
157
    }
158
}
159