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/Testing/Behat.php (5 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\Task\Testing;
4
5
use Robo\Contract\CommandInterface;
6
use Robo\Contract\PrintedInterface;
7
use Robo\Task\BaseTask;
8
9
/**
10
 * Executes Behat tests
11
 *
12
 * ``` php
13
 * <?php
14
 * $this->taskBehat()
15
 *      ->format('pretty')
16
 *      ->noInteraction()
17
 *      ->run();
18
 * ?>
19
 * ```
20
 *
21
 */
22
class Behat extends BaseTask implements CommandInterface, PrintedInterface
23
{
24
    use \Robo\Common\ExecOneCommand;
25
26
    /**
27
     * @var string
28
     */
29
    protected $command;
30
31
    /**
32
     * @var string[] $formaters available formaters for format option
33
     */
34
    protected $formaters = ['progress', 'pretty', 'junit'];
35
36
    /**
37
     * @var string[] $verbose_levels available verbose levels
38
     */
39
    protected $verbose_levels = ['v', 'vv'];
40
41
    /**
42
     * Behat constructor.
43
     *
44
     * @param null|string $pathToBehat
45
     *
46
     * @throws \Robo\Exception\TaskException
47
     */
48 View Code Duplication
    public function __construct($pathToBehat = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $this->command = $pathToBehat;
51
        if (!$this->command) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->command of type null|string is loosely compared to false; 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...
52
            $this->command = $this->findExecutable('behat');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->findExecutable('behat') can also be of type false. However, the property $command is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
53
        }
54
        if (!$this->command) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->command of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false 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...
55
            throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Behat found");
56
        }
57
    }
58
59
    /**
60
     * @return $this
61
     */
62
    public function stopOnFail()
63
    {
64
        $this->option('stop-on-failure');
65
        return $this;
66
    }
67
68
    /**
69
     * @return $this
70
     */
71
    public function noInteraction()
72
    {
73
        $this->option('no-interaction');
74
        return $this;
75
    }
76
77
    /**
78
     * @param string $config_file
79
     *
80
     * @return $this
81
     */
82
    public function config($config_file)
83
    {
84
        $this->option('config', $config_file);
85
        return $this;
86
    }
87
88
    /**
89
     * @return $this
90
     */
91
    public function colors()
92
    {
93
        $this->option('colors');
94
        return $this;
95
    }
96
97
    /**
98
     * @return $this
99
     */
100
    public function noColors()
101
    {
102
        $this->option('no-colors');
103
        return $this;
104
    }
105
106
    /**
107
     * @param string $suite
108
     *
109
     * @return $this
110
     */
111
    public function suite($suite)
112
    {
113
        $this->option('suite', $suite);
114
        return $this;
115
    }
116
117
    /**
118
     * @param string $level
119
     *
120
     * @return $this
121
     */
122 View Code Duplication
    public function verbose($level = 'v')
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
    {
124
        if (!in_array($level, $this->verbose_levels)) {
125
            throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels));
126
        }
127
        $this->option('-' . $level);
128
        return $this;
129
    }
130
131
    /**
132
     * @param string $formater
133
     *
134
     * @return $this
135
     */
136 View Code Duplication
    public function format($formater)
137
    {
138
        if (!in_array($formater, $this->formaters)) {
139
            throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters));
140
        }
141
        $this->option('format', $formater);
142
        return $this;
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function getCommand()
149
    {
150
        return $this->command . $this->arguments;
151
    }
152
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public function run()
157
    {
158
        $this->printTaskInfo('Running behat {arguments}', ['arguments' => $this->arguments]);
159
        return $this->executeCommand($this->getCommand());
160
    }
161
}
162