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.

entity_embed.api.php (12 issues)

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
 * @file
5
 * Hooks provided by the Entity Embed module.
6
 */
7
8
/**
9
 * @addtogroup hooks
10
 * @{
11
 */
12
13
/**
14
 * Alter the Entity Embed Display plugin definitions.
15
 *
16
 * @param array &$info
17
 *   An associative array containing the plugin definitions keyed by plugin ID.
18
 */
19
function hook_entity_embed_display_plugins_alter(array &$info) {
0 ignored issues
show
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
21
}
22
23
/**
24
 * Alter the Entity Embed Display plugin definitions for a given context.
25
 *
26
 * Usually used to remove certain Entity Embed Display plugins for specific
27
 * entities.
28
 *
29
 * @param array &$definitions
30
 *   Remove options from this list if they should not be available for the given
31
 *   context.
32
 * @param array $contexts
33
 *   The provided context, typically an entity.
34
 */
35
function hook_entity_embed_display_plugins_for_context_alter(array &$definitions, array $contexts) {
36
  // Do nothing if no entity is provided.
37
  if (!isset($contexts['entity'])) {
38
    return;
39
  }
40
  $entity = $contexts['entity'];
41
42
  // For video and audio files, limit the available options to the media player.
43 View Code Duplication
  if ($entity instanceof \Drupal\file\FileInterface && in_array($entity->bundle(), ['audio', 'video'])) {
0 ignored issues
show
The class Drupal\file\FileInterface 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...
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    $definitions = array_intersect_key($definitions, array_flip(['file:jwplayer_formatter']));
45
  }
46
47
  // For images, use the image formatter.
48 View Code Duplication
  if ($entity instanceof \Drupal\file\FileInterface && in_array($entity->bundle(), ['image'])) {
0 ignored issues
show
The class Drupal\file\FileInterface 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...
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    $definitions = array_intersect_key($definitions, array_flip(['image:image']));
50
  }
51
52
  // For nodes, use the default option.
53
  if ($entity instanceof \Drupal\node\NodeInterface) {
0 ignored issues
show
The class Drupal\node\NodeInterface 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...
54
    $definitions = array_intersect_key($definitions, array_flip(['entity_reference:entity_reference_entity_view']));
55
  }
56
}
57
58
/**
59
 * Alter the context of an embedded entity before it is rendered.
60
 *
61
 * @param array &$context
62
 *   The context array.
63
 * @param \Drupal\Core\Entity\EntityInterface $entity
64
 *   The entity object.
65
 */
66 View Code Duplication
function hook_entity_embed_context_alter(array &$context, \Drupal\Core\Entity\EntityInterface $entity) {
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
  if (isset($context['overrides']) && is_array($context['overrides'])) {
68
    foreach ($context['overrides'] as $key => $value) {
69
      $entity->key = $value;
70
    }
71
  }
72
}
73
74
/**
75
 * Alter the context of an particular embedded entity type before it is rendered.
76
 *
77
 * @param array &$context
78
 *   The context array.
79
 * @param \Drupal\Core\Entity\EntityInterface $entity
80
 *   The entity object.
81
 */
82 View Code Duplication
function hook_ENTITY_TYPE_embed_context_alter(array &$context, \Drupal\Core\Entity\EntityInterface $entity) {
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
  if (isset($context['overrides']) && is_array($context['overrides'])) {
84
    foreach ($context['overrides'] as $key => $value) {
85
      $entity->key = $value;
86
    }
87
  }
88
}
89
90
/**
91
 * Alter the results of an embedded entity build array.
92
 *
93
 * This hook is called after the content has been assembled in a structured
94
 * array and may be used for doing processing which requires that the complete
95
 * block content structure has been built.
96
 *
97
 * @param array &$build
98
 *   A renderable array representing the embedded entity content.
99
 * @param \Drupal\Core\Entity\EntityInterface $entity
100
 *   The embedded entity object.
101
 * @param array $context
102
 *   The context array.
103
 */
104
function hook_entity_embed_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, array &$context) {
0 ignored issues
show
The parameter $entity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
105
  // Remove the contextual links.
106
  if (isset($build['#contextual_links'])) {
107
    unset($build['#contextual_links']);
108
  }
109
}
110
111
/**
112
 * Alter the results of the particular embedded entity type build array.
113
 *
114
 * @param array &$build
115
 *   A renderable array representing the embedded entity content.
116
 * @param \Drupal\Core\Entity\EntityInterface $entity
117
 *   The embedded entity object.
118
 * @param array $context
119
 *   The context array.
120
 */
121
function hook_ENTITY_TYPE_embed_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, array &$context) {
0 ignored issues
show
The parameter $entity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
122
  // Remove the contextual links.
123
  if (isset($build['#contextual_links'])) {
124
    unset($build['#contextual_links']);
125
  }
126
}
127
128
/**
129
 * @} End of "addtogroup hooks".
130
 */
131