Issues (67)

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.

src/DrupalExtension/Context/ChosenFieldContext.php (1 issue)

Severity

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 NuvoleWeb\Drupal\DrupalExtension\Context;
4
5
use Behat\Gherkin\Node\TableNode;
6
use Behat\Mink\Exception\ExpectationException;
7
8
/**
9
 * Class ChosenFieldContext.
10
 *
11
 * @package NuvoleWeb\Drupal\DrupalExtension\Context
12
 */
13
class ChosenFieldContext extends RawMinkContext {
14
15
  /**
16
   * Fills in chosen form fields with provided table.
17
   *
18
   * @When /^(?:|I )fill in the following chosen fields:$/
19
   */
20
  public function fillChosenFields(TableNode $fields) {
21
    foreach ($fields->getRowsHash() as $field => $value) {
22
      $this->iSetChosenElement($field, $value);
23
    }
24
  }
25
26
  /**
27
   * Fills in chosen form fields with provided table.
28
   *
29
   * @When /^(?:|I )unset the following chosen fields:$/
30
   */
31
  public function unsetChosenFields(TableNode $fields) {
32
    foreach ($fields->getRowsHash() as $field => $value) {
33
      $this->iUnSetChosenElement($value, $field);
34
    }
35
  }
36
37
  /**
38
   * Select one more option from a Chosen select box.
39
   *
40
   * @When /^I add "([^"]*)" to the chosen element "([^"]*)"$/
41
   * @When /^I select "([^"]*)" on the Chosen element "([^"]*)"$/
42
   */
43
  public function iAddChosenElement($value, $locator) {
44
    $this->iSetChosenElement($locator, $value);
45
  }
46
47
  /**
48
   * This is from a patch which is very much work-in-progress.
49
   *
50
   * @link https://www.drupal.org/node/2562805.
51
   *
52
   * @When /^I set the chosen element "([^"]*)" to "([^"]*)"$/
53
   */
54
  public function iSetChosenElement($locator, $value) {
55
    $session = $this->getSession();
56
    $el = $session->getPage()->findField($locator);
57
58
    if (empty($el)) {
59
      throw new ExpectationException('No such select element ' . $locator, $session);
60
    }
61
62
    $element_id = str_replace('-', '_', $el->getAttribute('id')) . '_chosen';
63
64
    $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']");
65
66
    if ($el->hasClass('chosen-container-single')) {
67
      // This is a single select element.
68
      $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/a[@class='chosen-single']");
69
      $el->click();
70
    }
71
    elseif ($el->hasClass('chosen-container-multi')) {
72
      // This is a multi select element.
73
      $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/ul[@class='chosen-choices']/li[@class='search-field']/input");
74
      $el->click();
75
    }
76
77
    $selector = "//div[@id='{$element_id}']/div[@class='chosen-drop']/ul[@class='chosen-results']/li[text() = '{$value}']";
78
    $el = $session->getPage()->find('xpath', $selector);
79
80
    if (empty($el)) {
81
      throw new ExpectationException('No such option ' . $value . ' in ' . $locator, $session);
82
    }
83
84
    $el->click();
85
  }
86
87
  /**
88
   * Remove an option from a Chosen select box.
89
   *
90
   * @When /^I remove "([^"]*)" from the chosen element "([^"]*)"$/
91
   * @When I remove :arg1 from the Chosen element :arg2
92
   */
93
  public function iUnSetChosenElement($value, $locator) {
94
    $session = $this->getSession();
95
    $el = $session->getPage()->findField($locator);
96
97
    if (empty($el)) {
98
      throw new ExpectationException('No such select element ' . $locator, $session);
99
    }
100
101
    $element_id = str_replace('-', '_', $el->getAttribute('id')) . '_chosen';
102
103
    $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']");
104
    if ($el->hasClass('chosen-container-single')) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
105
      // This is a single select element, unsetting doesn't make sense.
106
    }
107
108
    $selector = "//div[@id='{$element_id}']/ul[@class='chosen-choices']//li[span = '{$value}']/a";
109
    $el = $session->getPage()->find('xpath', $selector);
110
111
    if (empty($el)) {
112
      throw new ExpectationException('No such option ' . $value . ' selected in ' . $locator, $session);
113
    }
114
115
    $el->click();
116
  }
117
118
}
119