Issues (11)

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/Access/EmbedButtonEditorAccessCheck.php (1 issue)

Labels
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 Drupal\embed\Access;
4
5
use Drupal\Core\Access\AccessResult;
6
use Drupal\Core\Routing\RouteMatchInterface;
7
use Drupal\Core\Routing\Access\AccessInterface;
8
use Drupal\Core\Session\AccountInterface;
9
use Drupal\editor\EditorInterface;
10
use Drupal\embed\EmbedButtonInterface;
11
use Symfony\Component\HttpKernel\Exception\HttpException;
12
13
class EmbedButtonEditorAccessCheck implements AccessInterface {
14
15
  /**
16
   * Checks whether the embed button is enabled for the given text editor.
17
   *
18
   * Returns allowed if the editor toolbar contains the embed button or neutral
19
   * otherwise.
20
   *
21
   * @code
22
   * pattern: '/foo/{editor}/{embed_button}'
23
   * requirements:
24
   *   _embed_button_filter_access: 'TRUE'
25
   * @endcode
26
   *
27
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
28
   *   The current route match.
29
   * @param \Drupal\Core\Session\AccountInterface $account
30
   *   The currently logged in account.
31
   *
32
   * @return \Drupal\Core\Access\AccessResultInterface
33
   *   The access result.
34
   */
35
  public function access(RouteMatchInterface $route_match, AccountInterface $account) {
36
    $parameters = $route_match->getParameters();
37
38
    $access_result = AccessResult::allowedIf($parameters->has('editor') && $parameters->has('embed_button'))
39
      // Vary by 'route' because the access result depends on the 'editor' and
40
      // 'embed_button' route parameters.
41
      ->addCacheContexts(['route']);
42
43
    if ($access_result->isAllowed()) {
44
      $editor = $parameters->get('editor');
45
      $embed_button = $parameters->get('embed_button');
46
      if ($editor instanceof EditorInterface && $embed_button instanceof EmbedButtonInterface) {
0 ignored issues
show
The class Drupal\editor\EditorInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
47
        return $access_result
48
          // Besides having the 'editor' route parameter, it's also necessary to
49
          // be allowed to use the text format associated with the text editor.
50
          ->andIf($editor->getFilterFormat()->access('use', $account, TRUE))
51
          // And on top of that, the 'embed_button' needs to be present in the
52
          // text editor's configured toolbar.
53
          ->andIf($this->checkButtonEditorAccess($embed_button, $editor));
54
      }
55
    }
56
57
    // No opinion, so other access checks should decide if access should be
58
    // allowed or not.
59
    return $access_result;
60
  }
61
62
  /**
63
   * Checks if the embed button is enabled in an editor configuration.
64
   *
65
   * @param \Drupal\embed\EmbedButtonInterface $embed_button
66
   *   The embed button entity to check.
67
   * @param \Drupal\editor\EditorInterface $editor
68
   *   The editor entity to check.
69
   *
70
   * @return \Drupal\Core\Access\AccessResultInterface
71
   *   The access result.
72
   *
73
   * @throws \Symfony\Component\HttpKernel\Exception\HttpException
74
   *   When the received Text Editor entity does not use CKEditor. This is
75
   *   currently only capable of detecting buttons used by CKEditor.
76
   */
77
  protected function checkButtonEditorAccess(EmbedButtonInterface $embed_button, EditorInterface $editor) {
78
    if ($editor->getEditor() !== 'ckeditor') {
79
      throw new HttpException(500, 'Currently, only CKEditor is supported.');
80
    }
81
82
    $has_button = FALSE;
83
    $settings = $editor->getSettings();
84
    foreach ($settings['toolbar']['rows'] as $row) {
85
      foreach ($row as $group) {
86
        if (in_array($embed_button->id(), $group['items'])) {
87
          $has_button = TRUE;
88
          break 2;
89
        }
90
      }
91
    }
92
93
    return AccessResult::allowedIf($has_button)
94
      ->addCacheableDependency($embed_button)
95
      ->addCacheableDependency($editor);
96
  }
97
98
}
99