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/Parser/Token.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
 * Date: 23.11.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Parser;
9
10
class Token
11
{
12
13
    const TYPE_END        = 'end';
14
    const TYPE_IDENTIFIER = 'identifier';
15
    const TYPE_NUMBER     = 'number';
16
    const TYPE_STRING     = 'string';
17
    const TYPE_ON         = 'on';
18
19
    const TYPE_QUERY              = 'query';
20
    const TYPE_MUTATION           = 'mutation';
21
    const TYPE_FRAGMENT           = 'fragment';
22
    const TYPE_FRAGMENT_REFERENCE = '...';
23
    const TYPE_TYPED_FRAGMENT     = 'typed fragment';
24
25
    const TYPE_LBRACE        = '{';
26
    const TYPE_RBRACE        = '}';
27
    const TYPE_LPAREN        = '(';
28
    const TYPE_RPAREN        = ')';
29
    const TYPE_LSQUARE_BRACE = '[';
30
    const TYPE_RSQUARE_BRACE = ']';
31
    const TYPE_COLON         = ':';
32
    const TYPE_COMMA         = ',';
33
    const TYPE_VARIABLE      = '$';
34
    const TYPE_POINT         = '.';
35
    const TYPE_REQUIRED      = '!';
36
    const TYPE_EQUAL         = '=';
37
    const TYPE_AT            = '@';
38
39
    const TYPE_NULL  = 'null';
40
    const TYPE_TRUE  = 'true';
41
    const TYPE_FALSE = 'false';
42
43
44
    /** @var mixed */
45
    private $data;
46
47
    /** @var  string */
48
    private $type;
49
50
    /** @var integer */
51
    private $line;
52
53
    /** @var integer */
54
    private $column;
55
56 108
    public function __construct($type, $line, $column, $data = null)
57
    {
58 108
        $this->type = $type;
59 108
        $this->data = $data;
60
61 108
        $this->line   = $line;
62 108
        $this->column = $column;
63
64 108
        if ($data) {
65 106
            $tokenLength = mb_strlen($data);
66 106
            $tokenLength = $tokenLength > 1 ? $tokenLength - 1 : 0;
67
68 106
            $this->column = $column - $tokenLength;
0 ignored issues
show
Documentation Bug introduced by
It seems like $column - $tokenLength can also be of type double. However, the property $column is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
69 106
        }
70
71 108
        if ($this->getType() == self::TYPE_TRUE) {
72 5
            $this->data = true;
73 5
        }
74
75 108
        if ($this->getType() == self::TYPE_FALSE) {
76 1
            $this->data = false;
77 1
        }
78
79 108
        if ($this->getType() == self::TYPE_NULL) {
80 9
            $this->data = null;
81 9
        }
82 108
    }
83
84 9
    public static function tokenName($tokenType)
85
    {
86
        return [
87 9
            self::TYPE_END                => 'END',
88 9
            self::TYPE_IDENTIFIER         => 'IDENTIFIER',
89 9
            self::TYPE_NUMBER             => 'NUMBER',
90 9
            self::TYPE_STRING             => 'STRING',
91 9
            self::TYPE_ON                 => 'ON',
92 9
            self::TYPE_QUERY              => 'QUERY',
93 9
            self::TYPE_MUTATION           => 'MUTATION',
94 9
            self::TYPE_FRAGMENT           => 'FRAGMENT',
95 9
            self::TYPE_FRAGMENT_REFERENCE => 'FRAGMENT_REFERENCE',
96 9
            self::TYPE_TYPED_FRAGMENT     => 'TYPED_FRAGMENT',
97 9
            self::TYPE_LBRACE             => 'LBRACE',
98 9
            self::TYPE_RBRACE             => 'RBRACE',
99 9
            self::TYPE_LPAREN             => 'LPAREN',
100 9
            self::TYPE_RPAREN             => 'RPAREN',
101 9
            self::TYPE_LSQUARE_BRACE      => 'LSQUARE_BRACE',
102 9
            self::TYPE_RSQUARE_BRACE      => 'RSQUARE_BRACE',
103 9
            self::TYPE_COLON              => 'COLON',
104 9
            self::TYPE_COMMA              => 'COMMA',
105 9
            self::TYPE_VARIABLE           => 'VARIABLE',
106 9
            self::TYPE_POINT              => 'POINT',
107 9
            self::TYPE_NULL               => 'NULL',
108 9
            self::TYPE_TRUE               => 'TRUE',
109 9
            self::TYPE_FALSE              => 'FALSE',
110 9
            self::TYPE_REQUIRED           => 'REQUIRED',
111 9
            self::TYPE_AT                 => 'AT',
112 9
        ][$tokenType];
113
    }
114
115
    /**
116
     * @return mixed
117
     */
118 98
    public function getData()
119
    {
120 98
        return $this->data;
121
    }
122
123
    /**
124
     * @return string
125
     */
126 108
    public function getType()
127
    {
128 108
        return $this->type;
129
    }
130
131
    /**
132
     * @return int
133
     */
134 102
    public function getLine()
135
    {
136 102
        return $this->line;
137
    }
138
139
    /**
140
     * @return int
141
     */
142 102
    public function getColumn()
143
    {
144 102
        return $this->column;
145
    }
146
}
147