Issues (42)

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.

include/onupdate.php (3 issues)

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project (https://xoops.org)
14
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author      XOOPS Development Team
16
 */
17
18
use XoopsModules\Xsitemap\{
19
    Common\Configurator,
20
    Helper,
21
    Utility
22
};
23
/** @var Utility $utility */
24
/** @var Helper $helper */
25
/** @var Configurator $configurator */
26
27
// require_once  \dirname(__DIR__) . '/class/Utility.php';
28
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
29
    || !$GLOBALS['xoopsUser']->isAdmin()) {
30
    exit('Restricted access' . PHP_EOL);
31
}
32
/**
33
 * Prepares system prior to attempting to update module
34
 *
35
 * @param \XoopsModule $module
36
 *
37
 * @return bool true if successfully ready to update module, false if not
38
 */
39
function xoops_module_pre_update_xsitemap(\XoopsModule $module)
40
{
41
    $moduleDirName = \basename(\dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
42
    $utility       = new Utility();
43
    $xoopsSuccess  = $utility::checkVerXoops($module);
44
    $phpSuccess    = $utility::checkVerPhp($module);
45
    return $xoopsSuccess && $phpSuccess;
46
}
47
48
/**
49
 * Functions to upgrade from previous version of the module
50
 *
51
 * @param \XoopsModule $module
52
 * @param int|null     $previousVersion
53
 * @return bool true if successfully updated module, false if not
54
 * @internal param int $curr_version version number of module currently installed
55
 */
56
function xoops_module_update_xsitemap(\XoopsModule $module, $previousVersion = null)
57
{
58
    /*======================================================================
59
        //----------------------------------------------------------------
60
        // Remove xSitemap uploads folder (and all subfolders) if they exist
61
        //----------------------------------------------------------------*
62
        $utility = new Utility();
63
        if (!class_exists($utility)) {
64
            xoops_load('utility', $moduleDirName);
65
        }
66
67
        // Recursively delete directories
68
        $xsUploadDir = realpath(XOOPS_UPLOAD_PATH . "/" . $module->dirname());
69
        $success = $utility::rrmdir($xsUploadDir);
70
        if (true !== $success) {
71
            \Xmf\Language::load('admin', $module->dirname());
72
            $module->setErrors(sprintf(_AM_XSITEMAP_ERROR_BAD_DEL_PATH, $xsUploadDir));
73
        }
74
        return $success;
75
    ======================================================================*/
76
    $moduleDirName      = \basename(\dirname(__DIR__));
77
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
0 ignored issues
show
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
78
    $helper       = Helper::getInstance();
79
    $utility      = new Utility();
80
    //-----------------------------------------------------------------------
81
    // Upgrade for Xsitemap < 1.54
82
    //-----------------------------------------------------------------------
83
    $success = true;
84
    $helper->loadLanguage('modinfo');
85
    $helper->loadLanguage('admin');
86
    if ($previousVersion < 154) {
87
        //----------------------------------------------------------------
88
        // Remove previous css & images directories since they've been relocated to ./assets
89
        // Also remove uploads directories since they're no longer used
90
        //----------------------------------------------------------------
91
        $old_directories = [
92
            $helper->path('css/'),
93
            $helper->path('js/'),
94
            $helper->path('images/'),
95
            XOOPS_UPLOAD_PATH . '/' . $module->dirname(),
96
        ];
97
        foreach ($old_directories as $old_dir) {
98
            $dirInfo = new \SplFileInfo($old_dir);
99
            if ($dirInfo->isDir()) {
100
                // The directory exists so delete it
101
                if (false === $utility::rrmdir($old_dir)) {
102
                    $module->setErrors(sprintf(_AM_XSITEMAP_ERROR_BAD_DEL_PATH, $old_dir));
103
                    return false;
104
                }
105
            }
106
            unset($dirInfo);
107
        }
108
        //-----------------------------------------------------------------------
109
        // Remove ./template/*.html (except index.html) files since they've
110
        // been replaced by *.tpl files
111
        // Note: this will also remove /template/xsitemap_style.html since it's no longer used
112
        //-----------------------------------------------------------------------
113
        $path       = $helper->path('templates/');
114
        $unfiltered = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
115
        $iterator   = new RegexIterator($unfiltered, '/.*\.html/');
116
        foreach ($iterator as $name => $fObj) {
117
            if ($fObj->isFile() && ('index.html' !== $fObj->getFilename())) {
118
                if (false === ($success = unlink($fObj->getPathname()))) {
119
                    $module->setErrors(sprintf(_AM_XSITEMAP_ERROR_BAD_REMOVE, $fObj->getPathname()));
120
                    return false;
121
                }
122
            }
123
        }
124
        //-----------------------------------------------------------------------
125
        // Now remove a some misc files that were renamed or deprecated
126
        //-----------------------------------------------------------------------
127
        $oldFiles = [
128
            $helper->path('include/install.php'),
129
            $helper->path('class/module.php'),
130
            $helper->path('class/menu.php'),
131
        ];
132
        foreach ($oldFiles as $file) {
133
            if (is_file($file)) {
134
                if (false === ($delOk = unlink($file))) {
135
                    $module->setErrors(sprintf(_AM_XSITEMAP_ERROR_BAD_REMOVE, $file));
136
                }
137
                $success = $success && $delOk;
138
            }
139
        }
140
    }
141
    if ($previousVersion < 156) {
142
        // update table (add new field)
143
        $table = $GLOBALS['xoopsDB']->prefix('xsitemap_plugin');
144
        $field = 'plugin_where';
145
        $check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
146
        $numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
147
        if (!$numRows) {
148
            $sql = "ALTER TABLE `$table` ADD `$field` VARCHAR(255) NOT NULL AFTER `plugin_weight`;";
149
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
150
                xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
151
                $module->setErrors("Error when adding '$field' to table '$table'.");
152
                $ret = false;
0 ignored issues
show
The assignment to $ret is dead and can be removed.
Loading history...
153
            }
154
            $success = $success && $result;
155
        }
156
    }
157
158
    return $success;
159
}
160