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.

Context/ServiceContainerContext.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 NuvoleWeb\Drupal\DrupalExtension\Context;
4
5
use Behat\Gherkin\Node\TableNode;
6
use Drupal\Core\Site\Settings;
7
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
8
use function bovigo\assert\assert;
9
use function bovigo\assert\predicate\equals;
10
use function bovigo\assert\predicate\not;
11
12
/**
13
 * Contains Contacts specific step definitions.
14
 */
15
class ServiceContainerContext extends RawDrupalContext {
16
17
  /**
18
   * Override service parameters.
19
   *
20
   * @see BehatServiceProvider
21
   *
22
   * @Given I override the following service parameters:
23
   */
24
  public function assertOverrideParameters(TableNode $table) {
25
    $this->overrideParameters($table->getRowsHash());
26
  }
27
28
  /**
29
   * Rebuild container on after scenario.
30
   *
31
   * @AfterScenario
32
   */
33
  public function resetParameters() {
34
    if (\Drupal::state()->get('nuvole_web.drupal_extension.parameter_overrides')) {
35
      \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', []);
36
      \Drupal::service('kernel')->rebuildContainer();
37
    }
38
  }
39
40
  /**
41
   * Assert given service parameter has given value.
42
   *
43
   * @Then the service parameter :name should be set to :expected
44
   */
45
  public function assertParameters($name, $expected) {
46
    $value = \Drupal::getContainer()->getParameter($name);
47
    assert($value, equals($this->castParameter($expected)));
48
  }
49
50
  /**
51
   * Assert given service parameter has not given value.
52
   *
53
   * @Then the service parameter :name should not be set to :expected
54
   */
55
  public function negateParameters($name, $expected) {
56
    try {
57
      $value = \Drupal::getContainer()->getParameter($name);
58
      assert($value, not(equals($this->castParameter($expected))));
59
    }
60
    catch (ParameterNotFoundException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
61
    }
62
  }
63
64
  /**
65
   * Apply parameters overrides and rebuild container.
66
   *
67
   * @param array $parameters
68
   *    List of parameters to be overridden.
69
   */
70
  protected function overrideParameters(array $parameters) {
71
    $this->setServiceProvider();
72
73
    // Cast service parameters.
74
    foreach ($parameters as $name => $value) {
75
      $parameters[$name] = $this->castParameter($value);
76
    }
77
78
    \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', $parameters);
79
    \Drupal::service('kernel')->rebuildContainer();
80
  }
81
82
  /**
83
   * Set custom service provider ar run-time.
84
   */
85
  protected function setServiceProvider() {
86
    // Setting service providers will change in Drupal 8.5.
87
    // @link https://www.drupal.org/node/2183323
88
    if (\Drupal::VERSION < '8.5') {
89
      $GLOBALS['conf']['container_service_providers']['BehatServiceProvider'] = '\NuvoleWeb\Drupal\DrupalExtension\ServiceProvider\BehatServiceProvider';
90
    }
91
    else {
92
      $settings = Settings::getAll();
93
      $settings['container_service_providers']['BehatServiceProvider'] = '\NuvoleWeb\Drupal\DrupalExtension\ServiceProvider\BehatServiceProvider';
94
      new Settings($settings);
95
    }
96
  }
97
98
  /**
99
   * Cast service parameters.
100
   *
101
   * @param string $value
102
   *    Parameter value.
103
   *
104
   * @return mixed
105
   *    Casted value.
106
   */
107
  protected function castParameter($value) {
108
    if ($value == 'TRUE' || $value == 'true') {
109
      return TRUE;
110
    }
111
    elseif ($value == 'FALSE' || $value == 'false') {
112
      return FALSE;
113
    }
114
    else {
115
      return $value;
116
    }
117
  }
118
119
}
120