Issues (964)

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/Building.php (4 issues)

Labels
1
<?php
2
3
namespace XoopsModules\Tdmcreate;
4
5
use XoopsModules\Tdmcreate;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
17
/**
18
 * Building class.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.x
24
 *
25
 * @author          TDM TEAM DEV MODULE
26
 *
27
 */
28
29
/**
30
 * Class Building.
31
 */
32
class Building
33
{
34
    /**
35
     * @static function getInstance
36
     *
37
     * @param null
38
     *
39
     * @return Building
40
     */
41
    public static function getInstance()
42
    {
43
        static $instance = false;
44
        if (!$instance) {
45
            $instance = new self();
46
        }
47
48
        return $instance;
49
    }
50
51
    /**
52
     * @param bool $action
53
     *
54
     * @return \XoopsThemeForm
55
     */
56
    public function getForm($action = false)
57
    {
58
        $helper = Tdmcreate\Helper::getInstance();
59
        if (false === $action) {
60
            $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
61
        }
62
        xoops_load('XoopsFormLoader');
63
        $form = new \XoopsThemeForm(_AM_TDMCREATE_ADMIN_CONST, 'buildform', $action, 'post', true);
0 ignored issues
show
It seems like $action can also be of type true; however, parameter $action of XoopsThemeForm::__construct() does only seem to accept string, 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

63
        $form = new \XoopsThemeForm(_AM_TDMCREATE_ADMIN_CONST, 'buildform', /** @scrutinizer ignore-type */ $action, 'post', true);
Loading history...
64
        $form->setExtra('enctype="multipart/form-data"');
65
        $moduleObj  = $helper->getHandler('modules')->getObjects(null);
0 ignored issues
show
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        $moduleObj  = $helper->getHandler('modules')->/** @scrutinizer ignore-call */ getObjects(null);
Loading history...
66
        $mod_select = new \XoopsFormSelect(_AM_TDMCREATE_CONST_MODULES, 'mod_id', 'mod_id');
67
        $mod_select->addOption('', _AM_TDMCREATE_BUILD_MODSELOPT);
68
        foreach ($moduleObj as $mod) {
69
            $mod_select->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
70
        }
71
        $form->addElement($mod_select, true);
72
        
73
        $form->addElement(new \XoopsFormRadioYN(_AM_TDMCREATE_MODULE_INROOT_COPY, 'inroot_copy', $helper->getConfig('inroot_copy')));
74
        
75
        $form->addElement(new \XoopsFormHidden('op', 'build'));
76
        $form->addElement(new \XoopsFormButton(_REQUIRED . ' <sup class="red bold">*</sup>', 'submit', _SUBMIT, 'submit'));
77
78
        return $form;
79
    }
80
81
    /**
82
     * @param string $dir
83
     * @param string $pattern
84
     */
85
    public function clearDir($dir, $pattern = '*')
86
    {
87
        // Find all files and folders matching pattern
88
        $files = glob($dir . "/$pattern");
89
        // Interate thorugh the files and folders
90
        foreach ($files as $file) {
91
            // if it's a directory then re-call clearDir function to delete files inside this directory
92
            if (is_dir($file) && !in_array($file, ['..', '.'])) {
93
                // Remove the directory itself
94
                $this->clearDir($file, $pattern);
95
            } elseif ((__FILE__ != $file) && is_file($file)) {
96
                // Make sure you don't delete the current script
97
                unlink($file);
98
            }
99
        }
100
        if (is_dir($dir)) {
101
            rmdir($dir);
102
        }
103
    }
104
105
    /**
106
     * @param string $src
107
     * @param string $dst
108
     */
109
    public function copyDir($src, $dst)
110
    {
111
        $dir = opendir($src);
112
        if (!mkdir($dst) && !is_dir($dst)) {
113
            throw new \RuntimeException(sprintf('Directory "%s" was not created', $dst));
114
        }
115
        while (false !== ($file = readdir($dir))) {
0 ignored issues
show
It seems like $dir can also be of type false; however, parameter $dir_handle of readdir() does only seem to accept resource, 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

115
        while (false !== ($file = readdir(/** @scrutinizer ignore-type */ $dir))) {
Loading history...
116
            if (('.' !== $file) && ('..' !== $file)) {
117
                if (is_dir($src . '/' . $file)) {
118
                    // Copy the directory itself
119
                    $this->copyDir($src . '/' . $file, $dst . '/' . $file);
120
                } else {
121
                    // Make sure you copy the current script
122
                    copy($src . '/' . $file, $dst . '/' . $file);
123
                }
124
            }
125
        }
126
        closedir($dir);
0 ignored issues
show
It seems like $dir can also be of type false; however, parameter $dir_handle of closedir() does only seem to accept resource, 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

126
        closedir(/** @scrutinizer ignore-type */ $dir);
Loading history...
127
    }
128
}
129