GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (12)

Security Analysis    no request data  

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/Image.php (1 issue)

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
namespace Spatie\Image;
4
5
use BadMethodCallException;
6
use Intervention\Image\ImageManagerStatic as InterventionImage;
7
use Spatie\Image\Exceptions\InvalidImageDriver;
8
use Spatie\ImageOptimizer\OptimizerChainFactory;
9
10
/** @mixin \Spatie\Image\Manipulations */
11
class Image
12
{
13
    /** @var string */
14
    protected $pathToImage;
15
16
    /** @var \Spatie\Image\Manipulations */
17
    protected $manipulations;
18
19
    protected $imageDriver = 'gd';
20
21
    /** @var string|null */
22
    protected $temporaryDirectory = null;
23
24
    /**
25
     * @param string $pathToImage
26
     *
27
     * @return static
28
     */
29
    public static function load(string $pathToImage)
30
    {
31
        return new static($pathToImage);
32
    }
33
34
    public function setTemporaryDirectory($tempDir)
35
    {
36
        $this->temporaryDirectory = $tempDir;
37
38
        return $this;
39
    }
40
41
    public function __construct(string $pathToImage)
42
    {
43
        $this->pathToImage = $pathToImage;
44
45
        $this->manipulations = new Manipulations();
46
    }
47
48
    /**
49
     * @param string $imageDriver
50
     *
51
     * @return $this
52
     *
53
     * @throws InvalidImageDriver
54
     */
55
    public function useImageDriver(string $imageDriver)
56
    {
57
        if (! in_array($imageDriver, ['gd', 'imagick'])) {
58
            throw InvalidImageDriver::driver($imageDriver);
59
        }
60
61
        $this->imageDriver = $imageDriver;
62
63
        InterventionImage::configure([
64
            'driver' => $this->imageDriver,
65
        ]);
66
67
        return $this;
68
    }
69
70
    /**
71
     * @param callable|$manipulations
72
     *
73
     * @return $this
74
     */
75
    public function manipulate($manipulations)
76
    {
77
        if (is_callable($manipulations)) {
78
            $manipulations($this->manipulations);
79
        }
80
81
        if ($manipulations instanceof Manipulations) {
82
            $this->manipulations->mergeManipulations($manipulations);
0 ignored issues
show
$manipulations is of type object<Spatie\Image\Manipulations>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
83
        }
84
85
        return $this;
86
    }
87
88
    public function __call($name, $arguments)
89
    {
90
        if (! method_exists($this->manipulations, $name)) {
91
            throw new BadMethodCallException("Manipulation `{$name}` does not exist");
92
        }
93
94
        $this->manipulations->$name(...$arguments);
95
96
        return $this;
97
    }
98
99
    public function getWidth(): int
100
    {
101
        return InterventionImage::make($this->pathToImage)->width();
102
    }
103
104
    public function getHeight(): int
105
    {
106
        return InterventionImage::make($this->pathToImage)->height();
107
    }
108
109
    public function getManipulationSequence(): ManipulationSequence
110
    {
111
        return $this->manipulations->getManipulationSequence();
112
    }
113
114
    public function save($outputPath = '')
115
    {
116
        if ($outputPath == '') {
117
            $outputPath = $this->pathToImage;
118
        }
119
120
        $this->addFormatManipulation($outputPath);
121
122
        $glideConversion = GlideConversion::create($this->pathToImage)->useImageDriver($this->imageDriver);
123
124
        if (! is_null($this->temporaryDirectory)) {
125
            $glideConversion->setTemporaryDirectory($this->temporaryDirectory);
126
        }
127
128
        $glideConversion->performManipulations($this->manipulations);
129
130
        $glideConversion->save($outputPath);
131
132
        if ($this->shouldOptimize()) {
133
            $optimizerChainConfiguration = $this->manipulations->getFirstManipulationArgument('optimize');
134
135
            $optimizerChainConfiguration = json_decode($optimizerChainConfiguration, true);
136
137
            $this->performOptimization($outputPath, $optimizerChainConfiguration);
138
        }
139
    }
140
141
    protected function shouldOptimize(): bool
142
    {
143
        return ! is_null($this->manipulations->getFirstManipulationArgument('optimize'));
144
    }
145
146
    protected function performOptimization($path, array $optimizerChainConfiguration)
147
    {
148
        $optimizerChain = OptimizerChainFactory::create();
149
150
        if (count($optimizerChainConfiguration)) {
151
            $optimizers = array_map(function (array $optimizerOptions, string $optimizerClassName) {
152
                return (new $optimizerClassName)->setOptions($optimizerOptions);
153
            }, $optimizerChainConfiguration, array_keys($optimizerChainConfiguration));
154
155
            $optimizerChain->setOptimizers($optimizers);
156
        }
157
158
        $optimizerChain->optimize($path);
159
    }
160
161
    protected function addFormatManipulation($outputPath)
162
    {
163
        if ($this->manipulations->hasManipulation('format')) {
164
            return;
165
        }
166
167
        $inputExtension = strtolower(pathinfo($this->pathToImage, PATHINFO_EXTENSION));
168
        $outputExtension = strtolower(pathinfo($outputPath, PATHINFO_EXTENSION));
169
170
        if ($inputExtension === $outputExtension) {
171
            return;
172
        }
173
174
        $supportedFormats = ['jpg', 'pjpg', 'png', 'gif', 'webp'];
175
176
        if (in_array($outputExtension, $supportedFormats)) {
177
            $this->manipulations->format($outputExtension);
178
        }
179
    }
180
}
181