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/BaseObject.php (11 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       Brian Wahoff <[email protected]>
19
 * @author       Eric Juden <[email protected]>
20
 * @author       XOOPS Development Team
21
 */
22
23
/**
24
 * class BaseObject
25
 */
26
class BaseObject extends \XoopsObject
27
{
28
    /**
29
     * create a new  object
30
     * @return BaseObject {@link BaseObject}
31
     */
32
    public function &create(): BaseObject
33
    {
34
        return new $this->classname();
0 ignored issues
show
Bug Best Practice introduced by
The property classname does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
35
    }
36
37
    /**
38
     * retrieve an object from the database, based on. use in child classes
39
     * @param int $id ID
40
     * @return DepartmentMailBox|bool
41
     */
42
    public function get(int $id)
43
    {
44
        $id = $id;
45
        if ($id > 0) {
46
            $sql = $this->selectQuery(new \Criteria('id', (string)$id));
47
            if (!$result = $this->db->query($sql)) {
0 ignored issues
show
Bug Best Practice introduced by
The property db does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
48
                return false;
49
            }
50
            $numrows = $this->db->getRowsNum($result);
51
            if (1 == $numrows) {
52
                $obj = new $this->classname($this->db->fetchArray($result));
0 ignored issues
show
Bug Best Practice introduced by
The property classname does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
53
54
                return $obj;
55
            }
56
        }
57
58
        return false;
59
    }
60
61
    /**
62
     * Create a "select" SQL query
63
     * @param \CriteriaElement|null $criteria {@link CriteriaElement} to match
64
     * @return string SQL query
65
     */
66
    public function selectQuery(\CriteriaElement $criteria = null): string
67
    {
68
        $sql = \sprintf('SELECT * FROM `%s`', $this->db->prefix($this->dbtable));
0 ignored issues
show
Bug Best Practice introduced by
The property dbtable does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property db does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
69
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
70
            $sql .= ' ' . $criteria->renderWhere();
71
            if ('' != $criteria->getSort()) {
72
                $sql .= ' ORDER BY ' . $criteria->getSort() . '
73
                   ' . $criteria->getOrder();
74
            }
75
        }
76
77
        return $sql;
78
    }
79
80
    /**
81
     * count objects matching a criteria
82
     *
83
     * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link CriteriaElement} to match
84
     * @return int    count of objects
85
     */
86
    public function getCount($criteria = null): int
87
    {
88
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($this->dbtable);
0 ignored issues
show
Bug Best Practice introduced by
The property dbtable does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property db does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
89
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
90
            $sql .= ' ' . $criteria->renderWhere();
91
        }
92
        if (!$result = $this->db->query($sql)) {
93
            return 0;
94
        }
95
        [$count] = $this->db->fetchRow($result);
96
97
        return $count;
98
    }
99
100
    /**
101
     * delete object based on id
102
     *
103
     * @param \XoopsObject $obj
104
     * @param bool         $force
105
     * @return bool true/false on deleting objects
106
     * @internal param CriteriaElement $criteria  to match
107
     */
108
    public function delete(\XoopsObject $obj, bool $force = false): bool
109
    {
110
        if (0 != \strcasecmp($this->classname, \get_class($obj))) {
0 ignored issues
show
Bug Best Practice introduced by
The property classname does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
111
            return false;
112
        }
113
114
        $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), $obj->getVar('id'));
0 ignored issues
show
It seems like $obj->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

114
        $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), /** @scrutinizer ignore-type */ $obj->getVar('id'));
Loading history...
Bug Best Practice introduced by
The property db does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property dbtable does not exist on XoopsModules\Xhelp\BaseObject. Did you maybe forget to declare it?
Loading history...
115
        if ($force) {
116
            $result = $this->db->queryF($sql);
117
        } else {
118
            $result = $this->db->query($sql);
119
        }
120
        if (!$result) {
121
            return false;
122
        }
123
124
        return true;
125
    }
126
}
127