Issues (314)

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

1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files;
4
5
use XoopsModules\Modulebuilder;
6
7
/**
8
 * Class CreateClone
9
 */
10
class CreateClone
11
{
12
    /**
13
     * Delete a file or recursively delete a directory
14
     *
15
     * @param string $path Path to file or directory
16
     *
17
     * public static function deleteFileFolder($path) {
18
     *
19
     * if (is_file($path)) {
20
     * return @\unlink($path);
21
     * }
22
     * elseif (\is_dir($path)) {
23
     * $scan = glob(r\trim($path,'/').'/*');
24
     * foreach($scan as $index=>$path) {
25
     * self::deleteFileFolder($path);
26
     * }
27
     * return @\rmdir($path);
28
     * }
29
     * }*/
30
31
    // recursive cloning script
32
    /**
33
     * @param       $src_path
34
     * @param       $dst_path
35
     * @param bool  $replace_code
36
     * @param array $patKeys
37
     * @param array $patValues
38
     */
39
    public static function cloneFileFolder($src_path, $dst_path, $replace_code = false, $patKeys = [], $patValues = [])
40
    {
41
        // open the source directory
42
        $dir = \opendir($src_path);
43
        // Make the destination directory if not exist
44
        @\mkdir($dst_path);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mkdir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

44
        /** @scrutinizer ignore-unhandled */ @\mkdir($dst_path);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
45
        // Loop through the files in source directory
46
        while ($file = \readdir($dir)) {
47
            if (($file != '.') && ($file != '..')) {
48
                if (\is_dir($src_path . '/' . $file)) {
49
                    // Recursively calling custom copy function for sub directory
50
                    self::cloneFileFolder($src_path . '/' . $file, $dst_path . '/' . $file, $replace_code, $patKeys, $patValues);
51
                } else {
52
                    self::cloneFile($src_path . '/' . $file, $dst_path . '/' . $file, $replace_code, $patKeys, $patValues);
53
                }
54
            }
55
        }
56
        \closedir($dir);
57
    }
58
59
    /**
60
     * @param       $src_file
61
     * @param       $dst_file
62
     * @param bool  $replace_code
63
     * @param array $patKeys
64
     * @param array $patValues
65
     */
66
    public static function cloneFile($src_file, $dst_file, $replace_code = false, $patKeys = [], $patValues = [])
67
    {
68
        if ($replace_code) {
69
            $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
70
            if (\in_array(\mb_strtolower(\pathinfo($src_file, PATHINFO_EXTENSION)), $noChangeExtensions)) {
0 ignored issues
show
It seems like pathinfo($src_file, Xoop...les\PATHINFO_EXTENSION) can also be of type array; however, parameter $string of mb_strtolower() 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

70
            if (\in_array(\mb_strtolower(/** @scrutinizer ignore-type */ \pathinfo($src_file, PATHINFO_EXTENSION)), $noChangeExtensions)) {
Loading history...
71
                // image
72
                \copy($src_file, $dst_file);
73
            } else {
74
                // file, read it and replace text
75
                $content = file_get_contents($src_file);
76
                $content = \str_replace($patKeys, $patValues, $content);
77
                //check file name whether it contains replace code
78
                $path_parts = \pathinfo($dst_file);
79
                $path       = $path_parts['dirname'];
80
                $file       = $path_parts['basename'];
81
                $dst_file   = $path . '/' . \str_replace($patKeys, $patValues, $file);
82
                file_put_contents($dst_file, $content);
83
            }
84
        } else {
85
            \copy($src_file, $dst_file);
86
        }
87
    }
88
}
89