Issues (4)

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.

src/Context/RawMultilingualContext.php (3 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
 * @author Toni Kolev, <[email protected]>
4
 */
5
namespace kolev\MultilingualExtension\Context;
6
use Behat\MinkExtension\Context\RawMinkContext;
7
8
/**
9
 * Class RawMultilingualContext.
10
 *
11
 * @package kolev\MultilingualExtension\Context
12
 */
13
class RawMultilingualContext extends RawMinkContext implements MultilingualContextInterface
14
{
15
16
    /**
17
     * Parameters of MultilingualExtension.
18
     *
19
     * @var array
20
     */
21
    public $multilingual_parameters = [];
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function setMultilingualParameters(array $parameters)
27
    {
28
        if (empty($this->multilingual_parameters)) {
29
            $this->multilingual_parameters = $parameters;
30
        }
31
    }
32
33
    /**
34
     * @param string $name
35
     *   The name of parameter from behat.yml.
36
     *
37
     * @return mixed
38
     */
39
    protected function getMultilingualParameter($name)
40
    {
41
        return isset($this->multilingual_parameters[$name]) ? $this->multilingual_parameters[$name] : false;
42
    }
43
44
    /**
45
     *  RAW definitions of simple functions to  be used in MultilingualContext
46
     */
47
48
    public function iClickOnTheText($text) {
49
50
        $session = $this->getSession();
51
        $element = $session->getPage()->find(
52
            'xpath',
53
            $session->getSelectorsHandler()->selectorToXpath('xpath', '//*[contains(text(),"' . $text . '")]'));
54
55
        if (null === $element) {
56
            throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
57
        }
58
59
        $element->click();
60
    }
61
62
    public function assertValueInInput($value, $input) {
63
64
        if (substr($input,0,1) != "#") {
65
            $input = "#" . $input;
66
        }
67
        $session = $this->getSession();
68
        $element = $session->getPage()->find('css', $input);
69
        if(isset($element)) {
70
            $text = $element->getValue();
71
        }
72
        else {
73
            throw new \Exception(sprintf("Element is null"));
74
        }
75
76
        if($text === $value) {
77
            return true;
78
        }
79
        else {
80
            throw new \Exception(sprintf('Value of input : "%s" does not match the text "%s"', $text, $value));
81
        }
82
    }
83
84
    public function iWaitForTextToAppearWithMaxTime($text, $maxExecutionTime) {
85
86
        $isTextFound = false;
87
88
        for ($i = 0; $i < $maxExecutionTime; $i++) {
89
            try {
90
                $this->iShouldSeeInTheSourceOfThePage($text);
91
                $isTextFound = true;
92
                break;
93
            }
94
            catch (\Exception $e) {
95
                sleep(1);
96
            }
97
        }
98
99
        if (!$isTextFound) {
100
            throw new \Exception("'$text' didn't appear on the page for $maxExecutionTime seconds");
101
        }
102
    }
103
104
    public function iShouldSeeInTheSourceOfThePage($text) {
105
106
        $html = $this->getSession()->getDriver()->getContent();
107
        $text = $this->validateTextForSearchInSource($text);
108
        $regex = '/' . $text . '/';
109
110
        preg_match($regex, $html, $results);
111
112
        if ($results == null) {
113
            throw new \Exception('The searched text ' . $text . ' was not found in the source of the page.');
114
        }
115
116
        return true;
117
    }
118
119
    public function validateTextForSearchInSource($text) {
120
121
        $text = preg_replace("/(\\.)/", '\\\\.', $text);
122
        $text = preg_replace("/(\/)/", '\\/', $text);
123
        $text = preg_replace("/(\\?)/", '\\\\\?', $text);
124
125
        return $text;
126
    }
127
128 View Code Duplication
    public function iClickOnTheTextInRegion($text, $region) {
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...
129
130
        $session = $this->getSession();
131
        $element = $session->getPage()->find('region', $region)->find('xpath', $session->getSelectorsHandler()->selectorToXpath('xpath',
132
            '//*[contains(text(),"' . $text . '")]'));
133
        if (null === $element) {
134
            throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
135
        }
136
137
        $element->click();
138
    }
139
140 View Code Duplication
    public function selectOptionWithJavascript($text, $region) {
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...
141
142
        $session = $this->getSession();
143
        $element = $session->getPage()->find('region', $region)->find('xpath', $session->getSelectorsHandler()->selectorToXpath('xpath',
144
            '//*[contains(text(),"' . $text . '")]'));
145
146
        if (null === $element) {
147
            throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
148
        }
149
150
        $element->click();
151
    }
152
153
    public function assertSelectRadioById($label, $id = '') {
154
        $element = $this->getSession()->getPage();
155
        $radiobutton = $id ? $element->findById($id) : $element->find('named', array('radio', $this->getSession()->getSelectorsHandler()->xpathLiteral($label)));
0 ignored issues
show
Deprecated Code introduced by
The method Behat\Mink\Selector\Sele...Handler::xpathLiteral() has been deprecated with message: since Mink 1.7. Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral when building Xpath or pass the unescaped value when using the named selector.

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...
156
        if ($radiobutton === NULL) {
157
            throw new \Exception(sprintf('The radio button with "%s" was not found on the page %s', $id ? $id : $label, $this->getSession()->getCurrentUrl()));
158
        }
159
        $value = $radiobutton->getAttribute('value');
160
        $labelonpage = $radiobutton->getParent()->getText();
161
        if ($label != $labelonpage) {
162
            throw new \Exception(sprintf("Button with id '%s' has label '%s' instead of '%s' on the page %s", $id, $labelonpage, $label, $this->getSession()->getCurrentUrl()));
163
        }
164
        $radiobutton->selectOption($value, FALSE);
165
    }
166
167
}
168