Issues (10)

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/Config.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 EasyRSA;
6
7
use function count;
8
use EasyRSA\Interfaces\ConfigInterface;
9
use InvalidArgumentException;
10
11
/**
12
 * Class Config.
13
 */
14
class Config implements ConfigInterface
15
{
16
    /**
17
     * Path to archive with EasyRSA scripts
18
     */
19
    public $archive = './easy-rsa.tar.gz';
20
21
    /**
22
     * Path to folder with EasyRSA scripts
23
     */
24
    public $scripts = './easy-rsa';
25
26
    /**
27
     * Part to certificates store folder
28
     */
29
    public $certs = './easy-rsa-certs';
30
31
    /**
32
     * List of allowed variables
33
     */
34
    public const ALLOWED = [
35
        'scripts',
36
        'archive',
37
        'certs',
38
    ];
39
40
    /**
41
     * Config constructor.
42
     *
43
     * @param array<string, string> $parameters
44
     */
45 12
    public function __construct(array $parameters = [])
46
    {
47 12
        foreach ($parameters as $key => $value) {
48 1
            $this->set($key, $value);
49
        }
50 12
    }
51
52
    /**
53
     * {@inheritdoc}
54
     *
55
     * @throws \InvalidArgumentException If wrong key name provided
56
     */
57 3
    public function set(string $name, $value = null, bool $resolveAbsolutePath = true): ConfigInterface
58
    {
59 3
        if (!in_array($name, self::ALLOWED, true)) {
60 2
            throw new InvalidArgumentException('Parameter "' . $name . '" is not in allowed list [' . implode(',', self::ALLOWED) . ']');
61
        }
62
63 1
        $this->$name = $resolveAbsolutePath ? $this->resolvePath($value) : $value;
0 ignored issues
show
It seems like $value defined by parameter $value on line 57 can also be of type boolean or null; however, EasyRSA\Config::resolvePath() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
64
65 1
        return $this;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     *
71
     * @throws \InvalidArgumentException If wrong key name provided
72
     */
73 4
    public function get(string $name)
74
    {
75 4
        if (!in_array($name, self::ALLOWED, true)) {
76 1
            throw new InvalidArgumentException('Parameter "' . $name . '" is not in allowed list [' . implode(',', self::ALLOWED) . ']');
77
        }
78
79 3
        return $this->$name;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 5
    public function resolvePath(string $path, string $basePath = null): string
86
    {
87
        // Make absolute path
88 5
        if (DIRECTORY_SEPARATOR !== $path[0]) {
89 1
            if (null === $basePath) {
90
                // Get PWD first to avoid getcwd() resolving symlinks if in symlinked folder
91 1
                $path = (getenv('PWD') ?: getcwd()) . DIRECTORY_SEPARATOR . $path;
92
            } elseif ('' !== $basePath) {
93
                $path = $basePath . DIRECTORY_SEPARATOR . $path;
94
            }
95
        }
96
97
        // Resolve '.' and '..'
98 5
        $components = [];
99 5
        foreach (explode(DIRECTORY_SEPARATOR, rtrim($path, DIRECTORY_SEPARATOR)) as $name) {
100 5
            if ('..' === $name) {
101 2
                array_pop($components);
102 5
            } elseif ('.' !== $name && !(count($components) > 0 && '' === $name)) {
103
                // … && !(count($components) && $name === '') - we want to keep initial '/' for abs paths
104 5
                $components[] = $name;
105
            }
106
        }
107
108 5
        return implode(DIRECTORY_SEPARATOR, $components);
109
    }
110
111
    /**
112
     * @codeCoverageIgnore
113
     * @deprecated Use ->get('certs')
114
     */
115
    public function getCerts(): string
116
    {
117
        return $this->get('certs');
118
    }
119
120
    /**
121
     * @param string $path
122
     *
123
     * @return \EasyRSA\Interfaces\ConfigInterface
124
     * @codeCoverageIgnore
125
     * @deprecated Use ->set('certs')
126
     */
127
    public function setCerts(string $path): ConfigInterface
128
    {
129
        return $this->set('certs', $path, true);
130
    }
131
132
    /**
133
     * @codeCoverageIgnore
134
     * @deprecated Use ->get('scripts')
135
     */
136
    public function getScripts(): string
137
    {
138
        return $this->get('scripts');
139
    }
140
141
    /**
142
     * @param string $path
143
     *
144
     * @return \EasyRSA\Interfaces\ConfigInterface
145
     * @codeCoverageIgnore
146
     * @deprecated Use ->set('scripts')
147
     */
148
    public function setScripts(string $path): ConfigInterface
149
    {
150
        return $this->set('scripts', $path, true);
151
    }
152
153
    /**
154
     * @codeCoverageIgnore
155
     * @deprecated Use ->get('archive')
156
     */
157
    public function getArchive(): string
158
    {
159
        return $this->get('archive');
160
    }
161
162
    /**
163
     * @param string $path
164
     *
165
     * @return \EasyRSA\Interfaces\ConfigInterface
166
     * @codeCoverageIgnore
167
     * @deprecated Use ->set('archive')
168
     */
169
    public function setArchive(string $path): ConfigInterface
170
    {
171
        return $this->set('archive', $path, true);
172
    }
173
}
174