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/AbstractConfig.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
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/27/15 2:31 AM
7
*/
8
9
namespace Youshido\GraphQL\Config;
10
11
12
use Youshido\GraphQL\Exception\ConfigurationException;
13
use Youshido\GraphQL\Exception\ValidationException;
14
use Youshido\GraphQL\Validator\ConfigValidator\ConfigValidator;
15
16
/**
17
 * Class Config
18
 *
19
 * @package Youshido\GraphQL\Config
20
 */
21
abstract class AbstractConfig
22
{
23
24
    /**
25
     * @var array
26
     */
27
    protected $data = [];
28
29
    protected $contextObject;
30
31
    protected $finalClass = false;
32
33
    protected $extraFieldsAllowed = null;
34
35
    /**
36
     * TypeConfig constructor.
37
     *
38
     * @param array $configData
39
     * @param mixed $contextObject
40
     * @param bool  $finalClass
41
     *
42
     * @throws ConfigurationException
43
     * @throws ValidationException
44
     */
45 149
    public function __construct(array $configData, $contextObject = null, $finalClass = false)
46
    {
47 149
        if (empty($configData)) {
48 3
            throw new ConfigurationException('Config for Type should be an array');
49
        }
50
51 146
        $this->contextObject = $contextObject;
52 146
        $this->data          = $configData;
53 146
        $this->finalClass    = $finalClass;
54
55 146
        $this->build();
56 146
    }
57
58
    public function validate()
59
    {
60
        $validator = ConfigValidator::getInstance();
61
62
        if (!$validator->validate($this->data, $this->getContextRules(), $this->extraFieldsAllowed)) {
63
            throw new ConfigurationException('Config is not valid for ' . ($this->contextObject ? get_class($this->contextObject) : null) . "\n" . implode("\n", $validator->getErrorsArray(false)));
64
        }
65
    }
66
67 1
    public function getContextRules()
68
    {
69 1
        $rules = $this->getRules();
70 1 View Code Duplication
        if ($this->finalClass) {
0 ignored issues
show
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...
71 1
            foreach ($rules as $name => $info) {
72 1
                if (!empty($info['final'])) {
73 1
                    $rules[$name]['required'] = true;
74 1
                }
75 1
            }
76 1
        }
77
78 1
        return $rules;
79
    }
80
81
    abstract public function getRules();
82
83 101
    public function getName()
84
    {
85 101
        return $this->get('name');
86
    }
87
88 6
    public function getType()
89
    {
90 6
        return $this->get('type');
91
    }
92
93 99
    public function getData()
94
    {
95 99
        return $this->data;
96
    }
97
98 21
    public function getContextObject()
99
    {
100 21
        return $this->contextObject;
101
    }
102
103 99
    public function isFinalClass()
104
    {
105 99
        return $this->finalClass;
106
    }
107
108 99
    public function isExtraFieldsAllowed()
109
    {
110 99
        return $this->extraFieldsAllowed;
111
    }
112
113
114
    /**
115
     * @return null|callable
116
     */
117 64
    public function getResolveFunction()
118
    {
119 64
        return $this->get('resolve', null);
120
    }
121
122 108
    protected function build()
123
    {
124 108
    }
125
126
    /**
127
     * @param      $key
128
     * @param null $defaultValue
129
     *
130
     * @return mixed|null|callable
131
     */
132 115
    public function get($key, $defaultValue = null)
133
    {
134 115
        return $this->has($key) ? $this->data[$key] : $defaultValue;
135
    }
136
137 31
    public function set($key, $value)
138
    {
139 31
        $this->data[$key] = $value;
140
141 31
        return $this;
142
    }
143
144 115
    public function has($key)
145
    {
146 115
        return array_key_exists($key, $this->data);
147
    }
148
149 3
    public function __call($method, $arguments)
150
    {
151 3
        if (substr($method, 0, 3) == 'get') {
152 2
            $propertyName = lcfirst(substr($method, 3));
153 3
        } elseif (substr($method, 0, 3) == 'set') {
154 1
            $propertyName = lcfirst(substr($method, 3));
155 1
            $this->set($propertyName, $arguments[0]);
156
157 1
            return $this;
158 2
        } elseif (substr($method, 0, 2) == 'is') {
159 1
            $propertyName = lcfirst(substr($method, 2));
160 1
        } else {
161 1
            throw new \Exception('Call to undefined method ' . $method);
162
        }
163
164 2
        return $this->get($propertyName);
165
    }
166
167
168
}
169