Issues (168)

Security Analysis    no request data  

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.

src/deprecated/Gallery.php (4 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
 * Created by PhpStorm.
4
 * User: myslyvyi
5
 * Date: 05.01.2016
6
 * Time: 15:25
7
 */
8
namespace samsoncms\api;
9
10
use samsonframework\orm\QueryInterface;
11
12
/***
13
 *  Gallery additional field for material.
14
 *  This class enables getting all information about additional fields gallery for specific material.
15
 *  @author [email protected]
16
 * @deprecated Use \samsoncms\api\generator\GalleryCollection instead
17
 */
18
class Gallery
19
{
20
    /** @var integer materialFieldId Table materialField identifier */
21
    protected $materialFieldId = null;
22
23
    /** @var QueryInterface Database query interface */
24
    protected $query;
25
26
    /**
27
     * Constructor Gallery.
28
     * This constructor finds identifier additional field gallery from
29
     * database record its material and field identifiers.
30
     *
31
     * @param QueryInterface $query Database query interface
32
     * @param integer $materialId material identifier
33
     * @param integer $fieldId field identifier
34
     */
35 3
    public function __construct(QueryInterface $query, $materialId, $fieldId)
36
    {
37
        /** @var object $materialField additional field value database record*/
38 3
        $materialField = null;
0 ignored issues
show
$materialField is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
40
        //set query interface
41 3
        $this->query = $query;
42
43
        //Find additional field value database record by its material and field identifiers.
44 3
        $materialField = $this->query->entity(MaterialField::ENTITY)
45 3
            ->where(Material::F_PRIMARY, $materialId)
46 3
            ->where(Field::F_PRIMARY, $fieldId)
47 3
            ->where(Material::F_DELETION, 1)
48 3
            ->first();
49
50 3
        if ($materialField) {
51
            //Set materialFieldId
52 3
            $this->materialFieldId = $materialField->id;
53 3
        }
54
55 3
    }
56
57
    /**
58
     * Getting quantity images in additional field gallery
59
     *
60
     * @return integer $count
61
     */
62 1
    public function getCount()
63
    {
64
        /**@var integer $count quantity images in additional field gallery */
65 1
        $count = 0;
66
67 1 View Code Duplication
        if ($this->hasImages()) {
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...
68
            // Getting quantity images for gallery
69 1
            $count = $this->query
70 1
                ->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)
71 1
                ->where(Field::F_DELETION, 1)
72 1
                ->where(MaterialField::F_PRIMARY, $this->materialFieldId)
73 1
                ->count();
74 1
        }
75
76 1
        return $count;
77
    }
78
79
    /**
80
     * Check on empty gallery. If materialFieldId = null and quantity images not more 1 then material not has images.
81
     *
82
     * @return boolean
83
     **/
84 3
    public function hasImages()
85
    {
86
        /**@var $hasImages */
87 3
        $hasImages = false;
88
89 3 View Code Duplication
        if (isset($this->materialFieldId)) {
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...
90
            // Getting quantity images, if quantity more 0 then material has images
91 3
            if ($this->query
92 3
            ->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)
93 3
            ->where(Field::F_DELETION, 1)
94 3
            ->where(MaterialField::F_PRIMARY, $this->materialFieldId)
95 3
            ->count() > 0) {
96 3
                $hasImages = true;
97 3
            }
98 3
        }
99
100 3
        return $hasImages;
101
    }
102
103
    /**
104
     * Get collection of images for material by gallery additional field selector. If none is passed
105
     * all images from gallery table would be returned empty array.
106
     *
107
     * @param integer $currentPage current page with images. Min value = 1
108
     * @param integer $countView quantity view by page
109
     *
110
*@return array
111
     * @deprecated  Use find()
112
     */
113 2
    public function getImages($currentPage = null, $countView = 20)
114
    {
115 2
        return $this->find($currentPage, $countView);
116
    }
117
118
    /**
119
     * Perform SamsonCMS query and get entity gallery images.
120
     *
121
     * @param int $page Page number
122
     * @param int $size Page size
123
     *
124
     * @return GalleryField[] Collection of entity gallery images
125
     */
126 2
    public function find($page = null, $size = null)
127
    {
128
        /** @var GalleryField[] $images Get material images for this gallery */
129 2
        $images = array();
130
131
        /** @var QueryInterface $query Database query interface*/
132 2
        $query = null;
0 ignored issues
show
$query is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
133
134 2
        if ($this->hasImages()) {
135
            // Select all images in DB by materialFieldId
136 2
            $query = $this->query
137 2
                ->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)
138 2
                ->where(Field::F_DELETION, 1)
139 2
                ->where(MaterialField::F_PRIMARY, $this->materialFieldId);
140
141
            // Add paging
142 2
            if (isset($page) && $page > 0) {
143
                //Set limit for query
144 1
                $query->limit(--$page * $size, $size);
145 1
            }
146
147
            // Execute query
148 2
            $images = $query->exec();
149 2
        }
150
151 2
        return $images;
152
    }
153
}
154