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

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.

JonnyW/PhantomJs/Procedure/ProcedureCompiler.php (3 issues)

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
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace JonnyW\PhantomJs\Procedure;
11
12
use JonnyW\PhantomJs\Cache\CacheInterface;
13
use JonnyW\PhantomJs\Template\TemplateRendererInterface;
14
15
/**
16
 * PHP PhantomJs
17
 *
18
 * @author Jon Wenmoth <[email protected]>
19
 */
20
class ProcedureCompiler implements ProcedureCompilerInterface
21
{
22
    /**
23
     * Procedure loader
24
     *
25
     * @var \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface
26
     * @access protected
27
     */
28
    protected $procedureLoader;
29
30
    /**
31
     * Procedure validator
32
     *
33
     * @var \JonnyW\PhantomJs\Procedure\ProcedureValidatorInterface
34
     * @access protected
35
     */
36
    protected $procedureValidator;
37
38
    /**
39
     * Cache handler
40
     *
41
     * @var \JonnyW\PhantomJs\Cache\CacheInterface
42
     * @access protected
43
     */
44
    protected $cacheHandler;
45
46
    /**
47
     * Renderer
48
     *
49
     * @var \JonnyW\PhantomJs\Template\TemplateRendererInterface
50
     * @access protected
51
     */
52
    protected $renderer;
53
54
    /**
55
     * Cache enabled
56
     *
57
     * @var boolean
58
     * @access protected
59
     */
60
    protected $cacheEnabled;
61
62
    /**
63
     * Internal constructor
64
     *
65
     * @access public
66
     * @param \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface    $procedureLoader
67
     * @param \JonnyW\PhantomJs\Procedure\ProcedureValidatorInterface $procedureValidator
68
     * @param \JonnyW\PhantomJs\Cache\CacheInterface                  $cacheHandler
69
     * @param \JonnyW\PhantomJs\Template\TemplateRendererInterface    $renderer
70
     */
71 6
    public function __construct(ProcedureLoaderInterface $procedureLoader, ProcedureValidatorInterface $procedureValidator,
72
        CacheInterface $cacheHandler, TemplateRendererInterface $renderer)
73
    {
74 6
        $this->procedureLoader    = $procedureLoader;
75 6
        $this->procedureValidator = $procedureValidator;
76 6
        $this->cacheHandler       = $cacheHandler;
77 6
        $this->renderer           = $renderer;
78 6
        $this->cacheEnabled       = true;
79 6
    }
80
81
    /**
82
     * Compile partials into procedure.
83
     *
84
     * @access public
85
     * @param  \JonnyW\PhantomJs\Procedure\ProcedureInterface $procedure
86
     * @param  \JonnyW\PhantomJs\Procedure\InputInterface     $input
87
     * @return void
88
     */
89 42
    public function compile(ProcedureInterface $procedure, InputInterface $input)
90
    {
91 42
        $cacheKey = sprintf('phantomjs_%s_%s', $input->getType(), md5($procedure->getTemplate()));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface JonnyW\PhantomJs\Procedure\InputInterface as the method getType() does only exist in the following implementations of said interface: JonnyW\PhantomJs\Http\AbstractRequest, JonnyW\PhantomJs\Http\CaptureRequest, JonnyW\PhantomJs\Http\PdfRequest, JonnyW\PhantomJs\Http\Request.

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...
92
93 42
        if ($this->cacheEnabled && $this->cacheHandler->exists($cacheKey)) {
94 31
            $template = $this->cacheHandler->fetch($cacheKey);
0 ignored issues
show
Are you sure the assignment to $template is correct as $this->cacheHandler->fetch($cacheKey) (which targets JonnyW\PhantomJs\Cache\CacheInterface::fetch()) 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...
95 31
        }
96
97 42
        if (empty($template)) {
98
99 12
            $template  = $this->renderer
100 12
                ->render($procedure->getTemplate(), array('engine' => $this, 'procedure_type' => $input->getType()));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface JonnyW\PhantomJs\Procedure\InputInterface as the method getType() does only exist in the following implementations of said interface: JonnyW\PhantomJs\Http\AbstractRequest, JonnyW\PhantomJs\Http\CaptureRequest, JonnyW\PhantomJs\Http\PdfRequest, JonnyW\PhantomJs\Http\Request.

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...
101
102 12
            $test = clone $procedure;
103 12
            $test->setTemplate($template);
104
105 12
            $compiled = $test->compile($input);
106
107 12
            $this->procedureValidator->validate($compiled);
108
109 10
            if ($this->cacheEnabled) {
110 9
                $this->cacheHandler->save($cacheKey, $template);
111 9
            }
112 10
        }
113
114 40
        $procedure->setTemplate($template);
115 40
    }
116
117
    /**
118
     * Load partial template.
119
     *
120
     * @access public
121
     * @param  string $name
122
     * @return string
123
     */
124 5
    public function load($name)
125
    {
126 5
        return $this->procedureLoader->loadTemplate($name, 'partial');
127
    }
128
129
    /**
130
     * Enable cache.
131
     *
132
     * @access public
133
     * @return void
134
     */
135 1
    public function enableCache()
136
    {
137 1
        $this->cacheEnabled = true;
138 1
    }
139
140
    /**
141
     * Disable cache.
142
     *
143
     * @access public
144
     * @return void
145
     */
146 1
    public function disableCache()
147
    {
148 1
        $this->cacheEnabled = false;
149 1
    }
150
151
    /**
152
     * Clear cache.
153
     *
154
     * @access public
155
     * @return void
156
     */
157 1
    public function clearCache()
158
    {
159 1
        $this->cacheHandler->delete('phantomjs_*');
160 1
    }
161
}
162