Issues (94)

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.

Imagine/Cache/Resolver/FlysystemResolver.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
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Imagine\Cache\Resolver;
13
14
use League\Flysystem\AdapterInterface;
15
use League\Flysystem\FilesystemInterface;
16
use Liip\ImagineBundle\Binary\BinaryInterface;
17
use Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotResolvableException;
18
use Symfony\Component\Routing\RequestContext;
19
20
class FlysystemResolver implements ResolverInterface
21
{
22
    /**
23
     * @var FilesystemInterface
24
     */
25
    protected $flysystem;
26
27
    /**
28
     * @var RequestContext
29
     */
30
    protected $requestContext;
31
32
    /**
33
     * @var string
34
     */
35
    protected $webRoot;
36
37
    /**
38
     * @var string
39
     */
40
    protected $cachePrefix;
41
42
    /**
43
     * @var string
44
     */
45
    protected $cacheRoot;
46
47
    /**
48
     * Flysystem specific visibility.
49
     *
50
     * @see AdapterInterface
51
     *
52
     * @var string
53
     */
54
    protected $visibility;
55
56
    /**
57
     * FlysystemResolver constructor.
58
     *
59
     * @param string $rootUrl
60
     * @param string $cachePrefix
61
     * @param string $visibility
62
     */
63
    public function __construct(
64
        FilesystemInterface $flysystem,
65
        RequestContext $requestContext,
66
        $rootUrl,
67
        $cachePrefix = 'media/cache',
68
        $visibility = AdapterInterface::VISIBILITY_PUBLIC
69
    ) {
70
        $this->flysystem = $flysystem;
71
        $this->requestContext = $requestContext;
72
73
        $this->webRoot = rtrim($rootUrl, '/');
74
        $this->cachePrefix = ltrim(str_replace('//', '/', $cachePrefix), '/');
75
        $this->cacheRoot = $this->cachePrefix;
76
        $this->visibility = $visibility;
77
    }
78
79
    /**
80
     * Checks whether the given path is stored within this Resolver.
81
     *
82
     * @param string $path
83
     * @param string $filter
84
     *
85
     * @return bool
86
     */
87
    public function isStored($path, $filter)
88
    {
89
        return $this->flysystem->has($this->getFilePath($path, $filter));
90
    }
91
92
    /**
93
     * Resolves filtered path for rendering in the browser.
94
     *
95
     * @param string $path   The path where the original file is expected to be
96
     * @param string $filter The name of the imagine filter in effect
97
     *
98
     * @throws NotResolvableException
99
     *
100
     * @return string The absolute URL of the cached image
101
     */
102 View Code Duplication
    public function resolve($path, $filter)
0 ignored issues
show
This method seems to be duplicated in 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...
103
    {
104
        return sprintf(
105
            '%s/%s',
106
            rtrim($this->webRoot, '/'),
107
            ltrim($this->getFileUrl($path, $filter), '/')
108
        );
109
    }
110
111
    /**
112
     * Stores the content of the given binary.
113
     *
114
     * @param BinaryInterface $binary The image binary to store
115
     * @param string          $path   The path where the original file is expected to be
116
     * @param string          $filter The name of the imagine filter in effect
117
     */
118
    public function store(BinaryInterface $binary, $path, $filter)
119
    {
120
        $this->flysystem->put(
121
            $this->getFilePath($path, $filter),
122
            $binary->getContent(),
123
            ['visibility' => $this->visibility, 'mimetype' => $binary->getMimeType()]
124
        );
125
    }
126
127
    /**
128
     * @param string[] $paths   The paths where the original files are expected to be
129
     * @param string[] $filters The imagine filters in effect
130
     */
131
    public function remove(array $paths, array $filters)
132
    {
133
        if (empty($paths) && empty($filters)) {
134
            return;
135
        }
136
137
        if (empty($paths)) {
138
            foreach ($filters as $filter) {
139
                $filterCacheDir = $this->cacheRoot.'/'.$filter;
140
                $this->flysystem->deleteDir($filterCacheDir);
141
            }
142
143
            return;
144
        }
145
146
        foreach ($paths as $path) {
147
            foreach ($filters as $filter) {
148
                if ($this->flysystem->has($this->getFilePath($path, $filter))) {
149
                    $this->flysystem->delete($this->getFilePath($path, $filter));
150
                }
151
            }
152
        }
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158
    protected function getFilePath($path, $filter)
159
    {
160
        return $this->getFileUrl($path, $filter);
161
    }
162
163
    /**
164
     * {@inheritdoc}
165
     */
166 View Code Duplication
    protected function getFileUrl($path, $filter)
0 ignored issues
show
This method seems to be duplicated in 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...
167
    {
168
        // crude way of sanitizing URL scheme ("protocol") part
169
        $path = str_replace('://', '---', $path);
170
171
        return $this->cachePrefix.'/'.$filter.'/'.ltrim($path, '/');
172
    }
173
}
174