Issues (222)

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/Updater.php (2 issues)

Labels
1
<?php namespace XoopsModules\Mymenus;
2
3
/**
4
 * Class Updater
5
 * @package XoopsModules\Mymenus
6
 */
7
class Updater
8
{
9
10
    // =========================================================================================
11
    // This class updates any existing table of a < 1.50 version to the format used
12
    // in the release of Mymenus 1.51
13
    // =========================================================================================
14
15
    /**
16
     * @param $module
17
     *
18
     * @return bool
19
     */
20
    public static function checkInfoTemplates(\XoopsObject $module)
0 ignored issues
show
The type XoopsObject was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
    {
22
        $err = true;
23
        if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $module->getInfo('dirname') . '/templates/blocks/' . $module->getInfo('dirname') . '_block.tpl')) {
0 ignored issues
show
The constant XoopsModules\Mymenus\XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
            $module->setErrors('Template ' . $module->getInfo('dirname') . '_block.tpl not exists!');
25
            $err = false;
26
        }
27
28
        return $err;
29
    }
30
31
    /**
32
     * @param $module
33
     *
34
     * @return bool
35
     */
36
    public static function checkInfoTable(\XoopsObject $module)
37
    {
38
        //    global $xoopsDB;
39
        $err = true;
40
41
        $tables_menus = [
42
            'id'    => 'int(5) NOT NULL auto_increment',
43
            'title' => "varchar(255) NOT NULL default ''",
44
            'css'   => "varchar(255) NOT NULL default ''"
45
        ];
46
47
        $tables_links = [
48
            'id'        => 'int(5) NOT NULL auto_increment',
49
            'pid'       => "int(5) NOT NULL default '0'",
50
            'mid'       => "int(5) NOT NULL default '0'",
51
            'title'     => "varchar(150) NOT NULL default ''",
52
            'alt_title' => "varchar(255) NOT NULL default ''",
53
            'visible'   => "tinyint(1) NOT NULL default '0'",
54
            'link'      => 'varchar(255) default NULL',
55
            'weight'    => "tinyint(4) NOT NULL default '0'",
56
            'target'    => 'varchar(10) default NULL',
57
            'groups'    => 'text default NULL',
58
            'hooks'     => 'text default NULL',
59
            'image'     => 'varchar(255) default NULL',
60
            'css'       => 'varchar(255) default NULL'
61
        ];
62
63
        /*
64
65
        // CREATE or ALTER 'mymenus_menus' table
66
        if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus')) {
67
            $sql = "CREATE TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus (";
68
            foreach ($tables_menus as $s => $w) {
69
                $sql .= " " . $s . " " . $w . ",";
70
            }
71
            $sql .= " PRIMARY KEY (id)); ";
72
            echo $sql;
73
            $result = $GLOBALS['xoopsDB']->queryF($sql);
74
            if (!$result) {
75
                $module->setErrors("Can't create Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus');
76
                return false;
77
            } else {
78
                $sql    = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus (id,title) VALUES (1,'Default')";
79
                $result = $GLOBALS['xoopsDB']->queryF($sql);
80
            }
81
        } else {
82
            foreach ($tables_menus as $s => $w) {
83
                if (!InfoColumnExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus', $s)) {
84
                    $sql    = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus ADD " . $s . " " . $w . ";";
85
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
86
                } else {
87
                    $sql    = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus CHANGE " . $s . " " . $s . " " . $w . ";";
88
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
89
                }
90
            }
91
        }
92
    */
93
94
        self::createUpdateTable($tables_menus, '_menus', $module);
95
96
        // RENAME TABLE 'mymenus_menu' TO 'mymenus_links'
97
        if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_links')) {
98
            if (InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu')) {
99
                $sql    = 'RENAME TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu TO ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_links;';
100
                $result = $GLOBALS['xoopsDB']->queryF($sql);
101
                if (!$result) {
102
                    $module->setErrors("Can't rename Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu');
103
104
                    return false;
105
                }
106
            }
107
        }
108
109
        /*
110
      //---------------------------
111
          // CREATE or ALTER 'mymenus_links' table
112
          if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links")) {
113
              $sql = "CREATE TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links ( ";
114
              foreach ($tables_links as $c => $w) {
115
                  $sql .= " " . $c . " " . $w . ",";
116
              }
117
              $sql .= "  PRIMARY KEY  (id) ) ;";
118
              $result = $GLOBALS['xoopsDB']->queryF($sql);
119
              if (!$result) {
120
                  $module->setErrors("Can't create Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links");
121
                  $sql    = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus';
122
                  $result = $GLOBALS['xoopsDB']->queryF($sql);
123
                  return false;
124
              }
125
          } else {
126
              foreach ($tables_links as $s => $w) {
127
                  if (!InfoColumnExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_links', $s)) {
128
                      $sql    = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links ADD " . $s . " " . $w . ";";
129
                      $result = $GLOBALS['xoopsDB']->queryF($sql);
130
                  } else {
131
                      $sql    = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links CHANGE " . $s . " " . $s . " " . $w . ";";
132
                      $result = $GLOBALS['xoopsDB']->queryF($sql);
133
                  }
134
              }
135
          }
136
137
          //--------------------------
138
      */
139
140
        self::createUpdateTable($tables_links, '_links', $module);
141
142
        return true;
143
    }
144
145
    /**
146
     * @param array       $table
147
     * @param string      $tablename
148
     * @param \XoopsObject $module
149
     * @return bool|null
150
     */
151
    public static function createUpdateTable($table, $tablename, \XoopsObject $module)
152
    {
153
        if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename)) {
154
            $sql = 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename . ' (';
155
            foreach ($table as $s => $w) {
156
                $sql .= ' ' . $s . ' ' . $w . ',';
157
            }
158
            $sql .= ' PRIMARY KEY (id)); ';
159
            //    echo $sql;
160
            $result = $GLOBALS['xoopsDB']->queryF($sql);
161
            if (!$result) {
162
                $module->setErrors("Can't create Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename);
163
164
                if ('_menu' === $tablename) {
165
                    return false;
166
                }
167
168
                if ('_links' === $tablename) {
169
                    $sql    = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menus';
170
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
171
172
                    return false;
173
                }
174
            } else {
175
                if ('_menu' === $tablename) {
176
                    $sql    = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename . " (id,title) VALUES (1,'Default')";
177
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
178
                }
179
            }
180
        } else {
181
            foreach ($table as $s => $w) {
182
                if (!InfoColumnExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename, $s)) {
183
                    $sql    = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename . ' ADD ' . $s . ' ' . $w . ';';
184
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
185
                } else {
186
                    $sql    = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . $tablename . ' CHANGE ' . $s . ' ' . $s . ' ' . $w . ';';
187
                    $result = $GLOBALS['xoopsDB']->queryF($sql);
188
                }
189
            }
190
        }
191
192
        return null;
193
    }
194
}
195