Issues (244)

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.

Sylius/Behat/Page/Admin/Promotion/CreatePage.php (2 issues)

Labels

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
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Behat\Page\Admin\Promotion;
15
16
use Behat\Mink\Element\NodeElement;
17
use Behat\Mink\Exception\ElementNotFoundException;
18
use Sylius\Behat\Behaviour\NamesIt;
19
use Sylius\Behat\Behaviour\SpecifiesItsCode;
20
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
21
use Sylius\Behat\Service\AutocompleteHelper;
22
use Webmozart\Assert\Assert;
23
24
class CreatePage extends BaseCreatePage implements CreatePageInterface
25
{
26
    use NamesIt;
27
    use SpecifiesItsCode;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function addRule($ruleName)
33
    {
34
        $count = count($this->getCollectionItems('rules'));
35
36
        $this->getDocument()->clickLink('Add rule');
37
38
        $this->getDocument()->waitFor(5, function () use ($count) {
39
            return $count + 1 === count($this->getCollectionItems('rules'));
40
        });
41
42
        $this->selectRuleOption('Type', $ruleName);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function selectRuleOption($option, $value, $multiple = false)
49
    {
50
        $this->getLastCollectionItem('rules')->find('named', ['select', $option])->selectOption($value, $multiple);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function selectAutocompleteRuleOption($option, $value, $multiple = false)
57
    {
58
        $option = strtolower(str_replace(' ', '_', $option));
59
60
        $ruleAutocomplete = $this
61
            ->getLastCollectionItem('rules')
62
            ->find('css', sprintf('input[type="hidden"][name*="[%s]"]', $option))
63
            ->getParent()
64
        ;
65
66
        if ($multiple && is_array($value)) {
67
            AutocompleteHelper::chooseValues($this->getSession(), $ruleAutocomplete, $value);
68
69
            return;
70
        }
71
72
        AutocompleteHelper::chooseValue($this->getSession(), $ruleAutocomplete, $value);
0 ignored issues
show
It seems like $value defined by parameter $value on line 56 can also be of type array<integer,string>; however, Sylius\Behat\Service\Aut...teHelper::chooseValue() does only seem to accept string, 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...
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function fillRuleOption($option, $value)
79
    {
80
        $this->getLastCollectionItem('rules')->fillField($option, $value);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function fillRuleOptionForChannel($channelName, $option, $value)
87
    {
88
        $lastAction = $this->getChannelConfigurationOfLastRule($channelName);
89
        $lastAction->fillField($option, $value);
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function addAction($actionName)
96
    {
97
        $count = count($this->getCollectionItems('actions'));
98
99
        $this->getDocument()->clickLink('Add action');
100
101
        $this->getDocument()->waitFor(5, function () use ($count) {
102
            return $count + 1 === count($this->getCollectionItems('actions'));
103
        });
104
105
        $this->selectActionOption('Type', $actionName);
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function selectActionOption($option, $value, $multiple = false)
112
    {
113
        $this->getLastCollectionItem('actions')->find('named', ['select', $option])->selectOption($value, $multiple);
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function fillActionOption($option, $value)
120
    {
121
        $this->getLastCollectionItem('actions')->fillField($option, $value);
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function fillActionOptionForChannel($channelName, $option, $value)
128
    {
129
        $lastAction = $this->getChannelConfigurationOfLastAction($channelName);
130
        $lastAction->fillField($option, $value);
131
    }
132
133
    /**
134
     * {@inheritdoc}
135
     */
136
    public function fillUsageLimit($limit)
137
    {
138
        $this->getDocument()->fillField('Usage limit', $limit);
139
    }
140
141
    public function makeExclusive()
142
    {
143
        $this->getDocument()->checkField('Exclusive');
144
    }
145
146
    public function checkCouponBased()
147
    {
148
        $this->getDocument()->checkField('Coupon based');
149
    }
150
151
    public function checkChannel($name)
152
    {
153
        $this->getDocument()->checkField($name);
154
    }
155
156
    /**
157
     * {@inheritdoc}
158
     */
159
    public function setStartsAt(\DateTimeInterface $dateTime)
160
    {
161
        $timestamp = $dateTime->getTimestamp();
162
163
        $this->getDocument()->fillField('sylius_promotion_startsAt_date', date('Y-m-d', $timestamp));
164
        $this->getDocument()->fillField('sylius_promotion_startsAt_time', date('H:i', $timestamp));
165
    }
166
167
    /**
168
     * {@inheritdoc}
169
     */
170
    public function setEndsAt(\DateTimeInterface $dateTime)
171
    {
172
        $timestamp = $dateTime->getTimestamp();
173
174
        $this->getDocument()->fillField('sylius_promotion_endsAt_date', date('Y-m-d', $timestamp));
175
        $this->getDocument()->fillField('sylius_promotion_endsAt_time', date('H:i', $timestamp));
176
    }
177
178
    /**
179
     * {@inheritdoc}
180
     */
181
    public function getValidationMessageForAction()
182
    {
183
        $actionForm = $this->getLastCollectionItem('actions');
184
185
        $foundElement = $actionForm->find('css', '.sylius-validation-error');
186
        if (null === $foundElement) {
187
            throw new ElementNotFoundException($this->getSession(), 'Tag', 'css', '.sylius-validation-error');
188
        }
189
190
        return $foundElement->getText();
191
    }
192
193
    /**
194
     * {@inheritdoc}
195
     */
196
    public function selectAutoCompleteFilterOption($option, $value, $multiple = false)
197
    {
198
        $option = strtolower(str_replace(' ', '_', $option));
199
200
        $filterAutocomplete = $this
201
            ->getLastCollectionItem('actions')
202
            ->find('css', sprintf('input[type="hidden"][name*="[%s_filter]"]', $option))
203
            ->getParent()
204
        ;
205
206
        if ($multiple && is_array($value)) {
207
            AutocompleteHelper::chooseValues($this->getSession(), $filterAutocomplete, $value);
208
209
            return;
210
        }
211
212
        AutocompleteHelper::chooseValue($this->getSession(), $filterAutocomplete, $value);
0 ignored issues
show
It seems like $value defined by parameter $value on line 196 can also be of type array<integer,string>; however, Sylius\Behat\Service\Aut...teHelper::chooseValue() does only seem to accept string, 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...
213
    }
214
215
    /**
216
     * {@inheritdoc}
217
     */
218
    protected function getDefinedElements()
219
    {
220
        return [
221
            'actions' => '#sylius_promotion_actions',
222
            'code' => '#sylius_promotion_code',
223
            'ends_at' => '#sylius_promotion_endsAt',
224
            'minimum' => '#sylius_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_min',
225
            'maximum' => '#sylius_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_max',
226
            'name' => '#sylius_promotion_name',
227
            'rules' => '#sylius_promotion_rules',
228
            'starts_at' => '#sylius_promotion_startsAt',
229
        ];
230
    }
231
232
    /**
233
     * @param string $channelName
234
     *
235
     * @return NodeElement
236
     */
237
    private function getChannelConfigurationOfLastAction($channelName)
238
    {
239
        return $this
240
            ->getLastCollectionItem('actions')
241
            ->find('css', sprintf('[id$="configuration"] .field:contains("%s")', $channelName))
242
        ;
243
    }
244
245
    /**
246
     * @param string $channelName
247
     *
248
     * @return NodeElement
249
     */
250
    private function getChannelConfigurationOfLastRule($channelName)
251
    {
252
        return $this
253
            ->getLastCollectionItem('rules')
254
            ->find('css', sprintf('[id$="configuration"] .field:contains("%s")', $channelName))
255
        ;
256
    }
257
258
    /**
259
     * @param string $collection
260
     *
261
     * @return NodeElement
262
     */
263
    private function getLastCollectionItem($collection)
264
    {
265
        $items = $this->getCollectionItems($collection);
266
267
        Assert::notEmpty($items);
268
269
        return end($items);
270
    }
271
272
    /**
273
     * @param string $collection
274
     *
275
     * @return NodeElement[]
276
     */
277
    private function getCollectionItems($collection)
278
    {
279
        $items = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
280
281
        Assert::isArray($items);
282
283
        return $items;
284
    }
285
}
286