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 (2)

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/Reader.php (1 issue)

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 Minime\Annotations;
4
5
use Minime\Annotations\Cache\ArrayCache;
6
use Minime\Annotations\Interfaces\CacheInterface;
7
use Minime\Annotations\Interfaces\ParserInterface;
8
use Minime\Annotations\Interfaces\ReaderInterface;
9
use Minime\Annotations\Reflector\ReflectionConst;
10
11
/**
12
 * This class is the primary entry point to read annotations
13
 *
14
 * @package Minime\Annotations
15
 */
16
class Reader implements ReaderInterface
17
{
18
    /**
19
     * @var \Minime\Annotations\Interfaces\ParserInterface
20
     */
21
    protected $parser;
22
23
    /**
24
     * @var \Minime\Annotations\Interfaces\CacheInterface
25
     */
26
    protected $cache;
27
28
    /**
29
     * @param \Minime\Annotations\Interfaces\ParserInterface $parser
30
     */
31
    public function __construct(ParserInterface $parser, CacheInterface $cache = null)
32
    {
33
        $this->setParser($parser);
34
        $this->setCache($cache);
35
    }
36
37
    /**
38
     * @param \Minime\Annotations\Interfaces\CacheInterface $cache Cache handler
39
     */
40
    public function setCache(CacheInterface $cache = null)
41
    {
42
        $this->cache = $cache;
43
    }
44
45
    /**
46
     * @return \Minime\Annotations\Interfaces\CacheInterface Cache handler
47
     */
48
    public function getCache()
49
    {
50
        return $this->cache;
51
    }
52
53
    /**
54
     * @param \Minime\Annotations\Interfaces\ParserInterface $parser
55
     */
56
    public function setParser(ParserInterface $parser)
57
    {
58
        $this->parser = $parser;
59
    }
60
61
    /**
62
     * @return \Minime\Annotations\Interfaces\ParserInterface
63
     */
64
    public function getParser()
65
    {
66
        return $this->parser;
67
    }
68
69
    /**
70
     * Retrieve all annotations from a given function or closure
71
     *
72
     * @param  mixed                                                  $fn Full qualified function name or closure
73
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
74
     * @throws \ReflectionException                                   If function is not found
75
     */
76
    public function getFunctionAnnotations($fn)
77
    {
78
        return $this->getAnnotations(new \ReflectionFunction($fn));
79
    }
80
81
    /**
82
     * Retrieve all annotations from a given class
83
     *
84
     * @param  mixed                                                  $class Full qualified class name or object
85
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
86
     * @throws \ReflectionException                                   If class is not found
87
     */
88
    public function getClassAnnotations($class)
89
    {
90
        return $this->getAnnotations(new \ReflectionClass($class));
91
    }
92
93
    /**
94
     * Retrieve all annotations from a given property of a class
95
     *
96
     * @param  mixed                                                  $class    Full qualified class name or object
97
     * @param  string                                                 $property Property name
98
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
99
     * @throws \ReflectionException                                   If property is undefined
100
     */
101
    public function getPropertyAnnotations($class, $property)
102
    {
103
        return $this->getAnnotations(new \ReflectionProperty($class, $property));
104
    }
105
106
    /**
107
     * Retrieve all annotations from a given method of a class
108
     *
109
     * @param  mixed                                                  $class  Full qualified class name or object
110
     * @param  string                                                 $method Method name
111
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
112
     * @throws \ReflectionException                                   If method is undefined
113
     */
114
    public function getMethodAnnotations($class, $method)
115
    {
116
        return $this->getAnnotations(new \ReflectionMethod($class, $method));
117
    }
118
119
    /**
120
     * Retrieve all annotations from a given constant of a class
121
     *
122
     * @param  string|object                                          $class fully qualified name or instance of the class
123
     * @param  string                                                 $const name of the constant
124
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
125
     */
126
    public function getConstantAnnotations($class, $const)
127
    {
128
        return $this->getAnnotations(new ReflectionConst($class, $const));
129
    }
130
131
    /**
132
     * Retrieve annotations from docblock of a given reflector
133
     *
134
     * @param  \Reflector                                             $Reflection Reflector object
135
     * @return \Minime\Annotations\Interfaces\AnnotationsBagInterface Annotations collection
136
     */
137
    public function getAnnotations(\Reflector $Reflection)
138
    {
139
        $doc = $Reflection->getDocComment();
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Reflector as the method getDocComment() does only exist in the following implementations of said interface: Minime\Annotations\Reflector\ReflectionConst, ReflectionClass, ReflectionFunction, ReflectionFunctionAbstract, ReflectionMethod, ReflectionObject, ReflectionProperty.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
140
        if ($this->cache) {
141
            $key = $this->cache->getKey($doc);
142
            $ast = $this->cache->get($key);
143
            if (! $ast) {
144
                $ast = $this->parser->parse($doc);
145
                $this->cache->set($key, $ast);
146
            }
147
        } else {
148
            $ast = $this->parser->parse($doc);
149
        }
150
151
        return new AnnotationsBag($ast);
152
    }
153
154
    /**
155
     * Shortcut to create an instance of the default annotations Reader
156
     * bundled with the default Parser implementation
157
     *
158
     * @return \Minime\Annotations\Interfaces\ReaderInterface
159
     */
160
    public static function createFromDefaults()
161
    {
162
        return new self(new Parser, new ArrayCache);
163
    }
164
}
165