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.

Command/ResolveCacheCommand.php (2 issues)

Labels
Severity

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\Command;
13
14
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
15
use Liip\ImagineBundle\Imagine\Data\DataManager;
16
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Input\InputOption;
21
use Symfony\Component\Console\Output\OutputInterface;
22
23
class ResolveCacheCommand extends Command
24
{
25
    use CacheCommandTrait;
26
    protected static $defaultName = 'liip:imagine:cache:resolve';
27
28
    /**
29
     * @var DataManager
30
     */
31
    private $dataManager;
32
33
    public function __construct(DataManager $dataManager, CacheManager $cacheManager, FilterManager $filterManager)
34
    {
35
        parent::__construct();
36
37
        $this->dataManager = $dataManager;
38
        $this->cacheManager = $cacheManager;
39
        $this->filterManager = $filterManager;
40
    }
41
42
    protected function configure(): void
43
    {
44
        $this
45
            ->setDescription('Warms up the cache for the specified image sources with all or specified filters applied, and prints the list of cache files.')
46
            ->addArgument('paths', InputArgument::REQUIRED | InputArgument::IS_ARRAY,
47
                'Image file path(s) for which to generate the cached images.')
48
            ->addOption('filter', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
49
                'Filter(s) to use for image resolution; if none explicitly passed, use all filters.')
50
            ->addOption('force', 'F', InputOption::VALUE_NONE,
51
                'Force generating the image and writing the cache, regardless of whether a cached version already exists.')
52
            ->addOption('no-colors', 'C', InputOption::VALUE_NONE,
53
                'Write only un-styled text output; remove any colors, styling, etc.')
54
            ->addOption('as-script', 'S', InputOption::VALUE_NONE,
55
                'Write only machine-readable output; silenced verbose reporting and implies --no-colors.')
56
            ->setHelp(<<<'EOF'
57
The <comment>%command.name%</comment> command resolves the passed image(s) for the resolved
58
filter(s), outputting results using the following basic format:
59
  <info>image.ext[filter] (resolved|cached|failed): (resolve-image-path|exception-message)</>
60
61
<comment># bin/console %command.name% --filter=thumb1 foo.ext bar.ext</comment>
62
Resolve <options=bold>both</> <comment>foo.ext</comment> and <comment>bar.ext</comment> images using <options=bold>one</> filter (<comment>thumb1</comment>), outputting:
63
  <info>- foo.ext[thumb1] status: http://localhost/media/cache/thumb1/foo.ext</>
64
  <info>- bar.ext[thumb1] status: http://localhost/media/cache/thumb1/bar.ext</>
65
66
<comment># bin/console %command.name% --filter=thumb1 --filter=thumb3 foo.ext</comment>
67
Resolve <comment>foo.ext</comment> image using <options=bold>two</> filters (<comment>thumb1</comment> and <comment>thumb3</comment>), outputting:
68
  <info>- foo.ext[thumb1] status: http://localhost/media/cache/thumb1/foo.ext</>
69
  <info>- foo.ext[thumb3] status: http://localhost/media/cache/thumb3/foo.ext</>
70
71
<comment># bin/console %command.name% foo.ext</comment>
72
Resolve <comment>foo.ext</comment> image using <options=bold>all</> filters (as none were specified), outputting:
73
  <info>- foo.ext[thumb1] status: http://localhost/media/cache/thumb1/foo.ext</>
74
  <info>- foo.ext[thumb2] status: http://localhost/media/cache/thumb2/foo.ext</>
75
  <info>- foo.ext[thumb3] status: http://localhost/media/cache/thumb2/foo.ext</>
76
77
<comment># bin/console %command.name% --force --filter=thumb1 foo.ext</comment>
78
Resolve <comment>foo.ext</comment> image using <options=bold>one</> filter (<comment>thumb1</comment>) and <options=bold>forcing resolution</> (regardless of cache), outputting:
79
  <info>- foo.ext[thumb1] resolved: http://localhost/media/cache/thumb1/foo.ext</>
80
81
EOF
82
            );
83
    }
84
85
    protected function execute(InputInterface $input, OutputInterface $output): int
86
    {
87
        $this->setupOutputStyle($input, $output);
88
        $this->outputCommandHeader();
89
90
        $forced = $input->getOption('force');
91
        [$images, $filters] = $this->resolveInputFiltersAndPaths($input);
0 ignored issues
show
The variable $images does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $filters does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
92
93
        foreach ($images as $i) {
94
            foreach ($filters as $f) {
95
                $this->runCacheImageResolve($i, $f, $forced);
96
            }
97
        }
98
99
        $this->outputCommandResult($images, $filters, 'resolution');
100
101
        return $this->getResultCode();
102
    }
103
104
    private function runCacheImageResolve(string $image, string $filter, bool $forced): void
105
    {
106
        if (!$this->outputMachineReadable) {
107
            $this->io->text(' - ');
108
        }
109
110
        $this->io->group($image, $filter, 'blue');
111
112
        try {
113
            if ($forced || !$this->cacheManager->isStored($image, $filter)) {
114
                $this->cacheManager->store($this->filterManager->applyFilter($this->dataManager->find($filter, $image), $filter), $image, $filter);
115
                $this->io->status('resolved', 'green');
116
            } else {
117
                $this->io->status('cached', 'white');
118
            }
119
120
            $this->io->line(sprintf(' %s', $this->cacheManager->resolve($image, $filter)));
121
        } catch (\Exception $e) {
122
            ++$this->failures;
123
124
            $this->io->status('failed', 'red');
125
            $this->io->line(' %s', [$e->getMessage()]);
126
        }
127
    }
128
}
129