Issues (234)

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.

src/Config/Traits/FieldsAwareConfigTrait.php (2 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
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 12/1/15 11:05 PM
7
*/
8
9
namespace Youshido\GraphQL\Config\Traits;
10
11
12
use Youshido\GraphQL\Field\Field;
13
use Youshido\GraphQL\Field\FieldInterface;
14
use Youshido\GraphQL\Field\InputFieldInterface;
15
use Youshido\GraphQL\Type\InterfaceType\AbstractInterfaceType;
16
17
/**
18
 * Class FieldsAwareTrait
19
 * @package Youshido\GraphQL\Config\Traits
20
 */
21
trait FieldsAwareConfigTrait
22
{
23
    protected $fields = [];
24
25 121
    public function buildFields()
26
    {
27 121
        if (!empty($this->data['fields'])) {
28 85
            $this->addFields($this->data['fields']);
0 ignored issues
show
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29 85
        }
30 121
    }
31
32
    /**
33
     * Add fields from passed interface
34
     * @param AbstractInterfaceType $interfaceType
35
     * @return $this
36
     */
37 1
    public function applyInterface(AbstractInterfaceType $interfaceType)
38
    {
39 1
        $this->addFields($interfaceType->getFields());
40
41 1
        return $this;
42
    }
43
44
    /**
45
     * @param array $fieldsList
46
     * @return $this
47
     */
48 88
    public function addFields($fieldsList)
49
    {
50 88
        foreach ($fieldsList as $fieldName => $fieldConfig) {
51
52 88
            if ($fieldConfig instanceof FieldInterface) {
53 9
                $this->fields[$fieldConfig->getName()] = $fieldConfig;
54 9
                continue;
55 82
            } elseif($fieldConfig instanceof InputFieldInterface) {
56 2
                $this->fields[$fieldConfig->getName()] = $fieldConfig;
57 2
                continue;
58
            } else {
59 82
                $this->addField($fieldName, $this->buildFieldConfig($fieldName, $fieldConfig));
60
            }
61 88
        }
62
63 88
        return $this;
64
    }
65
66
    /**
67
     * @param FieldInterface|string $field     Field name or Field Object
68
     * @param mixed                $fieldInfo Field Type or Field Config array
69
     * @return $this
70
     */
71 98
    public function addField($field, $fieldInfo = null)
72
    {
73 98
        if (!($field instanceof FieldInterface)) {
74 92
            $field = new Field($this->buildFieldConfig($field, $fieldInfo));
75 92
        }
76
77 98
        $this->fields[$field->getName()] = $field;
78
79 98
        return $this;
80
    }
81
82 92 View Code Duplication
    protected function buildFieldConfig($name, $info = null)
0 ignored issues
show
This method 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
    {
84 92
        if (!is_array($info)) {
85
            $info = [
86 68
                'type' => $info,
87 68
                'name' => $name,
88 68
            ];
89 92
        } elseif (empty($info['name'])) {
90 76
            $info['name'] = $name;
91 76
        }
92
93 92
        return $info;
94
    }
95
96
    /**
97
     * @param $name
98
     *
99
     * @return Field
100
     */
101 76
    public function getField($name)
102
    {
103 76
        return $this->hasField($name) ? $this->fields[$name] : null;
104
    }
105
106
    /**
107
     * @param $name
108
     *
109
     * @return bool
110
     */
111 80
    public function hasField($name)
112
    {
113 80
        return array_key_exists($name, $this->fields);
114
    }
115
116 84
    public function hasFields()
117
    {
118 84
        return !empty($this->fields);
119
    }
120
121
    /**
122
     * @return Field[]
123
     */
124 84
    public function getFields()
125
    {
126 84
        return $this->fields;
127
    }
128
129 1
    public function removeField($name)
130
    {
131 1
        if ($this->hasField($name)) {
132 1
            unset($this->fields[$name]);
133 1
        }
134
135 1
        return $this;
136
    }
137
}
138