Issues (1704)

Branch: master

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.

Tests/Features/Context/FeatureContext.php (21 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 Victoire\Tests\Features\Context;
4
5
use Behat\Behat\Context\Context;
6
use Behat\Behat\Context\SnippetAcceptingContext;
7
use Behat\Behat\Hook\Scope\AfterStepScope;
8
use Behat\Mink\Driver\Selenium2Driver;
9
use Behat\Mink\Element\Element;
10
use Behat\Mink\Exception\UnsupportedDriverActionException;
11
use Behat\Symfony2Extension\Context\KernelAwareContext;
12
use Behat\Symfony2Extension\Context\KernelDictionary;
13
use Behat\Symfony2Extension\Driver\KernelDriver;
14
use Knp\FriendlyContexts\Context\RawMinkContext;
15
16
/**
17
 * Feature context.
18
 */
19
class FeatureContext extends RawMinkContext implements Context, SnippetAcceptingContext, KernelAwareContext
0 ignored issues
show
Deprecated Code introduced by
The interface Behat\Behat\Context\SnippetAcceptingContext has been deprecated with message: will be removed in 4.0. Use --snippets-for CLI option instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

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

Loading history...
20
{
21
    use KernelDictionary;
22
23
    /**
0 ignored issues
show
Doc comment for parameter "$nbr" missing
Loading history...
24
     * @Given /^I wait (\d+) second$/
25
     * @Given /^I wait (\d+) seconds$/
26
     */
27
    public function iWaitSeconds($nbr)
28
    {
29
        $this->getSession()->wait($nbr * 1000);
30
    }
31
32
    public function getSymfonyProfile()
0 ignored issues
show
Missing function doc comment
Loading history...
33
    {
34
        $driver = $this->getSession()->getDriver();
35
        if (!$driver instanceof KernelDriver) {
36
            throw new UnsupportedDriverActionException(
37
                'You need to tag the scenario with '.
0 ignored issues
show
Concat operator must not be surrounded by spaces
Loading history...
38
                '"@mink:symfony2". Using the profiler is not '.
0 ignored issues
show
Concat operator must not be surrounded by spaces
Loading history...
39
                'supported by %s', $driver
40
            );
41
        }
42
43
        $profile = $driver->getClient()->getProfile();
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Symfony\Component\BrowserKit\Client as the method getProfile() does only exist in the following sub-classes of Symfony\Component\BrowserKit\Client: Symfony\Bundle\FrameworkBundle\Client. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
44
        if (false === $profile) {
45
            throw new \RuntimeException(
46
                'The profiler is disabled. Activate it by setting '.
0 ignored issues
show
Concat operator must not be surrounded by spaces
Loading history...
47
                'framework.profiler.only_exceptions to false in '.
0 ignored issues
show
Concat operator must not be surrounded by spaces
Loading history...
48
                'your config'
49
            );
50
        }
51
52
        return $profile;
53
    }
54
55
    /**
0 ignored issues
show
Doc comment for parameter "$elementId" missing
Loading history...
56
     * @Then /^I should see the css property "(.+)" of "(.+)" with "(.+)"$/
57
     *
58
     * @param string $property
59
     * @param string $value
0 ignored issues
show
Doc comment for parameter $value does not match actual variable name $elementId
Loading history...
60
     */
61
    public function iShouldSeeCssOfWith($property, $elementId, $value)
62
    {
63
        $script = "return $('#".$elementId."').css('".$property."') === '".$value."';";
64
        $evaluated = $this->getSession()->evaluateScript($script);
65
        if (!$evaluated) {
66
            throw new \RuntimeException('The element with id "'.$elementId.'" and css property "'.$property.': '.$value.';" not found.');
67
        }
68
    }
69
70
    /**
0 ignored issues
show
Doc comment for parameter "$id" missing
Loading history...
Doc comment for parameter "$url" missing
Loading history...
71
     * @Then I should see background-image of :id with relative url :url
72
     */
73
    public function iShouldSeeBackgroundImageWithRelativeUrl($id, $url)
74
    {
75
        $session = $this->getSession();
76
        $base_url = $session->getCurrentUrl();
0 ignored issues
show
Variable "base_url" is not in valid camel caps format
Loading history...
77
        $parse_url = parse_url($base_url);
0 ignored issues
show
Variable "parse_url" is not in valid camel caps format
Loading history...
Variable "base_url" is not in valid camel caps format
Loading history...
78
        $base_url = rtrim($base_url, $parse_url['path']);
0 ignored issues
show
Variable "base_url" is not in valid camel caps format
Loading history...
Variable "parse_url" is not in valid camel caps format
Loading history...
79
        $url = rtrim($base_url, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($url, DIRECTORY_SEPARATOR);
0 ignored issues
show
Variable "base_url" is not in valid camel caps format
Loading history...
80
        $this->iShouldSeeCssOfWith('background-image', $id, 'url("'.$url.'")');
81
    }
82
83
    /**
0 ignored issues
show
Doc comment for parameter "$title" missing
Loading history...
84
     * @Then the title should be :title
85
     */
86
    public function theTitleShouldBe($title)
87
    {
88
        $element = $this->getSession()->getPage()->find(
89
            'xpath',
90
            sprintf('//title[normalize-space(text()) = "%s"]', $title)
91
        );
92
93
        if (null === $element) {
94
            $message = sprintf('"%s" is not the title of the page', $title);
95
            throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession());
96
        }
97
    }
98
99
    /**
0 ignored issues
show
Doc comment for parameter "$event" missing
Loading history...
100
     * @AfterStep
101
     */
102
    public function printLastResponseOnError(AfterStepScope $event)
103
    {
104
        if (!$event->getTestResult()->isPassed()) {
105
            $this->saveDebugScreenshot();
106
        }
107
    }
108
109
    /**
110
     * @Then /^save screenshot$/
111
     */
112
    public function saveDebugScreenshot()
113
    {
114
        $driver = $this->getSession()->getDriver();
115
116
        if (!$driver instanceof Selenium2Driver) {
117
            return;
118
        }
119
120
        if (!getenv('BEHAT_SCREENSHOTS')) {
121
            return;
122
        }
123
124
        $filename = microtime(true).'.png';
125
        $path = $this->getContainer()
126
                ->getParameter('kernel.root_dir').'/../behat_screenshots';
127
128
        if (!file_exists($path)) {
129
            mkdir($path);
130
        }
131
132
        $this->saveScreenshot($filename, $path);
0 ignored issues
show
The method saveScreenshot() does not seem to exist on object<Victoire\Tests\Fe...Context\FeatureContext>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
    }
134
}
135