Issues (66)

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/Scripts/StaticConfigurationDumper.php (15 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 namespace Comodojo\Installer\Scripts;
2
3
use \Comodojo\Exception\InstallerException;
4
5
/**
6
 * Comodojo Installer
7
 *
8
 * @package     Comodojo Framework
9
 * @author      Marco Giovinazzi <[email protected]>
10
 * @license     GPL-3.0+
11
 *
12
 * LICENSE:
13
 *
14
 * This program is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License as
16
 * published by the Free Software Foundation, either version 3 of the
17
 * License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public License
25
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
 */
27
28
class StaticConfigurationDumper {
29
30
    private $settings = array(
31
        'COMODOJO_DATABASE_MODEL' => 'MYSQL',
32
        'COMODOJO_DATABASE_HOST' => 'localhost',
33
        'COMODOJO_DATABASE_PORT' => 3306,
34
        'COMODOJO_DATABASE_NAME' => 'comodojo',
35
        'COMODOJO_DATABASE_USER' => 'comodojo',
36
        'COMODOJO_DATABASE_PASS' => 'comodojo',
37
        'COMODOJO_DATABASE_PREFIX' => "cmdj_"
38
    );
39
    
40
    public function __construct( $parameters = array() ) {
41
        
42
        $this->set('COMODOJO_REAL_PATH', COMODOJO_INSTALLER_WORKING_DIRECTORY);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        $this->set('COMODOJO_STATIC_CONFIG', COMODOJO_INSTALLER_WORKING_DIRECTORY.'/'.COMODOJO_INSTALLER_STATIC_CONFIG);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $this->set('COMODOJO_LOCAL_CACHE', COMODOJO_INSTALLER_WORKING_DIRECTORY.'/'.COMODOJO_INSTALLER_LOCAL_CACHE);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $this->set('COMODOJO_LOCAL_LOGS', COMODOJO_INSTALLER_WORKING_DIRECTORY.'/'.COMODOJO_INSTALLER_LOCAL_LOGS);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
        $this->set('COMODOJO_LOCAL_DATABASE', COMODOJO_INSTALLER_WORKING_DIRECTORY.'/'.COMODOJO_INSTALLER_LOCAL_DATABASE);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $this->set('COMODOJO_APP_ASSETS', COMODOJO_INSTALLER_APP_ASSETS);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        $this->set('COMODOJO_THEME_ASSETS', COMODOJO_INSTALLER_THEME_ASSETS);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
        
50
        $this->set('COMODOJO_AUTH_KEY', self::generateKey());
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        $this->set('COMODOJO_PRIV_KEY', self::generateKey());
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
        
53
        
54
        foreach( $parameters as $parameter => $value ) {
55
            
56
            $this->set($parameter, $value);
0 ignored issues
show
The method set() does not seem to exist on object<Comodojo\Installe...ticConfigurationDumper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            
58
        }
59
        
60
    }
61
62
    public function __set($setting, $value) {
63
64
        $this->$settings[$setting] = $value;
0 ignored issues
show
The variable $settings does not exist. Did you mean $setting?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
65
66
        return $this;
67
68
    }
69
70
    public function __get($setting) {
71
72
        if (array_key_exists($setting, $this->$settings)) {
0 ignored issues
show
The variable $settings does not exist. Did you mean $setting?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
73
74
            return $this->$settings[$setting];
0 ignored issues
show
The variable $settings does not exist. Did you mean $setting?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
75
76
        }
77
78
        return null;
79
80
    }
81
82
    public function __isset($setting) {
83
84
        return isset($this->$settings[$setting]);
0 ignored issues
show
The variable $settings does not exist. Did you mean $setting?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
85
86
    }
87
88
    public function dump() {
89
90
        $config_file = COMODOJO_INSTALLER_WORKING_DIRECTORY.'/'.COMODOJO_INSTALLER_STATIC_CONFIG.'/'.comodojo-config.php;
91
92
        $template = $this->loadConfigurationTemplate();
93
94
        foreach ($this->settings as $setting => $value) {
95
96
            $template = str_replace('_'.$setting.'_', $value, $template);
97
98
        }
99
100
        $action = file_put_contents($config_file, $template, LOCK_EX);
101
102
        if ( $action === false ) throw new InstallerException("Cannot write comodojo-config file!");
103
104
        return true;
105
106
    }
107
108
    private function loadConfigurationTemplate() {
109
110
        $template_file = realpath(dirname(__FILE__)."/../../")."/comodojo-config.template";
111
112
        $template = file_get_contents($template_file);
113
114
        if ( $template === false ) throw new InstallerException("Cannot read comodojo-config template!");
115
116
        return $template;
117
118
    }
119
    
120
    private function generateKey() {
121
        
122
        return md5(uniqid(rand(), true), 0);
123
        
124
    }
125
    
126
    private function generateSalt() {
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
127
        
128
        return uniqid(mt_rand(), true);
129
        
130
    }
131
132
}
133