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/Common/ExecCommand.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\Common;
4
5
use Robo\Result;
6
use Symfony\Component\Process\ExecutableFinder;
7
use Symfony\Component\Process\Process;
8
9
/**
10
 * This task is supposed to be executed as shell command.
11
 * You can specify working directory and if output is printed.
12
 */
13
trait ExecCommand
14
{
15
    use ExecTrait;
16
17
    /**
18
     * @var \Robo\Common\TimeKeeper
19
     */
20
    protected $execTimer;
21
22
    /**
23
     * @return \Robo\Common\TimeKeeper
24
     */
25
    protected function getExecTimer()
26
    {
27
        if (!isset($this->execTimer)) {
28
            $this->execTimer = new TimeKeeper();
29
        }
30
        return $this->execTimer;
31
    }
32
33
    /**
34
     * Look for a "{$cmd}.phar" in the current working
35
     * directory; return a string to exec it if it is
36
     * found.  Otherwise, look for an executable command
37
     * of the same name via findExecutable.
38
     *
39
     * @param string $cmd
40
     *
41
     * @return bool|string
42
     */
43
    protected function findExecutablePhar($cmd)
44
    {
45
        if (file_exists("{$cmd}.phar")) {
46
            return "php {$cmd}.phar";
47
        }
48
        return $this->findExecutable($cmd);
49
    }
50
51
    /**
52
     * Return the best path to the executable program
53
     * with the provided name.  Favor vendor/bin in the
54
     * current project. If not found there, use
55
     * whatever is on the $PATH.
56
     *
57
     * @param string $cmd
58
     *
59
     * @return bool|string
60
     */
61
    protected function findExecutable($cmd)
62
    {
63
        $pathToCmd = $this->searchForExecutable($cmd);
64
        if ($pathToCmd) {
0 ignored issues
show
Bug Best Practice introduced by Greg Anderson
The expression $pathToCmd of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
65
            return $this->useCallOnWindows($pathToCmd);
66
        }
67
        return false;
68
    }
69
70
    /**
71
     * @param string $cmd
72
     *
73
     * @return string
74
     */
75
    private function searchForExecutable($cmd)
76
    {
77
        $projectBin = $this->findProjectBin();
78
79
        $localComposerInstallation = $projectBin . DIRECTORY_SEPARATOR . $cmd;
80
        if (file_exists($localComposerInstallation)) {
81
            return $localComposerInstallation;
82
        }
83
        $finder = new ExecutableFinder();
84
        return $finder->find($cmd, null, []);
85
    }
86
87
    /**
88
     * @return bool|string
89
     */
90
    protected function findProjectBin()
91
    {
92
        $cwd = getcwd();
93
        $candidates = [ __DIR__ . '/../../vendor/bin', __DIR__ . '/../../bin', $cwd . '/vendor/bin' ];
94
95
        // If this project is inside a vendor directory, give highest priority
96
        // to that directory.
97
        $vendorDirContainingUs = realpath(__DIR__ . '/../../../..');
98
        if (is_dir($vendorDirContainingUs) && (basename($vendorDirContainingUs) == 'vendor')) {
99
            array_unshift($candidates, $vendorDirContainingUs . '/bin');
100
        }
101
102
        foreach ($candidates as $dir) {
103
            if (is_dir("$dir")) {
104
                return realpath($dir);
105
            }
106
        }
107
        return false;
108
    }
109
110
    /**
111
     * Wrap Windows executables in 'call' per 7a88757d
112
     *
113
     * @param string $cmd
114
     *
115
     * @return string
116
     */
117
    protected function useCallOnWindows($cmd)
118
    {
119
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
120
            if (file_exists("{$cmd}.bat")) {
121
                $cmd = "{$cmd}.bat";
122
            }
123
            return "call $cmd";
124
        }
125
        return $cmd;
126
    }
127
128
    /**
129
     * {@inheritdoc}
130
     */
131
    protected function getCommandDescription()
132
    {
133
        return $this->process->getCommandLine();
134
    }
135
136
    /**
137
     * @param string $command
138
     *
139
     * @return \Robo\Result
140
     */
141
    protected function executeCommand($command)
142
    {
143
        // TODO: Symfony 4 requires that we supply the working directory.
144
        $result_data = $this->execute(Process::fromShellCommandline($command, getcwd()));
145
        return new Result(
146
            $this,
147
            $result_data->getExitCode(),
148
            $result_data->getMessage(),
149
            $result_data->getData()
150
        );
151
    }
152
}
153