Issues (20)

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/Database/Schema.php (5 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
namespace Taisiya\PropelBundle\Database;
4
5
use Taisiya\PropelBundle\Database\Exception\InvalidArgumentException;
6
7
final class Schema
8
{
9
    /**
10
     * @var array
11
     */
12
    private $databases = [];
13
14
    /**
15
     * @param Database $database
16
     *
17
     * @throws InvalidArgumentException
18
     *
19
     * @return self
20
     */
21 View Code Duplication
    public function createDatabase(Database $database): self
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...
22
    {
23
        if ($this->hasDatabase($database::getName())) {
24
            throw new InvalidArgumentException('Database '.$database::getName().' already added');
25
        }
26
27
        $this->databases[$database::getName()] = $database;
28
29
        return $this;
30
    }
31
32
    /**
33
     * @param Database $database
34
     *
35
     * @return Schema
36
     */
37
    public function createDatabaseIfNotExists(Database $database): self
38
    {
39
        if (!$this->hasDatabase($database::getName())) {
40
            $this->createDatabase($database);
41
        }
42
43
        return $this;
44
    }
45
46
    /**
47
     * @param Database $database
48
     *
49
     * @throws InvalidArgumentException
50
     *
51
     * @return Schema
52
     */
53 View Code Duplication
    public function removeDatabase(Database $database): self
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...
54
    {
55
        if (!$this->hasDatabase($database::getName())) {
56
            throw new InvalidArgumentException('Database '.$database::getName().' not exists');
57
        }
58
59
        unset($this->databases[$database::getName()]);
60
61
        return $this;
62
    }
63
64
    /**
65
     * @param string $name
66
     *
67
     * @throws InvalidArgumentException
68
     *
69
     * @return Database
70
     */
71
    public function getDatabase(string $name): Database
72
    {
73
        if (!array_key_exists($name, $this->databases)) {
74
            throw new InvalidArgumentException('Database '.$name.' not added');
75
        }
76
77
        return $this->databases[$name];
78
    }
79
80
    public function getDatabaseByClassName(string $class): Database
0 ignored issues
show
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
81
    {
82
    }
83
84
    /**
85
     * @param string $name
86
     *
87
     * @return bool
88
     */
89
    public function hasDatabase(string $name): bool
90
    {
91
        return array_key_exists($name, $this->databases);
92
    }
93
94
    public function hasDatabaseByClassName(string $className): bool
95
    {
96
        if (!class_exists($className)) {
97
            throw new InvalidArgumentException('Class '.$className.' not exists.');
98
        }
99
        $reflectionClass = new \ReflectionClass($className);
100
        if (!$reflectionClass->isSubclassOf(Database::class)) {
101
            throw new InvalidArgumentException('Class must be instance of '.Database::class.'.');
102
        }
103
        $name = $reflectionClass->getMethod('getName')->invoke($reflectionClass);
104
        exit(var_dump($name));
0 ignored issues
show
Security Debugging Code introduced by
var_dump($name); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
105
    }
106
107
    /**
108
     * @return array
109
     */
110
    public function getDatabases(): array
111
    {
112
        return $this->databases;
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    final public function generateOutputXml(): string
0 ignored issues
show
Unnecessary FINAL modifier in FINAL class
Loading history...
119
    {
120
        $dom               = new \DOMDocument('1.0', 'UTF-8');
121
        $dom->formatOutput = true;
122
123
        /** @var Database $database */
124
        foreach ($this->getDatabases() as $database) {
125
            $database->appendToXmlDocument($dom);
126
        }
127
128
        return $dom->saveXML();
129
    }
130
}
131