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.

tests/integration/FilesystemStackTest.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
2
namespace Robo;
3
4
use PHPUnit\Framework\TestCase;
5
use Robo\Traits\TestTasksTrait;
6
7
class FilesystemStackTest extends TestCase
8
{
9
    use TestTasksTrait;
10
    use Collection\loadTasks;
11
    use Task\Filesystem\loadTasks;
12
13
    protected $fixtures;
14
15
    public function setUp()
16
    {
17
        $this->fixtures = new Fixtures();
18
        $this->initTestTasksTrait();
19
        $this->fixtures->createAndCdToSandbox();
20
    }
21
22
    public function tearDown()
23
    {
24
        $this->fixtures->cleanup();
25
    }
26
27 View Code Duplication
    public function testDirAndFileCreation()
28
    {
29
        // Set up a collection to add tasks to
30
        $collection = $this->collectionBuilder();
31
32
        // Set up a filesystem stack
33
        $collection->taskFilesystemStack()
0 ignored issues
show
Documentation Bug introduced by
The method taskFilesystemStack 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...
34
            ->mkdir('simulatedir')
35
            ->touch('simulatedir/error.txt');
36
37
        $this->assertFileNotExists('simulatedir/error.txt');
38
39
        // Run the task collection; the files should be present afterwards
40
        $result = $collection->run();
41
        $this->assertTrue($result->wasSuccessful(), $result->getMessage());
42
        $this->assertFileExists('simulatedir/error.txt');
43
    }
44
45
    public function testCreateDir()
46
    {
47
        $this->assertFileNotExists('log/error.txt');
48
        $result = $this->taskFilesystemStack()
0 ignored issues
show
The method mkdir does only exist in Robo\Task\Filesystem\FilesystemStack, but not in Robo\Collection\CollectionBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
49
            ->mkdir('log')
50
            ->touch('log/error.txt')
51
            ->run();
52
        $this->assertTrue($result->wasSuccessful(), $result->getMessage());
53
        $this->assertFileExists('log/error.txt');
54
    }
55
56
    public function testDeleteFile()
57
    {
58
        $this->assertFileExists('a.txt');
59
        $result = $this->taskFilesystemStack()
0 ignored issues
show
The method stopOnFail does only exist in Robo\Task\Filesystem\FilesystemStack, but not in Robo\Collection\CollectionBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
60
            ->stopOnFail()
61
            ->remove('a.txt')
62
            ->run();
63
        $this->assertTrue($result->wasSuccessful(), $result->getMessage());
64
        $this->assertFileNotExists('a.txt');
65
    }
66
67
    public function testCrossVolumeRename()
68
    {
69
        $fsStack = $this->taskFilesystemStack()
0 ignored issues
show
The method mkdir does only exist in Robo\Task\Filesystem\FilesystemStack, but not in Robo\Collection\CollectionBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
70
            ->mkdir('log')
71
            ->touch('log/error.txt');
72
        $result = $fsStack->run();
73
        $this->assertTrue($result->wasSuccessful(), $result->getMessage());
74
75
        // We can't force _rename to run the cross-volume
76
        // code path, so we will directly call the protected
77
        // method crossVolumeRename to test to ensure it works.
78
        // We will get a reference to it via reflection, set
79
        // the reflected method object to public, and then
80
        // call it via reflection.
81
        $class = new \ReflectionClass('\Robo\Task\Filesystem\FilesystemStack');
82
        $method = $class->getMethod('crossVolumeRename');
83
        $method->setAccessible(true);
84
        $actualFsStackTask = $fsStack->getCollectionBuilderCurrentTask();
85
        $method->invokeArgs($actualFsStackTask, ['log', 'logfiles']);
86
87
        $this->assertFileNotExists('log/error.txt');
88
        $this->assertFileExists('logfiles/error.txt');
89
    }
90
91
}
92