Issues (3)

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/ProvisionConfig.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
namespace Tworzenieweb\SqlProvisioner\Config;
4
5
use Dotenv\Dotenv;
6
7
/**
8
 * Class ProvisionConfig
9
 *
10
 * @package Tworzenieweb\SqlProvisioner\Config
11
 */
12
class ProvisionConfig
13
{
14
    /**
15
     * @var string
16
     */
17
    private $envPath;
18
19
    /**
20
     * @var bool
21
     */
22
    private $force = false;
23
24
    /**
25
     * @var bool
26
     */
27
    private $skipProvisioned = false;
28
29
    /**
30
     * @var bool
31
     */
32
    private $skipSyntaxCheck = false;
33
34
    /**
35
     * @var EmailConfig
36
     */
37
    private $emailConfig;
38
39
    /**
40
     * ProvisionConfig constructor.
41
     *
42
     * @param string      $envPath
43
     * @param EmailConfig $emailConfig
44
     */
45
    public function __construct(string $envPath, EmailConfig $emailConfig)
46
    {
47
        $this->envPath     = $envPath;
48
        $this->emailConfig = $emailConfig;
49
    }
50
51
    /**
52
     * @param string $envPath
53
     *
54
     * @return ProvisionConfig
55
     */
56
    public function withEnvPath(string $envPath): ProvisionConfig
57
    {
58
        $this->envPath = $envPath;
59
60
        return $this;
61
    }
62
63
    /**
64
     * @param bool $force
65
     *
66
     * @return ProvisionConfig
67
     */
68
    public function force(bool $force = true): ProvisionConfig
69
    {
70
        $this->force = $force;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @param bool $skipProvisioned
77
     *
78
     * @return ProvisionConfig
79
     */
80
    public function skipProvisioned(bool $skipProvisioned = true): ProvisionConfig
81
    {
82
        $this->skipProvisioned = $skipProvisioned;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @param bool $skipSyntaxCheck
89
     *
90
     * @return ProvisionConfig
91
     */
92
    public function skipSyntaxCheck(bool $skipSyntaxCheck = true): ProvisionConfig
93
    {
94
        $this->skipSyntaxCheck = $skipSyntaxCheck;
95
96
        return $this;
97
    }
98
99
    /**
100
     * @return ProvisionConfig
101
     */
102
    public function sendEmail(): ProvisionConfig
103
    {
104
        $this->emailConfig->enable();
105
106
        return $this;
107
    }
108
109
    /**
110
     * @return ProvisionConfig
111
     */
112
    public function skipEmail(): ProvisionConfig
113
    {
114
        $this->emailConfig->disable();
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return void
121
     */
122
    public function load()
123
    {
124
        $loader = $this->composeDotenv();
125
        $loader->load();
126
127
        if ($this->emailConfig->isEnabled()) {
128
            $loader->required(EmailConfig::MANDATORY_ENV_VARIABLES)->notEmpty();
129
        }
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getEnvPath(): string
136
    {
137
        return $this->envPath;
138
    }
139
140
    /**
141
     * @return bool
142
     */
143
    public function isForce(): bool
144
    {
145
        return $this->force;
146
    }
147
148
    /**
149
     * @return bool
150
     */
151
    public function isSkipProvisioned(): bool
152
    {
153
        return $this->skipProvisioned;
154
    }
155
156
    /**
157
     * @return bool
158
     */
159
    public function isSkipSyntaxCheck(): bool
160
    {
161
        return $this->skipSyntaxCheck;
162
    }
163
164
    /**
165
     * @return bool
166
     */
167
    public function isSendEmail(): bool
168
    {
169
        return $this->sendEmail;
0 ignored issues
show
The property sendEmail does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
170
    }
171
172
    /**
173
     * @return Dotenv
174
     */
175
    protected function composeDotenv(): Dotenv
176
    {
177
        if (!is_readable($this->envPath)) {
178
            throw new \RuntimeException(
179
                sprintf('Env file path [%s] is not readable', $this->envPath)
180
            );
181
        }
182
183
        if (is_dir($this->envPath)) {
184
            return new Dotenv($this->envPath);
185
        }
186
187
        if (is_file($this->envPath)) {
188
            return new Dotenv(dirname($this->envPath), basename($this->envPath));
189
        }
190
191
        throw new \RuntimeException(
192
            sprintf('Could not define whether provided env path [%s] is a directory or file', $this->envPath)
193
        );
194
    }
195
}
196