Issues (23)

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/GraphQLNode.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 Drupal\graphql_twig;
4
5
use GraphQL\Language\AST\DefinitionNode;
6
use GraphQL\Language\AST\OperationDefinitionNode;
7
use GraphQL\Language\AST\VariableDefinitionNode;
8
use GraphQL\Language\Parser;
9
use Twig_Compiler;
10
11
/**
12
 * GraphQL meta information Twig node.
13
 *
14
 * A Twig node that will be attached to templates `class_end` to output the
15
 * collected graphql query and inheritance metadata. Not parsed directly but
16
 * injected by the `GraphQLNodeVisitor`.
17
 */
18
class GraphQLNode extends \Twig_Node {
19
20
  /**
21
   * The modules query string.
22
   *
23
   * @var string
24
   */
25
  protected $query = "";
26
27
  /**
28
   * The modules parent class.
29
   *
30
   * @var string
31
   */
32
  protected $parent = "";
33
34
  /**
35
   * The modules includes.
36
   *
37
   * @var array
38
   */
39
  protected $includes = [];
40
41
  /**
42
   * Boolean indicator if this fragment includes operations.
43
   *
44
   * @var bool
45
   */
46
  public $hasOperations = FALSE;
47
48
  /**
49
   * The list of arguments accepted by operations in this fragment.
50
   *
51
   * @var array
52
   */
53
  public $arguments = [];
54
55
  /**
56
   * GraphQLNode constructor.
57
   *
58
   * @param string $query
59
   *   The query string.
60
   * @param string $parent
61
   *   The parent template identifier.
62
   * @param array $includes
63
   *   Identifiers for any included/referenced templates.
64
   */
65
  public function __construct($query, $parent, $includes) {
66
    $this->query = trim($query);
67
    $this->parent = $parent;
68
    $this->includes = $includes;
69
70
    if ($this->query) {
71
      $document = Parser::parse($this->query);
72
73
      /** @var \GraphQL\Language\AST\OperationDefinitionNode[] $operations */
74
      $operations = array_filter(iterator_to_array($document->definitions->getIterator()), function (DefinitionNode $node) {
75
        return $node instanceof OperationDefinitionNode;
0 ignored issues
show
The class GraphQL\Language\AST\OperationDefinitionNode 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...
76
      });
77
78
      $this->hasOperations = (bool) $operations;
79
80
      $this->arguments = array_map(function (VariableDefinitionNode $node) {
81
        return $node->variable->name->value;
82
      }, array_reduce($operations, function ($carry, OperationDefinitionNode $node) {
83
        return array_merge($carry, iterator_to_array($node->variableDefinitions->getIterator()));
84
      }, []));
85
    }
86
87
    parent::__construct();
88
  }
89
90
  /**
91
   * {@inheritdoc}
92
   */
93
  public function compile(Twig_Compiler $compiler) {
94
    $compiler
95
      // Make the template implement the GraphQLTemplateTrait.
96
      ->write("\nuse \Drupal\graphql_twig\GraphQLTemplateTrait;\n")
97
      // Write metadata properties.
98
      ->write("\npublic static function hasGraphQLOperations() { return ")->repr($this->hasOperations)->write("; }\n")
99
      ->write("\npublic static function rawGraphQLQuery() { return ")->string($this->query)->write("; }\n")
100
      ->write("\npublic static function rawGraphQLParent() { return ")->string($this->parent)->write("; }\n");
101
102
    $compiler->write("\npublic static function rawGraphQLIncludes() { return [");
103
104
    foreach ($this->includes as $include) {
105
      $compiler->string($include)->write(",");
106
    }
107
108
    $compiler->write("]; }\n");
109
110
    $compiler->write("\npublic static function rawGraphQLArguments() { return [");
111
    foreach ($this->arguments as $argument) {
112
      $compiler->string($argument)->write(",");
113
    }
114
    $compiler->write("]; }\n");
115
  }
116
117
}
118