GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (14)

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.

Service/Mapping/Driver/AnnotationDriver.php (3 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
3
namespace Ma27\ApiKeyAuthenticationBundle\Service\Mapping\Driver;
4
5
use Doctrine\Common\Annotations\Reader;
6
use Ma27\ApiKeyAuthenticationBundle\Service\Mapping\ClassMetadata;
7
use ReflectionClass;
8
9
/**
10
 * Annotation driver which parses the annotations of the user model instance.
11
 *
12
 * @internal This code is part of the internal API to gather the appropriate model information and shouldn't be used for else use-cases
13
 */
14
final class AnnotationDriver implements ModelConfigurationDriverInterface
15
{
16
    /**
17
     * @var Reader
18
     */
19
    private $reader;
20
21
    /**
22
     * @var string
23
     */
24
    private $userClass;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param Reader $annotationReader
30
     * @param string $userClass
31
     */
32 16
    public function __construct(Reader $annotationReader, $userClass)
33
    {
34 16
        $this->reader = $annotationReader;
35 16
        $this->userClass = (string) $userClass;
36 16
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @throws \LogicException If one of the annotations is missing
42
     * @throws \LogicException If one property has multiple "auth" annotations
43
     */
44 10
    public function getMetadataForUser()
45
    {
46 10
        $reflection = new ReflectionClass($this->userClass);
47 10
        $properties = $reflection->getProperties();
48
        $metadata = [
49 10
            ClassMetadata::LOGIN_PROPERTY       => null,
50
            ClassMetadata::PASSWORD_PROPERTY    => null,
51
            ClassMetadata::API_KEY_PROPERTY     => null,
52
            ClassMetadata::LAST_ACTION_PROPERTY => null,
53
        ];
54
55 10
        foreach ($properties as $reflectionProperty) {
56 10
            foreach (['login', 'password', 'apiKey', 'lastAction'] as $annotation) {
57 10
                $class = sprintf('Ma27\\ApiKeyAuthenticationBundle\\Annotation\\%s', ucfirst($annotation));
58 10
                $annotationObject = $this->reader->getPropertyAnnotation($reflectionProperty, $class);
0 ignored issues
show
Are you sure the assignment to $annotationObject is correct as $this->reader->getProper...ectionProperty, $class) (which targets Doctrine\Common\Annotati...getPropertyAnnotation()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
59
60 10
                if (!$annotationObject) {
61 10
                    continue;
62
                }
63
64
                switch ($annotation) {
65 10
                    case 'login':
66 9
                        $this->assertUnique($metadata[ClassMetadata::LOGIN_PROPERTY]);
67 9
                        $metadata[ClassMetadata::LOGIN_PROPERTY] = $reflectionProperty;
68 9
                        break;
69 10
                    case 'password':
70 9
                        $this->assertUnique($metadata[ClassMetadata::PASSWORD_PROPERTY]);
71 9
                        $metadata[ClassMetadata::PASSWORD_PROPERTY] = $reflectionProperty;
72 9
                        break;
73 10
                    case 'apiKey':
74 10
                        $this->assertUnique($metadata[ClassMetadata::API_KEY_PROPERTY]);
75 10
                        $metadata[ClassMetadata::API_KEY_PROPERTY] = $reflectionProperty;
76 10
                        break;
77 9
                    case 'lastAction':
78 9
                        $this->assertUnique($metadata[ClassMetadata::LAST_ACTION_PROPERTY]);
79 9
                        $metadata[ClassMetadata::LAST_ACTION_PROPERTY] = $reflectionProperty;
80 9
                        break;
81
                }
82
83 10
                if ($this->isMetadataFullyLoaded($metadata)) {
0 ignored issues
show
$metadata is of type array<string|integer,nul...ct<ReflectionProperty>>, but the function expects a array<integer,object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
84 10
                    break 2;
85
                }
86
            }
87
        }
88
89 10
        if (!$metadata[ClassMetadata::LOGIN_PROPERTY] || !$metadata[ClassMetadata::PASSWORD_PROPERTY] || !$metadata[ClassMetadata::API_KEY_PROPERTY]) {
90 1
            throw new \LogicException('A user class must have a "Login", "Password", "ApiKey" annotation!');
91
        }
92
93 9
        return $metadata;
0 ignored issues
show
The expression return $metadata; seems to be an array, but some of its elements' types (null) are incompatible with the return type declared by the interface Ma27\ApiKeyAuthenticatio...ace::getMetadataForUser of type ReflectionProperty[].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
94
    }
95
96
    /**
97
     * Checks whether a property is already set.
98
     *
99
     * @param \ReflectionProperty $property
100
     *
101
     * @throws \InvalidArgumentException
102
     */
103 10
    private function assertUnique(\ReflectionProperty $property = null)
104
    {
105 10
        if (null !== $property) {
106
            throw $this->createDuplicateAnnotationException();
107
        }
108 10
    }
109
110
    /**
111
     * Creates the exception when.
112
     *
113
     * @return \InvalidArgumentException
114
     */
115
    private function createDuplicateAnnotationException()
116
    {
117
        return new \InvalidArgumentException('None of the Ma27\\ApiKeyAuthenticationBundle annotations can be declared twice!');
118
    }
119
120
    /**
121
     * Method which checks if all metadata annotations were loaded already.
122
     *
123
     * @param object[] $metadata
124
     *
125
     * @return bool
126
     */
127 10
    private function isMetadataFullyLoaded(array $metadata)
128
    {
129 10
        return $metadata[ClassMetadata::LOGIN_PROPERTY]
130 10
            && $metadata[ClassMetadata::PASSWORD_PROPERTY]
131 10
            && $metadata[ClassMetadata::API_KEY_PROPERTY]
132 10
            && $metadata[ClassMetadata::LAST_ACTION_PROPERTY];
133
    }
134
}
135