Issues (17)

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.

Resolver/BuiltParameterResolver.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 LaravelYaml package.
5
 *
6
 * (c) Théo FIDRY <[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
namespace Fidry\LaravelYaml\DependencyInjection\Resolver;
13
14
use Fidry\LaravelYaml\Exception\DependencyInjection\Resolver\ParameterCircularReferenceException;
15
use Fidry\LaravelYaml\Exception\ParameterNotFoundException;
16
use Illuminate\Contracts\Config\Repository as ConfigRepository;
17
18
/**
19
 * @author Théo FIDRY <[email protected]>
20
 */
21
final class BuiltParameterResolver implements ParameterResolverInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private $defaultValue;
27
28
    /**
29
     * @var ConfigRepository
30
     */
31
    private $config;
32
33
    /**
34
     * @var array
35
     */
36
    private $parameters;
37
38 4
    public function __construct(array $parameters, ConfigRepository $config)
39
    {
40 4
        $this->parameters = $parameters;
41 4
        $this->config = $config;
42 4
        $this->defaultValue = spl_object_hash(new \stdClass());
43 4
    }
44
45
    /**
46
     * {@inheritdoc}array
47
     */
48 4
    public function resolve($value)
49
    {
50 4
        return $this->resolveValue($value);
51
    }
52
53
    /**
54
     * @param mixed $value
55
     * @param array $resolving
56
     *
57
     * @return mixed
58
     *
59
     * @throws ParameterCircularReferenceException
60
     * @throws ParameterNotFoundException
61
     */
62 4
    private function resolveValue($value, $resolving = [])
63
    {
64 4
        if (is_bool($value) || is_numeric($value)) {
65 2
            return $value;
66
        }
67
68 4
        if (is_array($value)) {
69 2
            return $this->resolveArray($value, $resolving);
70
        }
71
72 4
        if (is_string($value)) {
73 4
            return $this->resolveString($value, $resolving);
74
        }
75
76 2
        return $value;
77
    }
78
79 2 View Code Duplication
    private function resolveArray(array $arrayValue, array $resolving)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
    {
81 2
        $resolvedValue = [];
82 2
        foreach ($arrayValue as $key => $value) {
83 2
            $resolvedValue[$key] = $this->resolveValue($value, $resolving);
84 1
        }
85
86 2
        return $resolvedValue;
87
    }
88
89
    /**
90
     * @param $value
91
     * @param $resolving
92
     *
93
     * @return array|mixed
94
     * @throws ParameterCircularReferenceException
95
     * @throws ParameterNotFoundException
96
     */
97 4
    private function resolveString($value, array $resolving)
98
    {
99 4
        if (0 === preg_match('/^%([^%\s]+)%$/', $value, $match)) {
100 2
            if (false === array_key_exists($value, $resolving)) {
101 2
                return $value;
102
            }
103
104
            $key = $value;
105
        } else {
106 4
            $key = $match[1];
107
        }
108
109 4
        if (array_key_exists($key, $this->parameters)) {
110 2
            $resolving[$key] = true;
111
112 2
            return $this->resolveValue($this->parameters[$key], $resolving);
113
        }
114
115 4
        if ($this->config->has($key)) {
116 2
            return $this->config->get($key);
117
        }
118
119 4
        return $this->resolveEnvironmentValue($key);
120
    }
121
122
    /**
123
     * @param string $key
124
     *
125
     * @return string|int|bool|null
126
     * @throws ParameterNotFoundException
127
     */
128 4 View Code Duplication
    private function resolveEnvironmentValue($key)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
    {
130 4
        $environmentKey = strtoupper(str_replace('.', '_', $key));
131 4
        $value = env($environmentKey, $this->defaultValue);
132 4
        if ($this->defaultValue !== $value) {
133 2
            return $value;
134
        }
135
136 2
        throw new ParameterNotFoundException(sprintf('No parameter "%s" found', $key));
137
    }
138
}
139