Issues (167)

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/Common/ImagesHandler.php (3 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Tdmdownloads\Common;
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
 * @copyright      2020 XOOPS Project (https://xoops.org)
18
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @link           https://xoops.org
20
 * @author         Wedega - Email:<[email protected]> - Website:<https://wedega.com>
21
 */
22
23
/**
24
 * Class Object Handler Images
25
 */
26
class ImagesHandler extends \XoopsPersistableObjectHandler
27
{
28
    /**
29
     * Constructor
30
     * @param \XoopsDatabase|null $db
31
     */
32
    public function __construct(?\XoopsDatabase $db = null)
33
    {
34
        parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name');
35
    }
36
37
    /**
38
     * retrieve a field
39
     *
40
     * @param int        $id field id
41
     * @param null|mixed $fields
42
     * @return \XoopsObject|null reference to the {@link Get} object
43
     */
44
    public function get($id = null, $fields = null)
45
    {
46
        return parent::get($id, $fields);
47
    }
48
49
    /**
50
     * get inserted id
51
     *
52
     * @param null
53
     * @return int reference to the {@link Get} object
54
     */
55
    public function getInsertId()
56
    {
57
        return $this->db->getInsertId();
58
    }
59
60
    /**
61
     * Get Count Images in the database
62
     * @param int    $albId
63
     * @param int    $start
64
     * @param int    $limit
65
     * @param string $sort
66
     * @param string $order
67
     * @return int
68
     */
69
    public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC')
70
    {
71
        $crCountImages = new \CriteriaCompo();
72
        $crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order);
73
        return parent::getCount($crCountImages);
0 ignored issues
show
$crCountImages of type integer is incompatible with the type CriteriaElement|null expected by parameter $criteria of XoopsPersistableObjectHandler::getCount(). ( Ignorable by Annotation )

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

73
        return parent::getCount(/** @scrutinizer ignore-type */ $crCountImages);
Loading history...
74
    }
75
76
    /**
77
     * Get All Images in the database
78
     * @param int    $start
79
     * @param int    $limit
80
     * @param string $sort
81
     * @param string $order
82
     * @return array
83
     */
84
    public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC')
85
    {
86
        $crAllImages = new \CriteriaCompo();
87
        $crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order);
88
        return parent::getAll($crAllImages);
0 ignored issues
show
$crAllImages of type integer is incompatible with the type CriteriaElement|null expected by parameter $criteria of XoopsPersistableObjectHandler::getAll(). ( Ignorable by Annotation )

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

88
        return parent::getAll(/** @scrutinizer ignore-type */ $crAllImages);
Loading history...
89
    }
90
91
    /**
92
     * Get Criteria Images
93
     * @param        $crImages
94
     * @param        $albId
95
     * @param int    $start
96
     * @param int    $limit
97
     * @param string $sort
98
     * @param string $order
99
     * @return int
100
     */
101
    private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order)
102
    {
103
        if ($albId > 0) {
104
            $crImages->add(new \Criteria('img_albid', $albId));
105
        }
106
        $crImages->setStart($start);
107
        $crImages->setLimit($limit);
108
        $crImages->setSort($sort);
109
        $crImages->setOrder($order);
110
        return $crImages;
111
    }
112
113
    /**
114
     * delete all copies of a specific image
115
     * @param $imageName
116
     * @return bool
117
     */
118
    public function unlinkImages($imageName)
119
    {
120
        \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $moduleDirNameUpper seems to be never defined.
Loading history...
121
        if (\is_file(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) {
122
            return false;
123
        }
124
        \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName);
125
        if (\is_file(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) {
126
            return false;
127
        }
128
        \unlink(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName);
129
        if (\is_file(\constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) {
130
            return false;
131
        }
132
        return true;
133
    }
134
}
135