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

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/FieldValidator.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 Spatie\DataTransferObject;
6
7
use ReflectionProperty;
8
9
abstract class FieldValidator
10
{
11
    public bool $isNullable;
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...
12
13
    public bool $isMixed;
14
15
    public bool $isMixedArray;
16
17
    public bool $hasDefaultValue;
18
19
    public array $allowedTypes;
20
21
    public array $allowedArrayTypes;
22
23
    public array $allowedArrayKeyTypes;
24
25
    protected static array $typeMapping = [
26
        'int' => 'integer',
27
        'bool' => 'boolean',
28
        'float' => 'double',
29
    ];
30
31
    protected bool $hasTypeDeclaration;
32
33
    public static function fromReflection(ReflectionProperty $property): FieldValidator
34
    {
35
        $docDefinition = null;
36
37
        if ($property->getDocComment()) {
38
            preg_match(
39
                DocblockFieldValidator::DOCBLOCK_REGEX,
40
                $property->getDocComment(),
41
                $matches
42
            );
43
44
            $docDefinition = $matches[0] ?? null;
45
        }
46
47
        if ($docDefinition) {
48
            return new DocblockFieldValidator($docDefinition, $property->isDefault());
49
        }
50
51
        return new PropertyFieldValidator($property);
52
    }
53
54
    public function isValidType($value): bool
55
    {
56
        if (! $this->hasTypeDeclaration) {
57
            return true;
58
        }
59
60
        if ($this->isMixed) {
61
            return true;
62
        }
63
64
        if (is_iterable($value) && $this->isMixedArray) {
65
            return true;
66
        }
67
68
        if ($this->isNullable && $value === null) {
69
            return true;
70
        }
71
72
        if (is_iterable($value)) {
73
            return $this->isValidIterable($value);
74
        }
75
76
        return $this->isValidValue($value);
77
    }
78
79
    private function isValidIterable(iterable $iterable): bool
80
    {
81
        // If the iterable matches one of the normal types, we immediately return true
82
        // For example: custom collection classes type hinted with `MyCollection`
83
        $isValidValue = $this->isValidValue($iterable);
84
85
        if ($isValidValue) {
86
            return true;
87
        }
88
89
        // If not, we'll check all individual iterable items and keys
90
        foreach ($iterable as $key => $value) {
91
            $isValidValue = false;
92
93
            // First we check whether the value matches the value type definition
94
            foreach ($this->allowedArrayTypes as $type) {
95
                $isValidValue = $this->assertValidType($type, $value);
96
97
                // No need to further check this value when a valid type is found
98
                if ($isValidValue) {
99
                    break;
100
                }
101
            }
102
103
            // If a value is invalid, we immediately return false
104
            if (! $isValidValue) {
105
                return false;
106
            }
107
108
            // We'll assume keys are valid by default, since they can be omitted
109
            $isValidKey = true;
110
111
            // Next we check the key's value
112
            foreach ($this->allowedArrayKeyTypes as $keyType) {
113
                $isValidKey = $this->assertValidType($keyType, $key);
114
115
                // No need to further check this jey when a valid type is found
116
                if ($isValidKey) {
117
                    break;
118
                }
119
            }
120
121
            // If a key type is invalid, we'll immediately return
122
            if (! $isValidKey) {
123
                return false;
124
            }
125
126
            // Moving on to checking the next $key => $value pair
127
        }
128
129
        // If value and key type checks pass, we can return true
130
        return true;
131
    }
132
133
    private function isValidValue($value): bool
134
    {
135
        foreach ($this->allowedTypes as $type) {
136
            // We'll check the type of this value against all allowed types, if one matches we're good
137
            $isValidType = $this->assertValidType($type, $value);
138
139
            if ($isValidType) {
140
                return true;
141
            }
142
        }
143
144
        return false;
145
    }
146
147
    private function assertValidType(string $type, $value): bool
148
    {
149
        return $value instanceof $type || gettype($value) === $type;
150
    }
151
}
152