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/Base/Exec.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\Base;
4
5
use Robo\Common\ExecTrait;
6
use Robo\Contract\CommandInterface;
7
use Robo\Contract\PrintedInterface;
8
use Robo\Contract\SimulatedInterface;
9
use Robo\Task\BaseTask;
10
use Symfony\Component\Process\Process;
11
use Robo\Result;
12
13
/**
14
 * Executes shell script. Closes it when running in background mode.
15
 *
16
 * ``` php
17
 * <?php
18
 * $this->taskExec('compass')->arg('watch')->run();
19
 * // or use shortcut
20
 * $this->_exec('compass watch');
21
 *
22
 * $this->taskExec('compass watch')->background()->run();
23
 *
24
 * if ($this->taskExec('phpunit .')->run()->wasSuccessful()) {
25
 *  $this->say('tests passed');
26
 * }
27
 *
28
 * ?>
29
 * ```
30
 */
31
class Exec extends BaseTask implements CommandInterface, PrintedInterface, SimulatedInterface
32
{
33
    use \Robo\Common\CommandReceiver;
34
    use \Robo\Common\ExecOneCommand;
35
36
    /**
37
     * @var static[]
38
     */
39
    protected static $instances = [];
40
41
    /**
42
     * @var string|\Robo\Contract\CommandInterface
43
     */
44
    protected $command;
45
46
    /**
47
     * @param string|\Robo\Contract\CommandInterface $command
48
     */
49
    public function __construct($command)
50
    {
51
        $this->command = $this->receiveCommand($command);
52
    }
53
54
    public function __destruct()
55
    {
56
        $this->stop();
57
    }
58
59
    /**
60
     * Executes command in background mode (asynchronously)
61
     *
62
     * @param bool $arg
63
     *
64
     * @return $this
65
     */
66
    public function background($arg = true)
67
    {
68
        self::$instances[] = $this;
69
        $this->background = $arg;
70
        return $this;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    protected function getCommandDescription()
77
    {
78
        return $this->getCommand();
79
    }
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function getCommand()
84
    {
85
        return trim($this->command . $this->arguments);
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function simulate($context)
92
    {
93
        $this->printAction($context);
94
    }
95
96
    public static function stopRunningJobs()
97
    {
98
        foreach (self::$instances as $instance) {
99
            if ($instance) {
100
                unset($instance);
101
            }
102
        }
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function run()
109
    {
110
        $this->hideProgressIndicator();
111
        // TODO: Symfony 4 requires that we supply the working directory.
112
        $result_data = $this->execute(Process::fromShellCommandline($this->getCommand(), getcwd()));
113
        return new Result(
114
            $this,
115
            $result_data->getExitCode(),
116
            $result_data->getMessage(),
117
            $result_data->getData()
118
        );
119
        $this->showProgressIndicator();
0 ignored issues
show
$this->showProgressIndicator(); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
120
    }
121
}
122
123
if (function_exists('pcntl_signal')) {
124
    pcntl_signal(SIGTERM, ['Robo\Task\Base\Exec', 'stopRunningJobs']);
125
}
126
127
register_shutdown_function(['Robo\Task\Base\Exec', 'stopRunningJobs']);
128