Issues (31)

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.

EntityEmbedDisplay/EntityEmbedDisplayManager.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\entity_embed\EntityEmbedDisplay;
4
5
use Drupal\Core\Cache\CacheBackendInterface;
6
use Drupal\Core\Entity\EntityInterface;
7
use Drupal\Core\Extension\ModuleHandlerInterface;
8
use Drupal\Core\Plugin\DefaultPluginManager;
9
use Drupal\Component\Plugin\Exception\PluginException;
10
11
/**
12
 * Provides an Entity Embed display plugin manager.
13
 *
14
 * @see \Drupal\entity_embed\Annotation\EntityEmbedDisplay
15
 * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayBase
16
 * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayInterface
17
 * @see plugin_api
18
 */
19
class EntityEmbedDisplayManager extends DefaultPluginManager {
20
21
  /**
22
   * Constructs a new EntityEmbedDisplayManager.
23
   *
24
   * @param \Traversable $namespaces
25
   *   An object that implements \Traversable which contains the root paths
26
   *   keyed by the corresponding namespace to look for plugin implementations.
27
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
28
   *   Cache backend instance to use.
29
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
30
   *   The module handler to invoke the alter hook with.
31
   */
32
  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
33
    parent::__construct('Plugin/entity_embed/EntityEmbedDisplay', $namespaces, $module_handler, 'Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayInterface', 'Drupal\entity_embed\Annotation\EntityEmbedDisplay');
34
    $this->alterInfo('entity_embed_display_plugins');
35
    $this->setCacheBackend($cache_backend, 'entity_embed_display_plugins');
36
  }
37
38
  /**
39
   * Overrides DefaultPluginManager::processDefinition().
40
   */
41
  public function processDefinition(&$definition, $plugin_id) {
42
    $definition += array(
43
      'entity_types' => FALSE,
44
    );
45
46
    if ($definition['entity_types'] !== FALSE && !is_array($definition['entity_types'])) {
47
      $definition['entity_types'] = array($definition['entity_types']);
48
    }
49
  }
50
51
  /**
52
   * Determines plugins whose constraints are satisfied by a set of contexts.
53
   *
54
   * @param array $contexts
55
   *   An array of contexts.
56
   *
57
   * @return array
58
   *   An array of plugin definitions.
59
   *
60
   * @todo At some point convert this to use ContextAwarePluginManagerTrait
61
   *
62
   * @see https://drupal.org/node/2277981
63
   */
64
  public function getDefinitionsForContexts(array $contexts = array()) {
65
    $definitions = $this->getDefinitions();
66
    $valid_ids = array_filter(array_keys($definitions), function ($id) use ($contexts) {
67
      try {
68
        $display = $this->createInstance($id);
69
        foreach ($contexts as $name => $value) {
70
          $display->setContextValue($name, $value);
71
        }
72
        // We lose cacheability metadata at this point. We should refactor to
73
        // avoid this. @see https://www.drupal.org/node/2593379#comment-11368447
74
        return $display->access()->isAllowed();
75
      }
76
      catch (PluginException $e) {
0 ignored issues
show
The class Drupal\Component\Plugin\Exception\PluginException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
77
        return FALSE;
78
      }
79
    });
80
    $definitions_for_context = array_intersect_key($definitions, array_flip($valid_ids));
81
    $this->moduleHandler->alter('entity_embed_display_plugins_for_context', $definitions_for_context, $contexts);
82
    return $definitions_for_context;
83
  }
84
85
  /**
86
   * Gets definition options for entity.
87
   *
88
   * Provides a list of plugins that can be used for a certain entity and
89
   * filters out plugins that should be hidden in the UI.
90
   *
91
   * @param \Drupal\Core\Entity\EntityInterface $entity
92
   *   An entity object.
93
   *
94
   * @return array
95
   *   An array of valid plugin labels, keyed by plugin ID.
96
   */
97
  public function getDefinitionOptionsForEntity(EntityInterface $entity) {
98
    $definitions = $this->getDefinitionsForContexts(array('entity' => $entity, 'entity_type' => $entity->getEntityTypeId()));
99
    $definitions = $this->filterExposedDefinitions($definitions);
100
    return array_map(function ($definition) {
101
      return (string) $definition['label'];
102
    }, $definitions);
103
  }
104
105
  /**
106
   * Filters out plugins from definitions that should be hidden in the UI.
107
   *
108
   * @param array $definitions
109
   *   The array of plugin definitions.
110
   *
111
   * @return array
112
   *   Returns plugin definitions that should be displayed in the UI.
113
   */
114
  protected function filterExposedDefinitions(array $definitions) {
115
    return array_filter($definitions, function($definition) {
116
      return empty($definition['no_ui']);
117
    });
118
  }
119
120
  /**
121
   * Gets definition options for entity type.
122
   *
123
   * Provides a list of plugins that can be used for a certain entity type and
124
   * filters out plugins that should be hidden in the UI.
125
   *
126
   * @param string $entity_type
127
   *   The entity type id.
128
   *
129
   * @return array
130
   *   An array of valid plugin labels, keyed by plugin ID.
131
   */
132
  public function getDefinitionOptionsForEntityType($entity_type) {
133
    $definitions = $this->getDefinitionsForContexts(array('entity_type' => $entity_type));
134
    $definitions = $this->filterExposedDefinitions($definitions);
135
    return array_map(function ($definition) {
136
      return (string) $definition['label'];
137
    }, $definitions);
138
  }
139
140
}
141