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 (5)

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

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
declare(strict_types=1);
4
5
namespace Patoui\Router;
6
7
use InvalidArgumentException;
8
use Psr\Http\Message\StreamInterface;
9
use Psr\Http\Message\UploadedFileInterface;
10
use RuntimeException;
11
12
final class UploadedFile implements UploadedFileInterface
13
{
14
    private string $file;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
15
16
    private StreamInterface $stream;
17
18
    private bool $hasMoved = false;
19
20
    private ?int $size;
21
22
    private int $error;
23
24
    private ?string $name;
25
26
    private ?string $type;
27
28
    private bool $isSapi;
29
30
    /** @var array<int> */
31
    private static array $validUploadErrorCodes = [
32
        UPLOAD_ERR_OK,
33
        UPLOAD_ERR_INI_SIZE,
34
        UPLOAD_ERR_FORM_SIZE,
35
        UPLOAD_ERR_PARTIAL,
36
        UPLOAD_ERR_NO_FILE,
37
        UPLOAD_ERR_NO_TMP_DIR,
38
        UPLOAD_ERR_CANT_WRITE,
39
        UPLOAD_ERR_EXTENSION,
40
    ];
41
42
    /**
43
     * UploadedFile constructor.
44
     * @param string|StreamInterface $file
45
     * @param string|null            $name
46
     * @param string|null            $type
47
     * @param int|null               $size
48
     * @param int                    $error
49
     * @psalm-suppress RedundantConditionGivenDocblockType Used for is_string check.
50
     */
51
    public function __construct(
52
        $file,
53
        ?string $name = null,
54
        ?string $type = null,
55
        ?int $size = null,
56
        int $error = UPLOAD_ERR_OK
57
    ) {
58
        if (! in_array($error, self::$validUploadErrorCodes, true)) {
59
            throw new InvalidArgumentException('Invalid upload error code.');
60
        }
61
62
        if ($file instanceof StreamInterface) {
63
            /** @psalm-suppress MixedAssignment */
64
            $fileUri = $file->getMetadata('uri');
65
            if (! is_string($fileUri)) {
66
                throw new InvalidArgumentException('URI not available for given stream');
67
            }
68
            $this->file = $fileUri;
69
            $this->stream = $file;
70
        } elseif (is_string($file)) {
71
            $this->file = $file;
72
            $this->stream = (new StreamFactory())->createStreamFromFile($file);
73
        } else {
74
            throw new InvalidArgumentException('Invalid type for file, must be string or implement StreamInterface.');
75
        }
76
        $this->size = $size;
77
        $this->error = $error;
78
        $this->name = $name;
79
        $this->type = $type;
80
        $this->isSapi = ! empty($_FILES);
81
    }
82
83
    /**
84
     * @return array<UploadedFile>
85
     * @psalm-suppress MixedAssignment
86
     * @psalm-suppress MixedArrayAccess
87
     * @psalm-suppress MixedArgument
88
     */
89
    public static function makeWithGlobals(): array
90
    {
91
        $uploadedFiles = [];
92
93
        foreach ($_FILES as $field => $file) {
94
            if (is_string($file['tmp_name']) || (is_object($file['tmp_name']) && $file['tmp_name'] instanceof StreamInterface)) {
95
                $uploadedFiles[] = new static(
96
                    $file['tmp_name'],
97
                    isset($file['name']) ? (string) $file['name'] : null,
98
                    isset($file['type']) ? (string) $file['type'] : null,
99
                    isset($file['size']) ? (int) $file['size'] : null,
100
                    (int) ($file['error'] ?? UPLOAD_ERR_OK),
101
                );
102
            }
103
        }
104
105
        return $uploadedFiles;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function getStream(): StreamInterface
112
    {
113
        return $this->stream;
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function moveTo($targetPath): void
120
    {
121
        if ($this->hasMoved) {
122
            throw new RuntimeException('Uploaded file has already been moved');
123
        }
124
125
        if ($this->isSapi) {
126
            if (! is_uploaded_file($this->file)) {
127
                throw new RuntimeException('Invalid uploaded file');
128
            }
129
            if (! move_uploaded_file($this->file, $targetPath)) {
130
                throw new RuntimeException('Error occurred while moving file');
131
            }
132
        } elseif (! rename($this->file, $targetPath)) {
133
            throw new RuntimeException('Error occurred while moving file');
134
        }
135
    }
136
137
    /**
138
     * {@inheritdoc}
139
     */
140
    public function getSize(): ?int
141
    {
142
        return $this->size;
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function getError(): int
149
    {
150
        return $this->error;
151
    }
152
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public function getClientFilename(): ?string
157
    {
158
        return $this->name;
159
    }
160
161
    /**
162
     * {@inheritdoc}
163
     */
164
    public function getClientMediaType(): ?string
165
    {
166
        return $this->type;
167
    }
168
}
169