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

Severity
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_CONSTANTS_INCLUDED')) {
23
    exit();
24
}
25
26
// require_once XHELP_CLASS_PATH . '/BaseObjectHandler.php';
27
28
/**
29
 * TicketValues class
30
 *
31
 * Metadata that represents a custom value created for xhelp
32
 *
33
 * @author  Eric Juden <[email protected]>
34
 */
35
class TicketValues extends \XoopsObject
36
{
37
    private $fields = [];
38
    private $helper;
39
40
    /**
41
     * Class Constructor
42
     *
43
     * @param int|array|null $id
44
     * @internal param mixed $ticketid: null for a new object, hash table for an existing object
45
     */
46
    public function __construct($id = null)
47
    {
48
        $this->initVar('ticketid', \XOBJ_DTYPE_INT, null, false);
49
        $this->helper = Helper::getInstance();
50
        $this->helper->loadLanguage('admin');
51
52
        /** @var \XoopsModules\Xhelp\TicketFieldHandler $ticketFieldHandler */
53
        $ticketFieldHandler = $this->helper->getHandler('TicketField');
54
        $fields             = $ticketFieldHandler->getObjects(null, true);
55
56
        foreach ($fields as $field) {
57
            $key       = $field->getVar('fieldname');
58
            $datatype  = $this->getDataType($field->getVar('datatype'), $field->getVar('controltype'));
59
            $value     = $this->getValueFromXoopsDataType($datatype);
0 ignored issues
show
The assignment to $value is dead and can be removed.
Loading history...
60
            $required  = $field->getVar('required');
61
            $maxlength = ($field->getVar('fieldlength') < 50 ? $field->getVar('fieldlength') : 50);
62
            $options   = '';
63
64
            $this->initVar($key, $datatype, null, $required, $maxlength, $options);
65
66
            $this->fields[$key] = ((\_XHELP_DATATYPE_TEXT == $field->getVar('datatype')) ? '%s' : '%d');
67
        }
68
        $this->fields['ticketid'] = '%u';
69
70
        if (null !== $id) {
71
            if (\is_array($id)) {
72
                $this->assignVars($id);
73
            }
74
        } else {
75
            $this->setNew();
76
        }
77
    }
78
79
    /**
80
     * @param string $datatype
81
     * @param int    $controltype
82
     * @return int
83
     */
84
    private function getDataType(string $datatype, int $controltype): ?int
85
    {
86
        switch ($controltype) {
87
            case \XHELP_CONTROL_TXTBOX:
88
                return $this->getXoopsDataType($datatype);
89
            case \XHELP_CONTROL_TXTAREA:
90
                return $this->getXoopsDataType($datatype);
91
            case \XHELP_CONTROL_SELECT:
92
                return \XOBJ_DTYPE_TXTAREA;
93
            case \XHELP_CONTROL_YESNO:
94
                return \XOBJ_DTYPE_INT;
95
            case \XHELP_CONTROL_RADIOBOX:
96
                return \XOBJ_DTYPE_TXTBOX;
97
            case \XHELP_CONTROL_DATETIME:
98
                return $this->getXoopsDataType($datatype);
99
            case \XHELP_CONTROL_FILE:
100
                return \XOBJ_DTYPE_TXTBOX;
101
            default:
102
                return \XOBJ_DTYPE_TXTBOX;
103
        }
104
    }
105
106
    /**
107
     * @param string $datatype
108
     * @return int
109
     */
110
    private function getXoopsDataType(string $datatype): ?int
111
    {
112
        switch ($datatype) {
113
            case \_XHELP_DATATYPE_TEXT:
114
                return \XOBJ_DTYPE_TXTBOX;
115
            case \_XHELP_DATATYPE_NUMBER_INT:
116
                return \XOBJ_DTYPE_INT;
117
            case \_XHELP_DATATYPE_NUMBER_DEC:
118
                return \XOBJ_DTYPE_OTHER;
119
            default:
120
                return \XOBJ_DTYPE_TXTBOX;
121
        }
122
    }
123
124
    /**
125
     * @param int $datatype
126
     * @return float|int|null|string
127
     */
128
    private function getValueFromXoopsDataType(int $datatype)
129
    {
130
        switch ($datatype) {
131
            case \XOBJ_DTYPE_TXTBOX:
132
            case \XOBJ_DTYPE_TXTAREA:
133
                return '';
134
            case \XOBJ_DTYPE_INT:
135
                return 0;
136
            case \XOBJ_DTYPE_OTHER:
137
                return 0.0;
138
            default:
139
                return null;
140
        }
141
    }
142
143
    /**
144
     * @return array
145
     */
146
    public function getTicketFields(): array
147
    {
148
        return $this->fields;
149
    }
150
}
151