Issues (234)

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.

src/Model/Gallery.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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\Model;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
use Sonata\MediaBundle\Provider\MediaProviderInterface;
19
20
/**
21
 * NEXT_MAJOR: remove GalleryMediaCollectionInterface interface. Move its content into GalleryInterface.
22
 */
23
abstract class Gallery implements GalleryInterface, GalleryMediaCollectionInterface
24
{
25
    /**
26
     * @var string
27
     */
28
    protected $context;
29
30
    /**
31
     * @var string
32
     */
33
    protected $name;
34
35
    /**
36
     * @var bool
37
     */
38
    protected $enabled;
39
40
    /**
41
     * @var \DateTime|null
42
     */
43
    protected $updatedAt;
44
45
    /**
46
     * @var \DateTime|null
47
     */
48
    protected $createdAt;
49
50
    /**
51
     * @var string
52
     */
53
    protected $defaultFormat = MediaProviderInterface::FORMAT_REFERENCE;
54
55
    /**
56
     * @var GalleryItemInterface[]|Collection
57
     */
58
    protected $galleryItems;
59
60
    public function __toString()
61
    {
62
        return $this->getName() ?: '-';
63
    }
64
65
    public function setName($name): void
66
    {
67
        $this->name = $name;
68
    }
69
70
    public function getName()
71
    {
72
        return $this->name;
73
    }
74
75
    public function setEnabled($enabled): void
76
    {
77
        $this->enabled = $enabled;
78
    }
79
80
    public function getEnabled()
81
    {
82
        return $this->enabled;
83
    }
84
85
    public function setUpdatedAt(?\DateTime $updatedAt = null): void
86
    {
87
        $this->updatedAt = $updatedAt;
88
    }
89
90
    public function getUpdatedAt()
91
    {
92
        return $this->updatedAt;
93
    }
94
95
    public function setCreatedAt(?\DateTime $createdAt = null): void
96
    {
97
        $this->createdAt = $createdAt;
98
    }
99
100
    public function getCreatedAt()
101
    {
102
        return $this->createdAt;
103
    }
104
105
    public function setDefaultFormat($defaultFormat): void
106
    {
107
        $this->defaultFormat = $defaultFormat;
108
    }
109
110
    public function getDefaultFormat()
111
    {
112
        return $this->defaultFormat;
113
    }
114
115
    public function setGalleryItems($galleryItems): void
116
    {
117
        $this->galleryItems = new ArrayCollection();
118
119
        foreach ($galleryItems as $galleryItem) {
120
            $this->addGalleryItem($galleryItem);
121
        }
122
    }
123
124
    public function getGalleryItems()
125
    {
126
        return $this->galleryItems;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->galleryItems; of type Sonata\MediaBundle\Model...\Collections\Collection adds the type Doctrine\Common\Collections\Collection to the return on line 126 which is incompatible with the return type declared by the interface Sonata\MediaBundle\Model...erface::getGalleryItems of type Sonata\MediaBundle\Model\GalleryItemInterface[].
Loading history...
127
    }
128
129
    public function addGalleryItem(GalleryItemInterface $galleryItem): void
130
    {
131
        $galleryItem->setGallery($this);
132
133
        $this->galleryItems[] = $galleryItem;
134
    }
135
136
    public function setContext($context): void
137
    {
138
        $this->context = $context;
139
    }
140
141
    public function getContext()
142
    {
143
        return $this->context;
144
    }
145
146
    /**
147
     * Reorders $galleryItems based on their position.
148
     */
149
    public function reorderGalleryItems()
150
    {
151
        if ($this->getGalleryItems() && $this->getGalleryItems() instanceof \IteratorAggregate) {
152
            // reorder
153
            $iterator = $this->getGalleryItems()->getIterator();
154
155
            $iterator->uasort(static function ($a, $b) {
156
                if ($a->getPosition() === $b->getPosition()) {
157
                    return 0;
158
                }
159
160
                return $a->getPosition() > $b->getPosition() ? 1 : -1;
161
            });
162
163
            $this->setGalleryItems($iterator);
0 ignored issues
show
$iterator is of type object<Traversable>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
164
        }
165
    }
166
}
167