Issues (621)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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/Common/Migrate.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace XoopsModules\Smallworld\Common;
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
use XoopsModules\Smallworld\Common;
16
17
/**
18
 * Class Migrate synchronize existing tables with target schema
19
 *
20
 * @category  Migrate
21
 * @author    Richard Griffith <[email protected]>
22
 * @copyright 2016 XOOPS Project (https://xoops.org)
23
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24
 * @link      https://xoops.org
25
 */
26
class Migrate extends \Xmf\Database\Migrate
27
{
28
    private $renameTables;
29
30
    /**
31
     * Migrate constructor.
32
     * @param Common\Configurator $configurator
0 ignored issues
show
Should the type for parameter $configurator not be null|Configurator?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
33
     * @throws \RuntimeException
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(Common\Configurator $configurator = null)
37
    {
38
        if (null !== $configurator) {
39
            $this->renameTables = $configurator->renameTables;
40
41
            $moduleDirName = basename(dirname(dirname(__DIR__)));
42
            parent::__construct($moduleDirName);
43
        }
44
    }
45
46
    /**
47
     * change table prefix if needed
48
     */
49
    private function changePrefix()
50
    {
51
        foreach ($this->renameTables as $oldName => $newName) {
52
            if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) {
53
                $this->tableHandler->renameTable($oldName, $newName);
54
            }
55
        }
56
    }
57
58
    /**
59
     * Change integer IPv4 column to varchar IPv6 capable
60
     *
61
     * @param string $tableName  table to convert
62
     * @param string $columnName column with IP address
63
     */
64
    private function convertIPAddresses($tableName, $columnName)
65
    {
66
        if ($this->tableHandler->useTable($tableName)) {
67
            $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
68
            if (false !== mb_strpos($attributes, ' int(')) {
69
                if (false === mb_strpos($attributes, 'unsigned')) {
70
                    $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL  DEFAULT '0' ");
71
                    $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false);
72
                }
73
                $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45)  NOT NULL  DEFAULT '' ");
74
                $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false);
75
            }
76
        }
77
    }
78
79
    /**
80
     * Move do* columns from newbb_posts to newbb_posts_text table
81
     */
82
    private function moveDoColumns()
83
    {
84
        $tableName    = 'newbb_posts_text';
85
        $srcTableName = 'newbb_posts';
86
        if ($this->tableHandler->useTable($tableName)
87
            && $this->tableHandler->useTable($srcTableName)) {
88
            $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
89
            if (false === $attributes) {
90
                $this->synchronizeTable($tableName);
91
                $updateTable = $GLOBALS['xoopsDB']->prefix($tableName);
92
                $joinTable   = $GLOBALS['xoopsDB']->prefix($srcTableName);
93
                $sql         = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml,  t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . '  , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
94
                $this->tableHandler->addToQueue($sql);
95
            }
96
        }
97
    }
98
99
    /**
100
     * Perform any upfront actions before synchronizing the schema
101
     *
102
     * Some typical uses include
103
     *   table and column renames
104
     *   data conversions
105
     */
106
    protected function preSyncActions()
107
    {
108
        // change 'bb' table prefix to 'newbb'
109
        $this->changePrefix();
110
        // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
111
        $this->moveDoColumns();
112
        // Convert IP address columns from int to readable varchar(45) for IPv6
113
        $this->convertIPAddresses('newbb_posts', 'poster_ip');
114
        $this->convertIPAddresses('newbb_report', 'reporter_ip');
115
    }
116
}
117