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/Templating/Helper/MediaHelper.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
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\Templating\Helper;
15
16
use Sonata\MediaBundle\Model\MediaInterface;
17
use Sonata\MediaBundle\Provider\MediaProviderInterface;
18
use Sonata\MediaBundle\Provider\Pool;
19
use Symfony\Component\Templating\EngineInterface;
20
use Symfony\Component\Templating\Helper\Helper;
21
22
/**
23
 * MediaHelper manages action inclusions.
24
 *
25
 * @author Thomas Rabaix <[email protected]>
26
 *
27
 * @deprecated since sonata-project/media-bundle 3.10, will be removed in 4.0.
28
 * NEXT_MAJOR : remove this class
29
 */
30
class MediaHelper extends Helper
31
{
32
    /**
33
     * @var Pool|null
34
     */
35
    protected $pool = null;
36
37
    /**
38
     * @var EngineInterface|null
39
     */
40
    protected $templating = null;
41
42
    public function __construct(Pool $pool, EngineInterface $templating)
43
    {
44
        $this->pool = $pool;
45
        $this->templating = $templating;
46
    }
47
48
    public function getName()
49
    {
50
        return 'sonata_media';
51
    }
52
53
    /**
54
     * Returns the provider view for the provided media.
55
     *
56
     * @param MediaInterface $media
57
     * @param string         $format
58
     * @param array          $options
59
     *
60
     * @return string
61
     */
62
    public function media($media, $format, $options = [])
63
    {
64
        if (!$media) {
65
            return '';
66
        }
67
68
        $provider = $this->getProvider($media);
69
70
        $format = $provider->getFormatName($media, $format);
71
72
        $options = $provider->getHelperProperties($media, $format, $options);
73
74
        return $this->templating->render($provider->getTemplate('helper_view'), [
75
             'media' => $media,
76
             'format' => $format,
77
             'options' => $options,
78
        ]);
79
    }
80
81
    /**
82
     * Returns the thumbnail for the provided media.
83
     *
84
     * @param MediaInterface $media
85
     * @param string         $format
86
     * @param array          $options
87
     *
88
     * @return string
89
     */
90
    public function thumbnail($media, $format, $options = [])
91
    {
92
        if (!$media) {
93
            return '';
94
        }
95
96
        $provider = $this->getProvider($media);
97
98
        $format = $provider->getFormatName($media, $format);
99
        $formatDefinition = $provider->getFormat($format);
100
101
        // build option
102
        $options = array_merge([
103
            'title' => $media->getName(),
104
            'width' => $formatDefinition['width'],
105
        ], $options);
106
107
        $options['src'] = $provider->generatePublicUrl($media, $format);
108
109
        return $this->getTemplating()->render($provider->getTemplate('helper_thumbnail'), [
0 ignored issues
show
The method getTemplating() does not seem to exist on object<Sonata\MediaBundl...ing\Helper\MediaHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
110
            'media' => $media,
111
            'options' => $options,
112
        ]);
113
    }
114
115
    /**
116
     * @param MediaInterface $media
117
     * @param string         $format
118
     *
119
     * @return string
120
     */
121
    public function path($media, $format)
122
    {
123
        if (!$media) {
124
            return '';
125
        }
126
127
        $provider = $this->getProvider($media);
128
129
        $format = $provider->getFormatName($media, $format);
130
131
        return $provider->generatePublicUrl($media, $format);
132
    }
133
134
    /**
135
     * @return MediaProviderInterface
136
     */
137
    private function getProvider(MediaInterface $media)
138
    {
139
        return $this->pool->getProvider($media->getProviderName());
140
    }
141
}
142