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.

Component/Console/Style/ImagineStyle.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\Component\Console\Style;
13
14
use Liip\ImagineBundle\Exception\InvalidArgumentException;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
use ValueError;
19
20
/**
21
 * @internal
22
 */
23
final class ImagineStyle
24
{
25
    /**
26
     * @var SymfonyStyle
27
     */
28
    private $io;
29
30
    /**
31
     * @var bool
32
     */
33
    private $decoration;
34
35
    public function __construct(InputInterface $input, OutputInterface $output, bool $decoration = true)
36
    {
37
        $this->io = new SymfonyStyle($input, $output);
38
        $this->decoration = $decoration;
39
    }
40
41
    public function text(string $string, array $replacements = []): self
42
    {
43
        $this->io->write($this->compileString($string, $replacements));
44
45
        return $this;
46
    }
47
48
    public function line(string $string, array $replacements = []): self
49
    {
50
        $this->io->writeln($this->compileString($string, $replacements));
51
52
        return $this;
53
    }
54
55
    public function newline(int $count = 1): self
56
    {
57
        $this->io->newLine($count);
58
59
        return $this;
60
    }
61
62
    public function status(string $status, string $fg = null): self
63
    {
64
        return $this->text(
65
            sprintf('<fg=%2$s>(</><fg=%2$s;options=bold>%1$s</><fg=%2$s>)</>', $status, $fg ?: 'default')
66
        );
67
    }
68
69
    public function group(string $item, string $group, string $fg = null): self
70
    {
71
        $this->text(
72
            sprintf('<fg=%3$s;options=bold>%1$s[</><fg=%3$s>%2$s</><fg=%3$s;options=bold>]</>', $item, $group, $fg ?: 'default')
73
        );
74
75
        return $this->space();
76
    }
77
78
    public function title(string $title, string $type = null): self
79
    {
80
        if (!$this->decoration) {
81
            return $this->plainTitle($title, $type);
82
        }
83
84
        return $this->block($title, $type, 'white', 'cyan');
85
    }
86
87
    public function okayBlock(string $string, array $replacements = []): self
88
    {
89
        return $this->largeBlock($this->compileString(strip_tags($string), $replacements), 'OKAY', 'black', 'green', '-');
90
    }
91
92
    public function critBlock(string $string, array $replacements = []): self
93
    {
94
        return $this->largeBlock($this->compileString(strip_tags($string), $replacements), 'ERROR', 'white', 'red', '#');
95
    }
96
97
    private function largeBlock(string $string, string $type, string $fg = null, string $bg = null, string $prefix = null): self
98
    {
99
        return $this->block($string, $type, $fg, $bg, $prefix, true);
100
    }
101
102
    private function space(int $count = 1): self
103
    {
104
        return $this->text(str_repeat(' ', $count));
105
    }
106
107
    private function plainTitle(string $title, string $type = null): self
108
    {
109
        $this->newline();
110
111
        if ($type) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $type of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
112
            $this->line('# [%s] %s', [$type, $title]);
113
        } else {
114
            $this->line('# %s', [$title]);
115
        }
116
117
        return $this->newline();
118
    }
119
120
    private function block(string $string, string $type = null, string $fg = null, string $bg = null, string $prefix = null, bool $padding = true): self
121
    {
122
        if (!$this->decoration) {
123
            return $this->plainBlock($string, $type);
124
        }
125
126
        $this->io->block($string, $type, sprintf('fg=%s;bg=%s', $fg ?: 'default', $bg ?: 'default'), $prefix ? sprintf(' %s ', $prefix) : ' ', $padding);
127
128
        return $this;
129
    }
130
131
    private function plainBlock(string $string, string $type): self
132
    {
133
        return $this
134
            ->newline()
135
            ->line('[%s] %s', [$type, $string])
136
            ->newline();
137
    }
138
139
    private function compileString(string $format, array $replacements = []): string
140
    {
141
        if (!$this->decoration) {
142
            $format = strip_tags($format);
143
        }
144
145
        if (0 === \count($replacements)) {
146
            return $format;
147
        }
148
149
        try {
150
            if (false !== $compiled = @vsprintf($format, $replacements)) {
151
                return $compiled;
152
            }
153
        } catch (ValueError $error) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
154
        }
155
156
        throw new InvalidArgumentException(sprintf('Invalid string format "%s" or replacements "%s".', $format, implode(', ', array_map(function ($replacement) { return var_export($replacement, true); }, $replacements))));
157
    }
158
}
159