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/Actions/Authentication.php (4 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\Actions;
2
3
use \Comodojo\Exception\InstallerException;
4
use \Exception;
5
6
/**
7
 *
8
 *
9
 * @package     Comodojo Framework
10
 * @author      Marco Giovinazzi <[email protected]>
11
 * @author      Marco Castiello <[email protected]>
12
 * @license     GPL-3.0+
13
 *
14
 * LICENSE:
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 */
29
30
class Authentication extends AbstractAction {
31
32 View Code Duplication
    public function install($package_name, $package_extra) {
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...
33
34
        $io = $this->getIO();
35
36
        $io->write("<info>>>> Installing authentication providers from ".$package_name."</info>");
37
38
        foreach ($package_extra as $provider => $configuration) {
39
40
            $this->addAuthProvider($io, $package_name, $provider, $configuration);
41
42
        }
43
44
    }
45
46 View Code Duplication
    public function update($package_name, $initial_extra, $target_extra) {
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...
47
48
        $io = $this->getIO();
49
50
        $io->write("<info>>>> Updating authentication providers from ".$package_name."</info>");
51
52
        $old_providers = array_keys($initial_extra);
53
        
54
        $new_providers = array_keys($target_extra);
55
        
56
        $uninstall = array_diff($old_providers, $new_providers);
57
58
        $install = array_diff($new_providers, $old_providers);
59
60
        $update = array_intersect($old_providers, $new_providers);
61
        
62
        foreach ( $uninstall as $provider ) {
63
            
64
            $this->removeAuthProvider($io, $package_name, $provider, $initial_extra[$provider]);
65
            
66
        }
67
        
68
        foreach ( $install as $provider ) {
69
            
70
            $this->addAuthProvider($io, $package_name, $provider, $target_extra[$provider]);
71
            
72
        }
73
        
74
        foreach ( $update as $provider ) {
75
            
76
            $this->updateAuthProvider($io, $package_name, $provider, $target_extra[$provider]);
77
            
78
        }
79
80
    }
81
82 View Code Duplication
    public function uninstall($package_name, $package_extra) {
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...
83
84
        $io = $this->getIO();
85
86
        $io->write("<info>>>> Removing authentication providers from ".$package_name."</info>");
87
88
        foreach ($package_extra as $provider => $configuration) {
89
90
            $this->removeAuthProvider($io, $package_name, $provider, $configuration);
91
92
        }
93
94
    }
95
    
96
    private function addAuthProvider($io, $package_name, $provider, $configuration) {
97
        
98
        try {
99
100
            if ( !self::validateProvider($configuration) ) throw new InstallerException('Skipping invalid authentication provider '.$provider.' in '.$package_name);
101
102
            $class = $configuration['class'];
103
            
104
            $description = empty($configuration['description']) ? null : $configuration['description'];
105
            
106
            $this->getPackageInstaller()->authentication()->add($package_name, $provider, $class, $description);
107
108
            $io->write(" <info>+</info> added authentication provider ".$provider);
109
110
        } catch (Exception $e) {
111
112
            $io->write('<error>Error processing authentication provider: '.$e->getMessage().'</error>');
113
114
        }
115
        
116
    }
117
    
118 View Code Duplication
    private function removeAuthProvider($io, $package_name, $provider, $configuration) {
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...
119
        
120
        try {
121
122
            if ( !self::validateProvider($configuration) ) throw new InstallerException('Skipping invalid authentication provider '.$provider.' in '.$package_name);
123
            
124
            $id = $this->getPackageInstaller()->authentication()->getByName($provider)->getId();
125
126
            $this->getPackageInstaller()->authentication()->delete($id);
127
128
            $io->write(" <comment>-</comment> removed authentication provider ".$provider);
129
130
        } catch (Exception $e) {
131
132
            $io->write('<error>Error processing authentication provider: '.$e->getMessage().'</error>');
133
134
        }
135
        
136
    }
137
    
138
    private function updateAuthProvider($io, $package_name, $provider, $configuration) {
139
        
140
        try {
141
142
            if ( !self::validateProvider($configuration) ) throw new InstallerException('Skipping invalid authentication provider '.$provider.' in '.$package_name);
143
144
            $class = $configuration['class'];
145
            
146
            $description = empty($configuration['description']) ? null : $configuration['description'];
147
148
            $id = $this->getPackageInstaller()->authentication()->getByName($provider)->getId();
149
            
150
            $this->getPackageInstaller()->authentication()->update($id, $package_name, $provider, $class, $description);
151
152
            $io->write(" <comment>~</comment> updated authentication provider ".$provider);
153
154
        } catch (Exception $e) {
155
156
            $io->write('<error>Error processing authentication provider: '.$e->getMessage().'</error>');
157
158
        }
159
        
160
    }
161
    
162
    private static function validateProvider($auth) {
163
164
        return !( empty($auth["class"]) );
165
166
    }
167
168
}
169