Issues (15)

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/Annotation/Query.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
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Annotation;
5
6
use Paysera\Bundle\ApiBundle\Entity\QueryResolverOptions;
7
use Paysera\Bundle\ApiBundle\Entity\RestRequestOptions;
8
use Paysera\Bundle\ApiBundle\Exception\ConfigurationException;
9
use Paysera\Bundle\ApiBundle\Service\Annotation\ReflectionMethodWrapper;
10
11
/**
12
 * @Annotation
13
 * @Target({"METHOD"})
14
 */
15
class Query implements RestAnnotationInterface
16
{
17
    /**
18
     * @var string
19
     */
20
    private $parameterName;
21
22
    /**
23
     * @var string|null
24
     */
25
    private $denormalizationType;
26
27
    /**
28
     * @var string|null
29
     */
30
    private $denormalizationGroup;
31
32
    /**
33
     * @var Validation|null
34
     */
35
    private $validation;
36
37 96 View Code Duplication
    public function __construct(array $options)
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...
38
    {
39 96
        $this->setParameterName($options['parameterName']);
40 96
        $this->setDenormalizationType($options['denormalizationType'] ?? null);
41 96
        $this->setDenormalizationGroup($options['denormalizationGroup'] ?? null);
42 96
        $this->setValidation($options['validation'] ?? null);
43 96
    }
44
45
    /**
46
     * @param string $parameterName
47
     * @return $this
48
     */
49 96
    private function setParameterName(string $parameterName): self
50
    {
51 96
        $this->parameterName = $parameterName;
52 96
        return $this;
53
    }
54
55
    /**
56
     * @param string|null $denormalizationType
57
     * @return $this
58
     */
59 96
    private function setDenormalizationType($denormalizationType): self
60
    {
61 96
        $this->denormalizationType = $denormalizationType;
62 96
        return $this;
63
    }
64
65
    /**
66
     * @param string|null $denormalizationGroup
67
     * @return $this
68
     */
69 96
    public function setDenormalizationGroup($denormalizationGroup): self
70
    {
71 96
        $this->denormalizationGroup = $denormalizationGroup;
72 96
        return $this;
73
    }
74
75
    /**
76
     * @param Validation|null $validation
77
     * @return $this
78
     */
79 96
    private function setValidation($validation): self
80
    {
81 96
        $this->validation = $validation;
82 96
        return $this;
83
    }
84
85 96
    public function isSeveralSupported(): bool
86
    {
87 96
        return true;
88
    }
89
90 96
    public function apply(RestRequestOptions $options, ReflectionMethodWrapper $reflectionMethod)
91
    {
92 96
        $resolverOptions = (new QueryResolverOptions())
93 96
            ->setParameterName($this->parameterName)
94 96
            ->setDenormalizationType($this->resolveDenormalizationType($reflectionMethod))
95 96
            ->setDenormalizationGroup($this->denormalizationGroup)
96
        ;
97
98 96
        $this->setValidationOptions($reflectionMethod, $resolverOptions);
99
100 96
        $options->addQueryResolverOptions($resolverOptions);
101 96
    }
102
103 96 View Code Duplication
    private function resolveDenormalizationType(ReflectionMethodWrapper $reflectionMethod): string
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...
104
    {
105 96
        if ($this->denormalizationType !== null) {
106 96
            return $this->denormalizationType;
107
        }
108
109
        try {
110 96
            $typeName = $reflectionMethod->getNonBuiltInTypeForParameter($this->parameterName);
111
        } catch (ConfigurationException $exception) {
112
            throw new ConfigurationException(sprintf(
113
                'Denormalization type could not be guessed for %s in %s',
114
                '$' . $this->parameterName,
115
                $reflectionMethod->getFriendlyName()
116
            ));
117
        }
118
119 96
        return $typeName;
120
    }
121
122 96
    private function setValidationOptions(ReflectionMethodWrapper $reflectionMethod, QueryResolverOptions $options)
123
    {
124 96
        if ($this->validation === null) {
125 96
            return;
126
        }
127
128 96
        $restRequestOptions = new RestRequestOptions();
129 96
        $this->validation->apply($restRequestOptions, $reflectionMethod);
130
131 96
        if (!$restRequestOptions->isBodyValidationNeeded()) {
132 96
            $options->disableValidation();
133 96
            return;
134
        }
135
136 96
        $options->setValidationOptions($restRequestOptions->getBodyValidationOptions());
137 96
    }
138
}
139