Issues (314)

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/Files/Includes/IncludeNotifications.php (1 issue)

1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files\Includes;
4
5
use XoopsModules\Modulebuilder;
6
use XoopsModules\Modulebuilder\Files;
7
8
/*
9
 You may not change or alter any portion of this comment or credits
10
 of supporting developers from this source code or any supporting source code
11
 which is considered copyrighted (c) material of the original comment or credit authors.
12
13
 This program is distributed in the hope that it will be useful,
14
 but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
/**
18
 * modulebuilder module.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.0
24
 *
25
 * @author          Txmod Xoops https://xoops.org 
26
 *                  Goffy https://myxoops.org
27
 *
28
 */
29
30
/**
31
 * Class IncludeNotifications.
32
 */
33
class IncludeNotifications extends Files\CreateFile
34
{
35
    /**
36
     * @var mixed
37
     */
38
    private $xc = null;
39
40
    /**
41
     * @var mixed
42
     */
43
    private $pc = null;
44
45
    /**
46
     * @public function constructor
47
     * @param null
48
     */
49
    public function __construct()
50
    {
51
        parent::__construct();
52
        $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
53
        $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance();
54
    }
55
56
    /**
57
     * @static function getInstance
58
     * @param null
59
     * @return IncludeNotifications
60
     */
61
    public static function getInstance()
62
    {
63
        static $instance = false;
64
        if (!$instance) {
65
            $instance = new self();
66
        }
67
68
        return $instance;
69
    }
70
71
    /**
72
     * @public function write
73
     * @param string $module
74
     * @param mixed  $tables
75
     * @param string $filename
76
     */
77
    public function write($module, $tables, $filename)
78
    {
79
        $this->setModule($module);
80
        $this->setTables($tables);
81
        $this->setFileName($filename);
82
    }
83
84
    /**
85
     * @static function getNotificationsFunction
86
     * @param string $moduleDirname
87
     *
88
     * @return string
89
     */
90
    public function getNotificationsFunction($moduleDirname)
91
    {
92
        $stuModuleDirname = \mb_strtoupper($moduleDirname);
93
        $tables           = $this->getTables();
94
        $t      = "\t";
95
        $ret    = $this->pc->getPhpCodeCommentMultiLine(['comment' => 'callback functions','' => '', '@param  $category' => '', '@param  $item_id' => '', '@return' => 'array item|null']);
96
        $func   = $this->xc->getXcGetGlobal(['xoopsDB'], $t);
97
        $func   .= $this->pc->getPhpCodeBlankLine();
98
        $contIf = $this->pc->getPhpCodeDefine($stuModuleDirname . '_URL',"\XOOPS_URL . '/modules/{$moduleDirname}'", $t . "\t");
99
        $func   .= $this->pc->getPhpCodeConditions("!\defined('{$stuModuleDirname}_URL')", '','',$contIf, false, $t);
100
        $func   .= $this->pc->getPhpCodeBlankLine();
101
102
        $case[] = $this->xc->getXcEqualsOperator("\$item['name']", "''",'',$t . "\t\t");
0 ignored issues
show
Comprehensibility Best Practice introduced by
$case was never initialized. Although not strictly required by PHP, it is generally a good practice to add $case = array(); before regardless.
Loading history...
103
        $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "''",'',$t . "\t\t");
104
        $case[] = $this->getSimpleString('return $item;', $t . "\t\t");
105
        $cases  = [
106
            'global' => $case,
107
        ];
108
        $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, false, false, $t . "\t");
109
        unset($case);
110
111
        foreach (\array_keys($tables) as $i) {
112
            if (1 === (int)$tables[$i]->getVar('table_notifications')) {
113
                $tableName   = $tables[$i]->getVar('table_name');
114
                $fieldParent = false;
115
                $fields      = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
116
                $fieldId     = '';
117
                $fieldMain   = '';
118
                foreach (\array_keys($fields) as $f) {
119
                    $fieldName = $fields[$f]->getVar('field_name');
120
                    if ((0 == $f) && (1 == $tables[$i]->getVar('table_autoincrement'))) {
121
                        $fieldId = $fieldName;
122
                    }
123
                    if (1 == $fields[$f]->getVar('field_parent')) {
124
                        $fieldParent = $fieldName;
125
                    }
126
                    if (1 == $fields[$f]->getVar('field_main')) {
127
                        $fieldMain = $fieldName;
128
                    }
129
                }
130
                if (1 == $tables[$i]->getVar('table_single')) {
131
                    $tableSingle = 'single';
132
                } else {
133
                    $tableSingle = $tableName;
134
                }
135
                $case[] = $this->xc->getXcEqualsOperator('$sql         ', "'SELECT {$fieldMain} FROM ' . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = '. \$item_id",'',$t . "\t\t");
136
                $case[] = $this->xc->getXcEqualsOperator('$result      ', '$xoopsDB->query($sql)','',$t . "\t\t");
137
                $case[] = $this->xc->getXcEqualsOperator('$result_array', '$xoopsDB->fetchArray($result)','',$t . "\t\t");
138
                $case[] = $this->xc->getXcEqualsOperator("\$item['name']", "\$result_array['{$fieldMain}']",'',$t . "\t\t");
139
                if ($fieldParent) {
140
                    $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableSingle}.php?{$fieldParent}=' . \$result_array['{$fieldParent}'] . '&amp;{$fieldId}=' . \$item_id",'',$t . "\t\t");
141
                } else {
142
                    $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableName}.php?{$fieldId}=' . \$item_id",'',$t . "\t\t");
143
                }
144
145
                $case[] = $this->getSimpleString('return $item;', $t . "\t\t");
146
                $cases  = [
147
                    $tableName => $case,
148
                ];
149
                $contentSwitch .= $this->pc->getPhpCodeCaseSwitch($cases, false, false, $t . "\t");
150
                unset($case);
151
            }
152
        }
153
154
        $func .= $this->pc->getPhpCodeSwitch('category', $contentSwitch, $t);
155
        $func .= $this->getSimpleString('return null;', $t );
156
        $ret  .= $this->pc->getPhpCodeFunction("{$moduleDirname}_notify_iteminfo", '$category, $item_id', $func);
157
158
        return $ret;
159
    }
160
161
    /**
162
     * @public function render
163
     * @param null
164
     * @return bool|string
165
     */
166
    public function render()
167
    {
168
        $module        = $this->getModule();
169
        $filename      = $this->getFileName();
170
        $moduleDirname = $module->getVar('mod_dirname');
171
        $content       = $this->getHeaderFilesComments($module);
172
        $content       .= $this->getNotificationsFunction($moduleDirname);
173
174
        $this->create($moduleDirname, 'include', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED);
175
176
        return $this->renderFile();
177
    }
178
}
179