Issues (6)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/UriTemplate/VariableBag.php (1 issue)

1
<?php
2
3
/**
4
 * League.Uri (https://uri.thephpleague.com)
5
 *
6
 * (c) Ignace Nyamagana Butera <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace League\Uri\UriTemplate;
15
16
use League\Uri\Exceptions\TemplateCanNotBeExpanded;
17
use function gettype;
18
use function is_array;
19
use function is_bool;
20
use function is_object;
21
use function is_scalar;
22
use function method_exists;
23
use function sprintf;
24
25
final class VariableBag
26
{
27
    /**
28
     * @var array<string,string|array<string>>
29
     */
30
    private $variables = [];
31
32
    /**
33
     * @param iterable<string,mixed> $variables
34
     */
35 18
    public function __construct(iterable $variables = [])
36
    {
37 18
        foreach ($variables as $name => $value) {
38 12
            $this->assign($name, $value);
39
        }
40 14
    }
41
42 2
    public static function __set_state(array $properties): self
43
    {
44 2
        return new self($properties['variables']);
45
    }
46
47
    /**
48
     * @return array<string,string|array<string>>
49
     */
50 6
    public function all(): array
51
    {
52 6
        return $this->variables;
53
    }
54
55
    /**
56
     * Fetches the variable value if none found returns null.
57
     *
58
     * @return null|string|array<string>
59
     */
60 14
    public function fetch(string $name)
61
    {
62 14
        return $this->variables[$name] ?? null;
63
    }
64
65
    /**
66
     * @param string|array<string> $value
67
     */
68 24
    public function assign(string $name, $value): void
69
    {
70 24
        $this->variables[$name] = $this->normalizeValue($value, $name, true);
71 20
    }
72
73
    /**
74
     * @param mixed $value the value to be expanded
75
     *
76
     * @throws TemplateCanNotBeExpanded if the value contains nested list
77
     *
78
     * @return string|array<string>
79
     */
80 24
    private function normalizeValue($value, string $name, bool $isNestedListAllowed)
81
    {
82 24
        if (is_bool($value)) {
83 4
            return true === $value ? '1' : '0';
84
        }
85
86 22
        if (null === $value || is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) {
87 18
            return (string) $value;
88
        }
89
90 10
        if (!is_array($value)) {
91 2
            throw new \TypeError(sprintf('The variable '.$name.' must be NULL, a scalar or a stringable object `%s` given', gettype($value)));
92
        }
93
94 8
        if (!$isNestedListAllowed) {
95 2
            throw TemplateCanNotBeExpanded::dueToNestedListOfValue($name);
96
        }
97
98 8
        foreach ($value as &$var) {
99 8
            $var = self::normalizeValue($var, $name, false);
0 ignored issues
show
Bug Best Practice introduced by
The method League\Uri\UriTemplate\V...leBag::normalizeValue() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
            /** @scrutinizer ignore-call */ 
100
            $var = self::normalizeValue($var, $name, false);
Loading history...
100
        }
101 6
        unset($var);
102
103 6
        return $value;
104
    }
105
106
    /**
107
     * Replaces elements from passed variables into the current instance.
108
     */
109 4
    public function replace(VariableBag $variables): self
110
    {
111 4
        $instance = clone $this;
112 4
        $instance->variables += $variables->variables;
113
114 4
        return $instance;
115
    }
116
}
117