Issues (1844)

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/SavedSearchHandler.php (14 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Xhelp;
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
/**
16
 * @copyright    {@link https://xoops.org/ XOOPS Project}
17
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
18
 * @author       Eric Juden <[email protected]>
19
 * @author       XOOPS Development Team
20
 */
21
22
if (!\defined('XHELP_CLASS_PATH')) {
23
    exit();
24
}
25
// require_once XHELP_CLASS_PATH . '/BaseObjectHandler.php';
26
27
/**
28
 * SavedSearchHandler class
29
 *
30
 * SavedSearch Handler for SavedSearch class
31
 *
32
 * @author  Eric Juden <[email protected]> &
33
 */
34
class SavedSearchHandler extends BaseObjectHandler
35
{
36
    /**
37
     * Name of child class
38
     *
39
     * @var string
40
     */
41
    public $classname = SavedSearch::class;
42
    /**
43
     * DB table name
44
     *
45
     * @var string
46
     */
47
    public $dbtable = 'xhelp_saved_searches';
48
49
    private const TABLE = 'xhelp_saved_searches';
50
    private const ENTITY = SavedSearch::class;
51
    private const ENTITYNAME = 'SavedSearch';
52
    private const KEYNAME = 'id';
53
    private const IDENTIFIER = 'name';
54
55
    /**
56
     * Constructor
57
     *
58
     * @param \XoopsMySQLDatabase|null $db reference to a xoopsDB object
59
     */
60
    public function __construct(\XoopsMySQLDatabase $db = null)
61
    {
62
        $this->init($db);
63
        $this->helper = Helper::getInstance();
64
        parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
65
    }
66
67
    /**
68
     * @param \XoopsObject $object
69
     * @return string
70
     */
71
    public function insertQuery(\XoopsObject $object): string
72
    {
73
        //TODO mb replace with individual variables
74
        // Copy all object vars into local variables
75
        foreach ($object->cleanVars as $k => $v) {
76
            ${$k} = $v;
77
        }
78
79
        $sql = \sprintf('INSERT INTO `%s` (id, uid, NAME, search, pagenav_vars, hasCustFields) VALUES (%u, %d, %s, %s, %s, %u)', $this->db->prefix($this->dbtable), $id, $uid, $this->db->quoteString($name), $this->db->quoteString($search), $this->db->quoteString($pagenav_vars), $hasCustFields);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pagenav_vars seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $id seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $name seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $uid seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $hasCustFields seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $search seems to be never defined.
Loading history...
80
81
        return $sql;
82
    }
83
84
    /**
85
     * @param \XoopsObject $object
86
     * @return string
87
     */
88
    public function updateQuery(\XoopsObject $object): string
89
    {
90
        //TODO mb replace with individual variables
91
        // Copy all object vars into local variables
92
        foreach ($object->cleanVars as $k => $v) {
93
            ${$k} = $v;
94
        }
95
96
        $sql = \sprintf('UPDATE `%s` SET uid = %d, NAME = %s, search = %s, pagenav_vars = %s, hasCustFields = %u WHERE id = %u', $this->db->prefix($this->dbtable), $uid, $this->db->quoteString($name), $this->db->quoteString($search), $this->db->quoteString($pagenav_vars), $hasCustFields, $id);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $hasCustFields seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $search seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $uid seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $pagenav_vars seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $id seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $name seems to be never defined.
Loading history...
97
98
        return $sql;
99
    }
100
101
    /**
102
     * @param \XoopsObject $object
103
     * @return string
104
     */
105
    public function deleteQuery(\XoopsObject $object): string
106
    {
107
        $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), $object->getVar('id'));
0 ignored issues
show
It seems like $object->getVar('id') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|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

107
        $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), /** @scrutinizer ignore-type */ $object->getVar('id'));
Loading history...
108
109
        return $sql;
110
    }
111
112
    /**
113
     * @param int  $uid
114
     * @param bool $has_global
115
     * @return array
116
     */
117
    public function getByUid(int $uid, bool $has_global = false): array
118
    {
119
        $uid = $uid;
120
        if ($has_global) {
121
            $criteria = new \CriteriaCompo(new \Criteria('uid', $uid), 'OR');
122
            $criteria->add(new \Criteria('uid', \XHELP_GLOBAL_UID), 'OR');
123
        } else {
124
            $criteria = new \Criteria('uid', $uid);
125
        }
126
        $criteria->setOrder('ASC');
127
        $criteria->setSort('name');
128
        $ret = $this->getObjects($criteria);
129
130
        return $ret;
131
    }
132
133
    /**
134
     * @param \CriteriaElement|\CriteriaCompo $criteria
135
     * @return string
136
     */
137
    public function createSQL($criteria): string
138
    {
139
        $sql = $this->selectQuery($criteria);
140
141
        return $sql;
142
    }
143
144
    /**
145
     * delete department matching a set of conditions
146
     *
147
     * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link \CriteriaElement}
148
     * @return bool   FALSE if deletion failed
149
     */
150
    public function deleteAll(\CriteriaElement $criteria = null, $force = true, $asObject = false): bool
151
    {
152
        $sql = 'DELETE FROM ' . $this->db->prefix($this->dbtable);
153
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
154
            $sql .= ' ' . $criteria->renderWhere();
155
        }
156
        if (!$result = $this->db->query($sql)) {
0 ignored issues
show
The assignment to $result is dead and can be removed.
Loading history...
157
            return false;
158
        }
159
160
        return true;
161
    }
162
}
163