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/Deploy.php (3 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
namespace samsonphp\deploy;
3
4
use samson\core\Service;
5
use samsonphp\event\Event;
6
7
/**
8
 * SamsonPHP deployment service
9
 *
10
 * @package samsonphp\deploy
11
 * @author Vitaly Iegorov <[email protected]>
12
 */
13
class Deploy extends Service
14
{
15
    /** Идентификатор модуля */
16
    protected $id = 'deploy';
17
18
    /** @var Remote */
19
    public $remote;
20
21
    /** @var array Collection of path names to be ignored */
22
    public $ignorePath = array('cms');
23
24
    /** Path to site document root on local server */
25
    public $sourceroot = '';
26
27
    /** FTP host */
28
    public $host 	= '';
0 ignored issues
show
Spaces must be used for alignment; tabs are not allowed
Loading history...
29
30
    /** Path to site document root on remote server */
31
    public $wwwroot	= '';
0 ignored issues
show
Spaces must be used for alignment; tabs are not allowed
Loading history...
32
33
    /** FTP username */
34
    public $username= '';
35
36
    /** FTP password */
37
    public $password= '';
38
39
    /**
40
     * Get all entries in $path
41
     * @param string $path Folder path for listing
42
     * @return array Collection of entries int folder
43
     */
44
    protected function directoryFiles($path)
45
    {
46
        $result = array();
47
        // Get all entries in path
48
        foreach (array_diff(scandir($path), array_merge($this->ignorePath, array('..', '.'))) as $entry) {
49
            // Build full REAL path to entry
50
            $result[$entry] = realpath($path . '/' . $entry);
51
        }
52
        return $result;
53
    }
54
55
    /**
56
     * Perform synchronizing folder via FTP connection
57
     * @param string 	$path       Local path for synchronizing
0 ignored issues
show
Spaces must be used for alignment; tabs are not allowed
Loading history...
58
     */
59
    protected function synchronize($path)
60
    {
61
        $this->remote->log('Synchronizing remote folder [##]', $path);
62
63
        // Check if we can read this path
64
        foreach ($this->directoryFiles($path) as $fileName => $fullPath) {
65
            // If this is a folder
66
            if (is_dir($fullPath)) {
67
                // Try to create it
68
                $this->remote->mkDir($fileName);
69
                // Go deeper in recursion
70
                $this->synchronize($fullPath);
71
            } elseif ($this->remote->isOld($fullPath)) { // Check if file has to be updated
72
                // Copy file to remote
73
                $this->remote->write($fullPath);
74
            }
75
        }
76
77
        // Go one level up
78
        $this->remote->cdup();
79
    }
80
81
    /**
82
     * Initialize module
83
     * @param array $params
84
     * @return bool
85
     */
86
    public function init(array $params = array())
87
    {
88
        // Check configuration
89
        if (!isset($this->sourceroot{0})) {
90
            return $this->error('Local project folder['.$this->sourceroot.'] is not specified');
91
        }
92
93
        // Check configuration
94
        if (!isset($this->wwwroot{0})) {
95
            return $this->error('Remote project folder['.$this->wwwroot.'] is not specified');
96
        }
97
98
        return parent::init($params);
99
    }
100
101
    /**
102
     * Signal module error
103
     * @param string $message error message
104
     * @return bool false
105
     */
106
    public function error($message)
107
    {
108
        // Signal error
109
        Event::fire('error', array($this, $message));
110
111
        return false;
112
    }
113
114
    /**
115
     * Perform project deployment
116
     */
117
    protected function deploy()
118
    {
119
        // If this is remote app - chdir to it
120
        if (__SAMSON_REMOTE_APP) {
121
            // Create folder
122
            $this->remote->mkDir(str_replace('/', '', __SAMSON_BASE__));
123
        }
124
125
        // Выполним синхронизацию папок
126
        $this->synchronize($this->sourceroot);
127
    }
128
129
    /** Controller to perform deploy routine */
130
    public function __BASE()
131
    {
132
        $this->title('Deploying project to '.$this->host);
133
134
        // If no remote class name is set
135
        if (!isset($this->remote)) {
136
            // Create remote connection instance
137
            $this->remote = new Remote($this->host, $this->username, $this->password);
138
        }
139
140
        // Go to project remote folder
141
        if (empty($this->wwwroot) || $this->remote->cd($this->wwwroot)) {
142
143
            $this->deploy();
144
145
            $this->remote->log('Project[##] has been successfully deployed to [##]', $this->sourceroot, $this->host);
146
        }
147
    }
148
}
149