Issues (74)

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.

Extension/UqlFunction.php (3 issues)

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 Netdudes\DataSourceryBundle\Extension;
4
5
/**
6
 * Wraps a definition of a callable defined in an extension,
7
 * available to be used in UQL, etc.
8
 */
9
class UqlFunction implements \JsonSerializable, UqlFunctionInterface
10
{
11
    /**
12
     * Instance to which this function/method belongs
13
     *
14
     * @var UqlExtensionInterface
15
     */
16
    private $instance;
17
18
    /**
19
     * Name of the method in the instance where its defined
20
     *
21
     * @var string
22
     */
23
    private $method;
24
25
    /**
26
     * Name by which this function will be known inside UQL
27
     *
28
     * @var string
29
     */
30
    private $name;
31
32
    /**
33
     * @param string                $name
34
     * @param UqlExtensionInterface $instance
35
     * @param string                $method
36
     */
37
    public function __construct($name, UqlExtensionInterface $instance, $method)
38
    {
39
        $this->instance = $instance;
40
        $this->name = $name;
41
        $this->method = $method;
42
    }
43
44
    /**
45
     * @return UqlExtensionInterface
46
     */
47
    public function getInstance()
48
    {
49
        return $this->instance;
50
    }
51
52
    /**
53
     * @return mixed
54
     */
55
    public function getMethod()
56
    {
57
        return $this->method;
58
    }
59
60
    /**
61
     * @return mixed
62
     */
63
    public function getName()
64
    {
65
        return $this->name;
66
    }
67
68
    /**
69
     * Performs the call to the function defined by this FunctionExtension
70
     *
71
     * @param array $arguments
72
     *
73
     * @return mixed
74
     */
75
    public function call($arguments)
76
    {
77
        return call_user_func_array([$this->getInstance(), $this->getMethod()], $arguments);
78
    }
79
80
    /**
81
     * Returns a readable string representation of the function, of the standard form:
82
     *
83
     * functionName(argument1, argument2, [optionalArgument1 = defaultValue, [optionalNullableArgument2]])
84
     *
85
     * @return string
86
     */
87
    public function __toString()
88
    {
89
        $reflection = new \ReflectionMethod($this->instance, $this->method);
90
        $methodParameters = $reflection
91
            ->getParameters();
92
93
        $optionalArgumentCount = 0;
94
        $splitStringRepresentation = [];
95
        foreach ($methodParameters as $parameter) {
96
            $optional = $parameter->isOptional();
97
            $name = $parameter->getName();
0 ignored issues
show
Consider using $parameter->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
98
            if ($optional) {
99
                $name = '[' . $name;
100
                $defaultValue = $parameter->getDefaultValue();
101
                if (!is_null($defaultValue)) {
102
                    if (is_numeric($defaultValue)) {
103
                        $defaultValue = intval($defaultValue);
104
                    }
105
                    $name .= ' = ' . $defaultValue;
106
                }
107
108
                $optionalArgumentCount++;
109
            }
110
            $splitStringRepresentation[] = $name;
111
        }
112
113
        return $this->name . '(' . implode(', ', $splitStringRepresentation) . str_repeat(']', $optionalArgumentCount) . ')';
114
    }
115
116
    /**
117
     * (PHP 5 &gt;= 5.4.0)<br/>
118
     * Specify data which should be serialized to JSON
119
     *
120
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
121
     * @return mixed data which can be serialized by <b>json_encode</b>,
122
     *       which is a value of any type other than a resource.
123
     */
124
    public function jsonSerialize()
125
    {
126
        $json = [
127
            'name' => $this->getName(),
0 ignored issues
show
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
128
            'arguments' => [],
129
        ];
130
131
        $reflection = new \ReflectionMethod($this->instance, $this->method);
132
        $methodParameters = $reflection
133
            ->getParameters();
134
135
        foreach ($methodParameters as $parameter) {
136
            $isOptional = $parameter->isOptional();
137
            $argument = [
138
                'name' => $parameter->getName(),
0 ignored issues
show
Consider using $parameter->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
139
                'optional' => $isOptional,
140
                'default' => null,
141
            ];
142
143
            if ($isOptional) {
144
                $defaultValue = $parameter->getDefaultValue();
145
                if (!is_null($defaultValue)) {
146
                    if (is_numeric($defaultValue)) {
147
                        $defaultValue = intval($defaultValue);
148
                    }
149
                    $argument['default'] = $defaultValue;
150
                }
151
            }
152
153
            $json['arguments'][] = $argument;
154
        }
155
156
        return $json;
157
    }
158
}
159