Issues (1)

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.

Tester/ErrorTester.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 RMiller\BehatSpec\Extension\ErrorExtension\Tester;
4
5
use Behat\Behat\Tester\Result\ExecutedStepResult;
6
use Behat\Behat\Tester\Result\StepResult;
7
use Behat\Behat\Tester\StepTester;
8
use Behat\Gherkin\Node\FeatureNode;
9
use Behat\Gherkin\Node\StepNode;
10
use Behat\Testwork\Call\Exception\FatalThrowableError;
11
use Behat\Testwork\Environment\Environment;
12
use Behat\Testwork\Tester\Setup\Setup;
13
use Behat\Testwork\Tester\Setup\Teardown;
14
use RMiller\BehatSpec\Extension\ErrorExtension\Observer\ErrorObservers;
15
use Symfony\Component\Console\Helper\FormatterHelper;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class ErrorTester implements StepTester
19
{
20
    private $baseTester;
21
    private $observers;
22
    private $output;
23
24
    public function __construct(
25
        StepTester $baseTester,
26
        OutputInterface $output,
27
        array $observers = null
28
    ) {
29
        $this->baseTester = $baseTester;
30
        $this->output = $output;
31
        $this->observers = new ErrorObservers($observers);
0 ignored issues
show
It seems like $observers defined by parameter $observers on line 27 can also be of type null; however, RMiller\BehatSpec\Extens...bservers::__construct() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
32
    }
33
34
    /**
35
     * Sets up suite for a test.
36
     *
37
     * @param Environment $env
38
     * @param FeatureNode $feature
39
     * @param StepNode $step
40
     * @param bool $skip
41
     *
42
     * @return Setup
43
     */
44
    public function setUp(
45
        Environment $env,
46
        FeatureNode $feature,
47
        StepNode $step,
48
        $skip
49
    ) {
50
        return $this->baseTester->setUp($env, $feature, $step, $skip);
51
    }
52
53
    /**
54
     * Tests provided suite specifications.
55
     *
56
     * @param Environment $env
57
     * @param FeatureNode $feature
58
     * @param StepNode $step
59
     * @param bool $skip
60
     *
61
     * @return StepResult
62
     */
63
    public function test(
64
        Environment $env,
65
        FeatureNode $feature,
66
        StepNode $step,
67
        $skip = false
68
    ) {
69
        $result = $this->baseTester->test($env, $feature, $step, $skip);
70
71
        if ($result instanceof ExecutedStepResult && $result->hasException()) {
72
            $exception = $result->getException();
73
74
            if ($exception instanceof FatalThrowableError) {
75
                $errorMessages = [
76
                    sprintf('The error "%s"', $exception->getMessage()),
77
                    sprintf('occurred in step %s', $step->getText()),
78
                    sprintf('at line %s', $step->getLine()),
79
                ];
80
81
                $formatter = new FormatterHelper();
82
                $formattedBlock = $formatter->formatBlock($errorMessages,
83
                    'error', true);
84
                $this->output->writeln('');
85
                $this->output->writeln($formattedBlock);
86
                $this->output->writeln('');
87
88
                foreach ($this->observers as $observer) {
89
                    $observer->notify($exception);
90
                }
91
            }
92
        }
93
94
        return $result;
95
    }
96
97
    /**
98
     * Tears down suite after a test.
99
     *
100
     * @param Environment $env
101
     * @param FeatureNode $feature
102
     * @param StepNode $step
103
     * @param bool $skip
104
     * @param StepResult $result
105
     *
106
     * @return Teardown
107
     */
108
    public function tearDown(
109
        Environment $env,
110
        FeatureNode $feature,
111
        StepNode $step,
112
        $skip,
113
        StepResult $result
114
    ) {
115
        return $this->baseTester->tearDown($env, $feature, $step, $skip,
116
            $result);
117
    }
118
}
119