Issues (35)

Security Analysis    no request data  

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.

features/bootstrap/FeatureContext.php (15 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use Behat\Behat\Context\ClosuredContextInterface,
4
    Behat\Behat\Context\TranslatedContextInterface,
5
    Behat\Behat\Context\BehatContext,
6
    Behat\Behat\Exception\PendingException;
7
use Behat\Gherkin\Node\PyStringNode,
8
    Behat\Gherkin\Node\TableNode;
9
10
require __DIR__ . "/../../vendor/autoload.php";
11
12
//
13
// Require 3rd-party libraries here:
14
//
15
//   require_once 'PHPUnit/Autoload.php';
16
//   require_once 'PHPUnit/Framework/Assert/Functions.php';
17
//
18
19
use ETNA\Silex\Provider\RabbitMQ\RabbitMQServiceProvider;
20
use Silex\Application;
21
22
/**
23
 * Features context.
24
 */
25
class FeatureContext extends BehatContext
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
26
{
27
    /**
28
     * Initializes context.
29
     * Every scenario gets its own context object.
30
     *
31
     * @param array $parameters context parameters (set them up through behat.yml)
32
     */
33
    public function __construct(array $parameters)
0 ignored issues
show
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        // Initialize your context here
36
    }
37
38
    static private $vhosts = ["/test-behat", "/test-behat-named"];
0 ignored issues
show
The property $vhosts is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
39
40
    use ETNA\FeatureContext\RabbitMQ;
41
42
    /**
43
     * @Given /^une application Silex$/
44
     */
45
    public function uneApplicationSilex()
46
    {
47
        $this->app = new Application();
0 ignored issues
show
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
48
        $this->app->register(new RabbitMQServiceProvider());
49
    }
50
51
    /**
52
     * @Given /^la configuration suivante :$/
53
     */
54
    public function laConfigurationSuivante(PyStringNode $config)
55
    {
56
        $config = json_decode($config->getRaw(), true);
57
        if (!$config && json_last_error()) {
58
            throw new PendingException("Invalid JSON");
59
        }
60
        foreach ($config as $key => $value) {
61
            $this->app[$key] = $value;
62
        }
63
    }
64
65
    /**
66
     * @Given /^\$app\["amqp\.chan"\] == \$app\["amqp\.chans"\]\["default"\]$/
67
     */
68
    public function chanEstUnAliasVersDefault()
69
    {
70
        if ($this->app["amqp.chan"] !== $this->app["amqp.chans"]["default"]) {
71
            throw new Exception('$app["amqp.chan"] != $app["amqp.chans"]["default"]');
72
        }
73
    }
74
75
    /**
76
     * @Given /^\$app\["amqp\.(\w+)"\]\["(\w+)"\] est du type ([\w\\]+)$/
77
     */
78
    public function checkClass($type, $name, $class)
79
    {
80
        if (!is_a($this->app["amqp.{$type}"][$name], $class)) {
81
            throw new Exception("\$app['amqp.{$type}']['{$name}'] n'est pas une instance de {$class}");
82
        }
83
    }
84
85
    /**
86
     * @Given /^\$app\["amqp\.(\w+)"\]\["(\w+)"\]->(\w+)\(\) == "([^"]*)"$/
87
     */
88 View Code Duplication
    public function checkGetterString($type, $name, $method, $value)
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...
89
    {
90
        if ($this->app["amqp.{$type}"][$name]->$method() != $value) {
91
            $value = $this->app["amqp.{$type}"][$name]->$method();
92
            throw new Exception("\$app['amqp.{$type}'['{$name}']]->{$method}() = " . var_export($value, true));
93
        }
94
    }
95
96
    /**
97
     * @Given /^\$app\["amqp\.(\w+)"\]\["(\w+)"\]->(\w+)\(\) == (true|false)$/
98
     */
99 View Code Duplication
    public function checkGetterBoolean($type, $name, $method, $value)
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...
100
    {
101
        if ($this->app["amqp.{$type}"][$name]->$method() != (strtolower($value) == "true")) {
102
            $value = $this->app["amqp.{$type}"][$name]->$method();
103
            throw new Exception("\$app['amqp.{$type}'['{$name}']]->{$method}() = " . var_export($value, true));
104
        }
105
    }
106
107
    /**
108
     * @Given /^que je bind une file sur l\'exchange "([^"]*)"$/
109
     */
110
    public function queJeBindUneFileSurLExchange($exchange)
111
    {
112
        $this->channel = $this->app["amqp.exchanges"][$exchange]->getChannel();
0 ignored issues
show
The property channel does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
113
        $this->tmp_queue = $this->channel->queue_declare()[0];
0 ignored issues
show
The property tmp_queue does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
114
        $this->channel->queue_bind($this->tmp_queue, $exchange);
115
    }
116
117
     /**
118
     * @Given /^que "([^"]*)" est (un exchange|une queue) réservé$/
119
     */
120
    public function queEstUnTrucReserve($name, $type)
121
    {
122
        try {
123
            $type = $type == 'un exchange' ? "amqp.exchanges" : "amqp.queues";
124
            $this->app[$type][$name]->getChannel();
125
        } catch (Exception $e) {
126
            $this->exception = $e->getMessage();
0 ignored issues
show
The property exception does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
127
        }
128
    }
129
130
    /**
131
     * @Given /^je devrais avoir une exception "([^"]*)"$/
132
     */
133
    public function jeDevraisAvoirUneException($exception)
134
    {
135
        if ($exception != $this->exception) {
136
            throw new Exception("Expected: '{$exception}'; got: '{$this->exception}'");
137
        }
138
    }
139
140
    /**
141
     * @Given /^j\'envoie un message "(\w+)" dans l\'exchange "(\w+)"$/
142
     */
143
    public function jEnvoieUnMessage($message, $exchange)
144
    {
145
        $this->app["amqp.exchanges"][$exchange]->send($message);
146
    }
147
148
    /**
149
     * @Given /^j\'envoie un message "(\w+)" dans la file "([^"]*)"$/
150
     */
151
    public function jEnvoieUnMessageDansLaFile($message, $queue)
152
    {
153
        $this->channel = $this->app["amqp.queues"][$queue]->getChannel();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
154
        $this->tmp_queue = $queue;
155
        $this->app["amqp.queues"][$queue]->send($message);
156
    }
157
158
    /**
159
     * @Given /^il doit y avoir un message "([^"]*)" dans la file( "(\w+)")?$/
160
     */
161
    public function ilDoitYAvoirUnMessageDansLaFile($message, $queue = null)
0 ignored issues
show
The parameter $queue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
162
    {
163
        $this->channel->basic_consume($this->tmp_queue, "behat", false, false, false, false, function ($msg) use ($message) {
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
164
            $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
165
166
            if (json_decode($msg->body) != $message) {
167
                throw new Exception("{$msg->body} != {$message}");
168
            }
169
        });
170
        $this->channel->wait();
171
    }
172
173
    /**
174
     * @Given /^je fais un listen ma callback doit ĂȘtre appelĂ© (\d+) fois$/
175
     */
176
    public function jeFaisUnListen($nb)
177
    {
178
        $this->app["amqp.queues"][$this->tmp_queue]->send("__QUIT__");
179
        $nb++;
180
181
        $count = 0;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
182
        $last_message = null;
183
        $this->app["amqp.queues"][$this->tmp_queue]->listen(function ($msg) use ($count, &$last_message) {
184
            $count++;
185
            $last_message = json_decode($msg->body);
186
        });
187
        while ($nb--) {
188
            $this->channel->wait();
189
        }
190
        if ($last_message != "__QUIT__") {
191
            throw new Exception("Il y a trop de message");
192
        }
193
    }
194
}
195