Issues (6)

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/Base/Sync.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
3
/**
4
 * AppserverIo\RoboTasks\Base\Sync
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/robo-tasks
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\RoboTasks\Base;
22
23
use Lurker\Resource\FileResource;
24
use Lurker\Event\FilesystemEvent;
25
use Robo\Common\BuilderAwareTrait;
26
use Robo\Contract\BuilderAwareInterface;
27
28
/**
29
 * A task that provides directory synchronization functionality.
30
 *
31
 * ```php
32
 * <?php
33
 * $this->taskSync()->src('src')->dest('dest')->run();
34
 * ?>
35
 * ```
36
 *
37
 * @author    Tim Wagner <[email protected]>
38
 * @copyright 2015 TechDivision GmbH <[email protected]>
39
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
40
 * @link      https://github.com/appserver-io/robo-tasks
41
 * @link      http://www.appserver.io
42
 */
43
class Sync extends Watch implements BuilderAwareInterface
44
{
45
46
    /**
47
     * The builder to internally create tasks.
48
     *
49
     * @var \Robo\Common\BuilderAwareTrait
50
     */
51
    use BuilderAwareTrait;
52
53
    /**
54
     * The source directory.
55
     *
56
     * @var array
57
     */
58
    protected $src;
59
60
    /**
61
     * The target directory.
62
     *
63
     * @var array
64
     */
65
    protected $dest;
66
67
    /**
68
     * Set the source directory.
69
     *
70
     * @param string $src The source directory
71
     *
72
     * @return \AppserverIo\RoboTasks\Base\Sync The task instance
73
     */
74
    public function src($src)
75
    {
76
        $this->src = $src;
0 ignored issues
show
Documentation Bug introduced by
It seems like $src of type string is incompatible with the declared type array of property $src.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
77
        return $this;
78
    }
79
80
    /**
81
     * Set the destination directory.
82
     *
83
     * @param string $dest The destination directory
84
     *
85
     * @return \AppserverIo\RoboTasks\Base\Sync The task instance
86
     */
87
    public function dest($dest)
88
    {
89
        $this->dest = $dest;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dest of type string is incompatible with the declared type array of property $dest.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
90
        return $this;
91
    }
92
93
    /**
94
     * Provides the main synchronize functionality.
95
     *
96
     * @param FilesystemEvent $event The event that has to be processed
97
     *
98
     * @return void
99
     * @throws \Exception Is thrown, if a non supported event type will be passed
100
     */
101
    public function sync(FilesystemEvent $event)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
102
    {
103
104
        // load the resource that changed
105
        $filename = $event->getResource();
106
107
        // prepare the destination filename
108
        $targetFilename = $this->prepareDestFilename($filename);
109
110
        // query whether or not it is a file
111
        if ($filename instanceof FileResource) {
112
            // query whether or not the file has to be copied or deleted
113
            switch ($event->getType()) {
114
                case $event->getType() === FilesystemEvent::DELETE:
115
                    // remove the target file
116
                    $this->collectionBuilder()->taskFilesystemStack()->remove($targetFilename)->run();
117
                    break;
118
119
                case $event->getType() === FilesystemEvent::CREATE:
120
                case $event->getType() === FilesystemEvent::MODIFY:
121
                    // if yes, copy it ot the target directory
122
                    $this->collectionBuilder()->taskFilesystemStack()->copy($filename, $targetFilename)->run();
123
                    break;
124
125
                default:
126
                    throw new \Exception(
127
                        sprintf('Found invalid event type %s', $event->getTypeString())
128
                    );
129
            }
130
        }
131
    }
132
133
    /**
134
     * Invokes the task and its functionality.
135
     *
136
     * @return \Robo\Result The tasks result
137
     * @see \Robo\Contract\TaskInterface::run()
138
     */
139
    public function run()
140
    {
141
142
        // add the monitor
143
        $this->monitor($this->src, array($this, 'sync'));
144
145
        // start synchronizing the directories
146
        return parent::run();
147
    }
148
149
    /**
150
     * Prepare and return the destination filename.
151
     *
152
     * @param string $filename The relative/absolute pathname of the file
153
     *
154
     * @return string The prepared destination filename
155
     */
156
    protected function prepareDestFilename($filename)
157
    {
158
        return sprintf(
159
            '%s%s',
160
            realpath($this->dest),
161
            str_replace(realpath($this->src), '', $filename)
162
        );
163
    }
164
}
165