Issues (569)

Security Analysis    not enabled

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/Task/Filesystem/FilesystemStack.php (1 issue)

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 Robo\Task\Filesystem;
4
5
use Robo\Task\StackBasedTask;
6
use Symfony\Component\Filesystem\Filesystem as sfFilesystem;
7
use Symfony\Component\Filesystem\Exception\IOException;
8
use Robo\Contract\BuilderAwareInterface;
9
use Robo\Common\BuilderAwareTrait;
10
11
/**
12
 * Wrapper for [Symfony Filesystem](http://symfony.com/doc/current/components/filesystem.html) Component.
13
 * Comands are executed in stack and can be stopped on first fail with `stopOnFail` option.
14
 *
15
 * ``` php
16
 * <?php
17
 * $this->taskFilesystemStack()
18
 *      ->mkdir('logs')
19
 *      ->touch('logs/.gitignore')
20
 *      ->chgrp('www', 'www-data')
21
 *      ->symlink('/var/log/nginx/error.log', 'logs/error.log')
22
 *      ->run();
23
 *
24
 * // one line
25
 * $this->_touch('.gitignore');
26
 * $this->_mkdir('logs');
27
 *
28
 * ?>
29
 * ```
30
 *
31
 * @method $this mkdir(string|array|\Traversable $dir, int $mode = 0777)
32
 * @method $this touch(string|array|\Traversable $file, int $time = null, int $atime = null)
33
 * @method $this copy(string $from, string $to, bool $force = false)
34
 * @method $this chmod(string|array|\Traversable $file, int $permissions, int $umask = 0000, bool $recursive = false)
35
 * @method $this chgrp(string|array|\Traversable $file, string $group, bool $recursive = false)
36
 * @method $this chown(string|array|\Traversable $file, string $user, bool $recursive = false)
37
 * @method $this remove(string|array|\Traversable $file)
38
 * @method $this rename(string $from, string $to, bool $force = false)
39
 * @method $this symlink(string $from, string $to, bool $copyOnWindows = false)
40
 * @method $this mirror(string $from, string $to, \Traversable $iterator = null, array $options = [])
41
 */
42
class FilesystemStack extends StackBasedTask implements BuilderAwareInterface
43
{
44
    use BuilderAwareTrait;
45
46
    /**
47
     * @var \Symfony\Component\Filesystem\Filesystem
48
     */
49
    protected $fs;
50
51
    public function __construct()
52
    {
53
        $this->fs = new sfFilesystem();
54
    }
55
56
    /**
57
     * @return \Symfony\Component\Filesystem\Filesystem
58
     */
59
    protected function getDelegate()
60
    {
61
        return $this->fs;
62
    }
63
64
    /**
65
     * @param string $from
66
     * @param string $to
67
     * @param bool $force
68
     */
69
    protected function _copy($from, $to, $force = false)
70
    {
71
        $this->fs->copy($from, $to, $force);
72
    }
73
74
    /**
75
     * @param string|string[]|\Traversable $file
76
     * @param int $permissions
77
     * @param int $umask
78
     * @param bool $recursive
79
     */
80
    protected function _chmod($file, $permissions, $umask = 0000, $recursive = false)
81
    {
82
        $this->fs->chmod($file, $permissions, $umask, $recursive);
83
    }
84
85
    /**
86
     * @param string|string[]|\Traversable $file
87
     * @param string $group
88
     * @param bool $recursive
89
     */
90
    protected function _chgrp($file, $group, $recursive = null)
91
    {
92
        $this->fs->chgrp($file, $group, $recursive);
93
    }
94
95
    /**
96
     * @param string|string[]|\Traversable $file
97
     * @param string $user
98
     * @param bool $recursive
99
     */
100
    protected function _chown($file, $user, $recursive = null)
101
    {
102
        $this->fs->chown($file, $user, $recursive);
103
    }
104
105
    /**
106
     * @param string $origin
107
     * @param string $target
108
     * @param bool $overwrite
109
     *
110
     * @return null|true|\Robo\Result
111
     */
112
    protected function _rename($origin, $target, $overwrite = false)
113
    {
114
        // we check that target does not exist
115
        if ((!$overwrite && is_readable($target)) || (file_exists($target) && !is_writable($target))) {
116
            throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
117
        }
118
119
        // Due to a bug (limitation) in PHP, cross-volume renames do not work.
120
        // See: https://bugs.php.net/bug.php?id=54097
121
        if (true !== @rename($origin, $target)) {
122
            return $this->crossVolumeRename($origin, $target);
123
        }
124
        return true;
125
    }
126
127
    /**
128
     * @param string $origin
129
     * @param string $target
130
     *
131
     * @return null|\Robo\Result
132
     */
133
    protected function crossVolumeRename($origin, $target)
134
    {
135
        // First step is to try to get rid of the target. If there
136
        // is a single, deletable file, then we will just unlink it.
137
        if (is_file($target)) {
138
            unlink($target);
139
        }
140
        // If the target still exists, we will try to delete it.
141
        // TODO: Note that if this fails partway through, then we cannot
142
        // adequately rollback.  Perhaps we need to preflight the operation
143
        // and determine if everything inside of $target is writable.
144
        if (file_exists($target)) {
145
            $this->fs->remove($target);
146
        }
147
148
        /** @var \Robo\Result $result */
149
        $result = $this->collectionBuilder()->taskCopyDir([$origin => $target])->run();
0 ignored issues
show
Documentation Bug introduced by
The method taskCopyDir does not exist on object<Robo\Collection\CollectionBuilder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
150
        if (!$result->wasSuccessful()) {
151
            return $result;
152
        }
153
        $this->fs->remove($origin);
154
    }
155
}
156