Issues (49)

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/TdbmFluidColumnGraphqlOptions.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
4
namespace TheCodingMachine\FluidSchema;
5
6
7
use function addslashes;
8
use Doctrine\DBAL\Types\Type;
9
use function var_export;
10
11
class TdbmFluidColumnGraphqlOptions
12
{
13
    /**
14
     * @var TdbmFluidColumnOptions
15
     */
16
    private $tdbmFluidColumnOptions;
17
    /**
18
     * @var string
19
     */
20
    private $name;
21
    /**
22
     * @var string
23
     */
24
    private $outputType;
25
    /**
26
     * @var FluidColumn
27
     */
28
    private $fluidColumn;
29
30
    public function __construct(TdbmFluidColumnOptions $tdbmFluidColumnOptions, FluidColumn $fluidColumn)
31
    {
32
        $this->tdbmFluidColumnOptions = $tdbmFluidColumnOptions;
33
        $this->fluidColumn = $fluidColumn;
34
        if (!$this->getComment()->hasAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Field')) {
35
            $this->generateFieldAnnotation();
36
        }
37
    }
38
39
    private function getComment(): Comment
40
    {
41
        $comment = $this->fluidColumn->getDbalColumn()->getComment();
42
43
        return new Comment($comment ?? '');
44
    }
45
46
    public function fieldName(string $name): self
47
    {
48
        $this->name = $name;
49
        $this->generateFieldAnnotation();
50
        return $this;
51
    }
52
53
    public function outputType(string $outputType): self
54
    {
55
        $this->outputType = $outputType;
56
        $this->generateFieldAnnotation();
57
        return $this;
58
    }
59
60
    private function generateFieldAnnotation(): void
61
    {
62
        $outputType = null;
63
        if ($this->outputType !== null) {
64
            $outputType = $this->outputType;
65
        } elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Type::GUID)) {
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::GUID has been deprecated with message: Use {@see DefaultTypes::GUID} instead.

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
66
            // are we part of a foreign key or not?
67
            $fks = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getForeignKeys();
68
            $isPartOfFk = false;
69
            foreach ($fks as $fk) {
70
                if (in_array($this->fluidColumn->getDbalColumn()->getName(), $fk->getUnquotedLocalColumns(), true) === true) {
71
                    $isPartOfFk = true;
72
                    break;
73
                }
74
            }
75
            if ($isPartOfFk === false) {
76
                $outputType = 'ID';
77
            }
78
        } else {
79
            // If the column is the primary key, let's add an ID type
80
            $pk = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getPrimaryKey();
81
            if ($pk !== null && $pk->getUnquotedColumns() === [$this->fluidColumn->getDbalColumn()->getName()]) {
82
                $outputType = 'ID';
83
            }
84
        }
85
86
        $parameters = array_filter([
87
            'name' => $this->name,
88
            'outputType' => $outputType
89
        ]);
90
        if (empty($parameters)) {
91
            $parameters = null;
92
        }
93
        $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Field', $parameters);
94
    }
95
96
    public function logged(bool $mustBeLogged = true): self
97
    {
98
        if ($mustBeLogged) {
99
            $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Logged');
100
        } else {
101
            $this->removeAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Logged');
102
        }
103
        return $this;
104
    }
105
106
    public function right(string $rightName): self
107
    {
108
        $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Right', ['name'=>$rightName]);
109
        return $this;
110
    }
111
112
    public function failWith($value): self
113
    {
114
        $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\FailWith', $value, true, true);
115
        return $this;
116
    }
117
118
    /**
119
     * @param string $annotation
120
     * @param mixed $content
121
     * @param bool $replaceExisting
122
     * @return TdbmFluidColumnGraphqlOptions
123
     */
124
    public function addAnnotation(string $annotation, $content = null, bool $replaceExisting = true, bool $explicitNull = false): self
125
    {
126
        $this->tdbmFluidColumnOptions->addAnnotation($annotation, $content, $replaceExisting, $explicitNull);
127
        return $this;
128
    }
129
130
    public function removeAnnotation(string $annotation): self
131
    {
132
        $this->tdbmFluidColumnOptions->removeAnnotation($annotation);
133
        return $this;
134
    }
135
136
    public function endGraphql(): TdbmFluidColumnOptions
137
    {
138
        return $this->tdbmFluidColumnOptions;
139
    }
140
141
    public function then(): TdbmFluidTable
142
    {
143
        return $this->tdbmFluidColumnOptions->then();
144
    }
145
146
    public function column(string $name): TdbmFluidColumn
147
    {
148
        return $this->tdbmFluidColumnOptions->column($name);
149
    }
150
}
151