Issues (381)

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

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\Xnewsletter\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
/**
16
 * @copyright   XOOPS Project (https://xoops.org)
17
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
18
 * @author      mamba <[email protected]>
19
 */
20
trait VersionChecks
21
{
22
    /**
23
     * Verifies XOOPS version meets minimum requirements for this module
24
     * @static
25
     * @param \XoopsModule|null $module
26
     *
27
     * @param null|string  $requiredVer
28
     * @return bool true if meets requirements, false if not
29
     */
30
    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
31
    {
32
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
33
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
34
        if (null === $module) {
35
            $module = \XoopsModule::getByDirname($moduleDirName);
36
        }
37
        xoops_loadLanguage('admin', $moduleDirName);
38
        xoops_loadLanguage('common', $moduleDirName);
39
40
41
        //check for minimum XOOPS version
42
        $currentVer = mb_substr(XOOPS_VERSION, 6); // get the numeric part of string
43
        if (null === $requiredVer) {
44
            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
45
        }
46
        $success = true;
47
48 View Code Duplication
        if (version_compare($currentVer, $requiredVer, '<')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
            $success = false;
50
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
51
        }
52
53
        return $success;
54
    }
55
56
    /**
57
     * Verifies PHP version meets minimum requirements for this module
58
     * @static
59
     * @param \XoopsModule|null $module
60
     *
61
     * @return bool true if meets requirements, false if not
62
     */
63
    public static function checkVerPhp(\XoopsModule $module = null)
64
    {
65
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
66
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
67
        if (null === $module) {
68
            $module = \XoopsModule::getByDirname($moduleDirName);
69
        }
70
        xoops_loadLanguage('admin', $moduleDirName);
71
        xoops_loadLanguage('common', $moduleDirName);
72
73
        // check for minimum PHP version
74
        $success = true;
75
76
        $verNum = PHP_VERSION;
77
        $reqVer = &$module->getInfo('min_php');
78
79
        if (false !== $reqVer && '' !== $reqVer && !is_array($reqVer)) {
80 View Code Duplication
            if (version_compare($verNum, $reqVer, '<')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
82
                $success = false;
83
            }
84
        }
85
86
        return $success;
87
    }
88
89
    /**
90
     *
91
     * compares current module version with latest GitHub release
92
     * @static
93
     * @param \Xmf\Module\Helper $helper
94
     * @param string|null        $source
95
     * @param string|null        $default
96
     *
97
     * @return string|array info about the latest module version, if newer
98
     */
99
100
    public static function checkVerModule($helper, $source = 'github', $default = 'master')
101
    {
102
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
103
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
104
        $update             = '';
105
        $repository         = 'XoopsModules25x/' . $moduleDirName;
106
        //        $repository         = 'XoopsModules25x/publisher'; //for testing only
107
        $ret             = '';
108
        $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
109
        if ('github' === $source) {
110
            if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) {
111
                curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl);
112
                curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
113
                curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
114
                curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
115
                $curlReturn = curl_exec($curlHandle);
116
                if (false === $curlReturn) {
117
                    trigger_error(curl_error($curlHandle));
118
                } elseif (false !== strpos($curlReturn, 'Not Found')) {
119
                    trigger_error('Repository Not Found: ' . $infoReleasesUrl);
120
                } else {
121
                    $file              = json_decode($curlReturn, false);
122
                    $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default);
123
                    $latestVersion     = $file[0]->tag_name;
124
                    $prerelease        = $file[0]->prerelease;
125
                    if ('master' !== $latestVersionLink) {
126
                        $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
127
                    }
128
                    //"PHP-standardized" version
129
                    $latestVersion = mb_strtolower($latestVersion);
130
                    if (false !== mb_strpos($latestVersion, 'final')) {
131
                        $latestVersion = str_replace('_', '', mb_strtolower($latestVersion));
132
                        $latestVersion = str_replace('final', '', mb_strtolower($latestVersion));
133
                    }
134
                    $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
135
                    //"PHP-standardized" version
136
                    $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion));
137
                    //                    $moduleVersion = '1.0'; //for testing only
138
                    //                    $moduleDirName = 'publisher'; //for testing only
139
                    if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) {
140
                        $ret   = [];
141
                        $ret[] = $update;
142
                        $ret[] = $latestVersionLink;
143
                    }
144
                }
145
                curl_close($curlHandle);
146
            }
147
        }
148
        return $ret;
149
    }
150
}
151