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/CommandArguments.php (2 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
namespace Robo\Common;
4
5
use Robo\Common\ProcessUtils;
6
7
/**
8
 * Use this to add arguments and options to the $arguments property.
9
 */
10
trait CommandArguments
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $arguments = '';
16
17
    /**
18
     * Pass argument to executable. Its value will be automatically escaped.
19
     *
20
     * @param string $arg
21
     *
22
     * @return $this
23
     */
24
    public function arg($arg)
25
    {
26
        return $this->args($arg);
27
    }
28
29
    /**
30
     * Pass methods parameters as arguments to executable. Argument values
31
     * are automatically escaped.
32
     *
33
     * @param string|string[] $args
34
     *
35
     * @return $this
36
     */
37
    public function args($args)
38
    {
39
        if (!is_array($args)) {
40
            $args = func_get_args();
41
        }
42
        $this->arguments .= ' ' . implode(' ', array_map('static::escape', $args));
43
        return $this;
44
    }
45
46
    /**
47
     * Pass the provided string in its raw (as provided) form as an argument to executable.
48
     *
49
     * @param string $arg
50
     *
51
     * @return $this
52
     */
53
    public function rawArg($arg)
54
    {
55
        $this->arguments .= " $arg";
56
57
        return $this;
58
    }
59
60
    /**
61
     * Escape the provided value, unless it contains only alphanumeric
62
     * plus a few other basic characters.
63
     *
64
     * @param string $value
65
     *
66
     * @return string
67
     */
68
    public static function escape($value)
69
    {
70
        if (preg_match('/^[a-zA-Z0-9\/\[email protected]~_-]+$/', $value)) {
71
            return $value;
72
        }
73
        return ProcessUtils::escapeArgument($value);
0 ignored issues
show
Deprecated Code introduced by Greg Anderson
The method Robo\Common\ProcessUtils::escapeArgument() has been deprecated with message: since version 3.3, to be removed in 4.0. Use a command line array or give env vars to the `Process::start/run()` method instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
74
    }
75
76
    /**
77
     * Pass option to executable. Options are prefixed with `--` , value can be provided in second parameter.
78
     * Option values are automatically escaped.
79
     *
80
     * @param string $option
81
     * @param string $value
82
     * @param string $separator
83
     *
84
     * @return $this
85
     */
86
    public function option($option, $value = null, $separator = ' ')
87
    {
88
        if ($option !== null and strpos($option, '-') !== 0) {
89
            $option = "--$option";
90
        }
91
        $this->arguments .= null == $option ? '' : " " . $option;
92
        $this->arguments .= null == $value ? '' : $separator . static::escape($value);
0 ignored issues
show
It seems like you are loosely comparing $value of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
93
        return $this;
94
    }
95
96
    /**
97
     * Pass multiple options to executable. The associative array contains
98
     * the key:value pairs that become `--key value`, for each item in the array.
99
     * Values are automatically escaped.
100
     *
101
     * @param array $options
102
     * @param string $separator
103
     *
104
     * @return $this
105
     */
106
    public function options(array $options, $separator = ' ')
107
    {
108
        foreach ($options as $option => $value) {
109
            $this->option($option, $value, $separator);
110
        }
111
        return $this;
112
    }
113
114
    /**
115
     * Pass an option with multiple values to executable. Value can be a string or array.
116
     * Option values are automatically escaped.
117
     *
118
     * @param string $option
119
     * @param string|array $value
120
     * @param string $separator
121
     *
122
     * @return $this
123
     */
124
    public function optionList($option, $value = array(), $separator = ' ')
125
    {
126
        if (is_array($value)) {
127
            foreach ($value as $item) {
128
                $this->optionList($option, $item, $separator);
129
            }
130
        } else {
131
            $this->option($option, $value, $separator);
132
        }
133
134
        return $this;
135
    }
136
}
137