Issues (380)

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

Labels
Severity
1
<?php
2
3
namespace XoopsModules\Newbb;
4
5
use XoopsModules\Newbb;
6
use XoopsModules\Newbb\Common;
7
use XoopsModules\Newbb\Constants;
8
9
/**
10
 * Class Utility
11
 */
12
class Utility extends Common\SysUtility
13
{
14
    //--------------- Custom module methods -----------------------------
15
16
    /**
17
     * Verify that a mysql table exists
18
     *
19
     * @param $tablename
20
     * @return bool
21
     * @copyright (c) Hervé Thouzard
22
     * @package       News
23
     * @author        Hervé Thouzard (http://www.herve-thouzard.com)
24
     */
25
    public function tableExists($tablename)
26
    {
27
        global $xoopsDB;
28
        /** @var \XoopsMySQLDatabase $xoopsDB */
29
        $result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'");
30
31
        return ($xoopsDB->getRowsNum($result) > 0);
0 ignored issues
show
It seems like $result can also be of type boolean; however, parameter $result of XoopsMySQLDatabase::getRowsNum() does only seem to accept mysqli_result, 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

31
        return ($xoopsDB->getRowsNum(/** @scrutinizer ignore-type */ $result) > 0);
Loading history...
32
    }
33
34
    /**
35
     * Verify that a field exists inside a mysql table
36
     *
37
     * @param $fieldname
38
     * @param $table
39
     * @return bool
40
     * @package       News
41
     * @author        Hervé Thouzard (http://www.herve-thouzard.com)
42
     * @copyright (c) Hervé Thouzard
43
     */
44
    public function fieldExists($fieldname, $table)
45
    {
46
        global $xoopsDB;
47
        $result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
48
49
        return ($xoopsDB->getRowsNum($result) > 0);
50
    }
51
52
    /**
53
     * Add a field to a mysql table
54
     *
55
     * @param $field
56
     * @param $table
57
     * @return bool|\mysqli_result
58
     * @package       News
59
     * @author        Hervé Thouzard (http://www.herve-thouzard.com)
60
     * @copyright (c) Hervé Thouzard
61
     */
62
    public function addField($field, $table)
63
    {
64
        global $xoopsDB;
65
        $result = $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field");
66
67
        return $result;
68
    }
69
70
    /**
71
     * Function responsible for checking if a directory exists, we can also write in and create an index.html file
72
     *
73
     * @param string $folder Le chemin complet du répertoire à vérifier
74
     */
75
    public static function prepareFolder($folder)
76
    {
77
        try {
78
            if (!@\mkdir($folder) && !\is_dir($folder)) {
79
                throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder));
80
            }
81
            file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
82
        } catch (\Exception $e) {
83
            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
84
        }
85
    }
86
87
    public static function cleanCache()
88
    {
89
        $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
90
        if (\method_exists($cacheHelper, 'clear')) {
91
            $cacheHelper->clear();
92
93
            return;
94
        }
95
        // for 2.5 systems, clear everything
96
        require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php';
97
        $maintenance = new \SystemMaintenance();
98
        $cacheList   = [
99
            3, // xoops_cache
100
        ];
101
        $maintenance->CleanCache($cacheList);
102
        \xoops_setActiveModules();
103
    }
104
105
    /**
106
     * Checks if a user is admin of NewBB
107
     *
108
     * @return bool
109
     */
110
    public static function userIsAdmin()
111
    {
112
        /** @var Newbb\Helper $helper */
113
        $helper = \XoopsModules\Newbb\Helper::getInstance();
114
115
        static $newbbIsAdmin;
116
117
        if (isset($newbbIsAdmin)) {
118
            return $newbbIsAdmin;
119
        }
120
121
        if (!$GLOBALS['xoopsUser']) {
122
            $newbbIsAdmin = false;
123
        } else {
124
            $newbbIsAdmin = $GLOBALS['xoopsUser']->isAdmin($helper->getModule()->getVar('mid'));
125
        }
126
127
        return $newbbIsAdmin;
128
    }
129
}
130