Issues (3099)

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.

AdminList/MediaAdminListConfigurator.php (1 issue)

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 Kunstmaan\MediaBundle\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\QueryBuilder;
7
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
8
use Kunstmaan\AdminListBundle\AdminList\Configurator\ChangeableLimitInterface;
9
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
10
use Kunstmaan\AdminListBundle\Traits\ChangeableLimitTrait;
11
use Kunstmaan\MediaBundle\AdminList\ItemAction\MediaDeleteItemAction;
12
use Kunstmaan\MediaBundle\AdminList\ItemAction\MediaEditItemAction;
13
use Kunstmaan\MediaBundle\AdminList\ItemAction\MediaSelectItemAction;
14
use Kunstmaan\MediaBundle\Entity\Folder;
15
use Kunstmaan\MediaBundle\Form\Type\MediaType;
16
use Kunstmaan\MediaBundle\Helper\MediaManager;
17
use Kunstmaan\MediaBundle\Helper\RemoteAudio\RemoteAudioHandler;
18
use Kunstmaan\MediaBundle\Helper\RemoteSlide\RemoteSlideHandler;
19
use Kunstmaan\MediaBundle\Helper\RemoteVideo\RemoteVideoHandler;
20
use Symfony\Component\HttpFoundation\Request;
21
22
/**
23
 * The admin list configurator for the Media entity
24
 */
25
class MediaAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator implements ChangeableLimitInterface
26
{
27
    use ChangeableLimitTrait;
28
29
    /**
30
     * @var Folder
31
     */
32
    private $folder;
33
34
    /**
35
     * @var Request
36
     */
37
    private $request;
38
39
    /**
40
     * @param EntityManager $em           The entity manager
41
     * @param MediaManager  $mediaManager The media manager
42
     * @param Folder        $folder       The current folder
43
     * @param Request       $request      The request object
44
     */
45
    public function __construct(
46
        EntityManager $em,
47
        MediaManager $mediaManager,
48
        Folder $folder,
49
        Request $request
0 ignored issues
show
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
50
    ) {
51
        parent::__construct($em);
52
53
        $this->setAdminType(MediaType::class);
54
55
        $this->folder = $folder;
56
        $this->request = $request;
57
    }
58
59
    /**
60
     * Configure the visible columns
61
     */
62
    public function buildFields()
63
    {
64
        $this->addField('name', 'media.adminlist.configurator.name', true);
65
        $this->addField('contentType', 'media.adminlist.configurator.type', true);
66
        $this->addField('updatedAt', 'media.adminlist.configurator.date', true);
67
        $this->addField('filesize', 'media.adminlist.configurator.filesize', true);
68
    }
69
70
    /**
71
     * Build filters for admin list
72
     */
73
    public function buildFilters()
74
    {
75
        $this->addFilter('name', new ORM\StringFilterType('name'), 'media.adminlist.configurator.filter.name');
76
        $this->addFilter('contentType', new ORM\StringFilterType('contentType'), 'media.adminlist.configurator.filter.type');
77
        $this->addFilter('updatedAt', new ORM\NumberFilterType('updatedAt'), 'media.adminlist.configurator.filter.updated_at');
78
        $this->addFilter('filesize', new ORM\NumberFilterType('filesize'), 'media.adminlist.configurator.filter.filesize');
79
    }
80
81
    /**
82
     * Return the url to list all the items
83
     *
84
     * @return array
85
     */
86
    public function getIndexUrl()
87
    {
88
        return array(
89
            'path' => $this->request->get('_route'),
90
            'params' => array('folderId' => $this->folder->getId()),
91
        );
92
    }
93
94
    /**
95
     * @param object|array $item
96
     *
97
     * @return bool
98
     */
99
    public function canEdit($item)
100
    {
101
        return false;
102
    }
103
104
    /**
105
     * Configure if it's possible to delete the given $item
106
     *
107
     * @param object|array $item
108
     *
109
     * @return bool
110
     */
111
    public function canDelete($item)
112
    {
113
        return false;
114
    }
115
116
    /**
117
     * Add item actions buttons
118
     */
119
    public function buildItemActions()
120
    {
121
        if ($this->request->get('_route') == 'KunstmaanMediaBundle_chooser_show_folder') {
122
            $this->addItemAction(new MediaSelectItemAction());
123
        } else {
124
            $this->addItemAction(new MediaEditItemAction());
125
            $this->addItemAction(new MediaDeleteItemAction($this->request->getRequestUri()));
126
        }
127
    }
128
129
    /**
130
     * Get bundle name
131
     *
132
     * @return string
133
     */
134
    public function getBundleName()
135
    {
136
        return 'KunstmaanMediaBundle';
137
    }
138
139
    /**
140
     * Get entity name
141
     *
142
     * @return string
143
     */
144
    public function getEntityName()
145
    {
146
        return 'Media';
147
    }
148
149
    /**
150
     * @param QueryBuilder $queryBuilder
151
     */
152
    public function adaptQueryBuilder(QueryBuilder $queryBuilder)
153
    {
154
        $queryBuilder->andWhere('b.folder = :folder')
155
            ->setParameter('folder', $this->folder->getId())
156
            ->andWhere('b.deleted = 0')
157
            ->orderBy('b.updatedAt', 'DESC');
158
159
        if ($this->request->get('_route') == 'KunstmaanMediaBundle_chooser_show_folder') {
160
            $type = $this->request->query->get('type');
161
            if ($type) {
162
                switch ($type) {
163
                    case 'file':
164
                        $queryBuilder->andWhere('b.location = :location')
165
                            ->setParameter('location', 'local');
166
167
                        break;
168
                    case 'image':
169
                        $queryBuilder->andWhere('b.contentType LIKE :ctype')
170
                            ->setParameter('ctype', '%image%');
171
172
                        break;
173
                    case RemoteAudioHandler::TYPE:
174
                        $queryBuilder->andWhere('b.contentType = :ctype')
175
                            ->setParameter('ctype', RemoteAudioHandler::CONTENT_TYPE);
176
177
                        break;
178
                    case RemoteSlideHandler::TYPE:
179
                        $queryBuilder->andWhere('b.contentType = :ctype')
180
                            ->setParameter('ctype', RemoteSlideHandler::CONTENT_TYPE);
181
182
                        break;
183
                    case RemoteVideoHandler::TYPE:
184
                        $queryBuilder->andWhere('b.contentType = :ctype')
185
                            ->setParameter('ctype', RemoteVideoHandler::CONTENT_TYPE);
186
187
                        break;
188
                }
189
            }
190
        }
191
    }
192
}
193