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

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.

build/Classes/Update/Content/AbstractContent.php (7 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
 * Created by PhpStorm.
4
 * User: pedro
5
 * Date: 24/11/16
6
 * Time: 17:19
7
 */
8
9
namespace Classes\Update\Content;
10
11
use Classes\Update\ProgressBar;
12
use Classes\Update\ProtocolFileContent;
13
14
abstract class AbstractContent
15
{
16
17
    private static $opts = array (
18
        'http' => array (
19
            'method' => 'GET' ,
20
            'header' => array (
21
                'User-Agent: PHP'
22
            )
23
        )
24
    );
25
26
    /**
27
     * @type \Classes\Update\ProtocolFileContent
28
     */
29
    protected $objProtocol;
30
    /**
31
     * @type Content
32
     */
33
    private static $objContent;
34
35
    /**
36
     * @type array
37
     */
38
    private $content = array ();
39
40
    protected function __construct ()
41
    {
42
        $this->objProtocol = ProtocolFileContent::getInstance ();
43
        $this->init ();
44
    }
45
46
    protected function init (){ }
47
48
    /**
49
     * @return \Classes\Update\Content
50
     */
51
    public static function getInstance ()
52
    {
53
        if ( empty( self::$objContent ) )
54
        {
55
            self::$objContent = new static();
0 ignored issues
show
Documentation Bug introduced by
It seems like new static() of type this<Classes\Update\Content\AbstractContent> is incompatible with the declared type object<Classes\Update\Content\Content> of property $objContent.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
        }
57
58
        return self::$objContent;
59
    }
60
61
    /**
62
     * @param $url
63
     *
64
     * @return string
65
     */
66
    public function getContent ( $url , $progress = false )
67
    {
68
        if ( ! isset( $this->content[ $url ] ) )
69
        {
70
            $this->content[ $url ] = '';
71
            switch ( $this->objProtocol->getProtocol () )
72
            {
73
                case 'curl':
74
                    $this->content[ $url ] = $this->getCurlContent ( $url , $progress );
75
                    break;
76
                case 'file_content':
77
                    $this->content[ $url ] = $this->getFileContent ( $url , $progress );
78
                    break;
79
                case 'steam_content':
80
                    $this->content[ $url ] = $this->getStreamContent ( $url , $progress );
81
                    break;
82
            }
83
        }
84
85
        return $this->content[ $url ];
86
    }
87
88
    /**
89
     * @param $url
90
     *
91
     * @return string
92
     */
93
    protected function getCurlContent ( $url , $progress = false )
94
    {
95
        $conn = curl_init ( $url );
96
        curl_setopt ( $conn , CURLOPT_RETURNTRANSFER , true );
97
        curl_setopt ( $conn , CURLOPT_BINARYTRANSFER , true );
98
        curl_setopt ( $conn , CURLOPT_USERAGENT , self::$opts[ 'http' ][ 'method' ] );
99
        if ( $progress )
100
        {
101
            curl_setopt ( $conn , CURLOPT_NOPROGRESS , false );
102
            curl_setopt ( $conn , CURLOPT_PROGRESSFUNCTION , array (
103
                $this , 'progressCallback'
104
            ) );
105
        }
106
        $url_get_contents_data = ( curl_exec ( $conn ) );
107
        curl_close ( $conn );
108
109
        return $url_get_contents_data;
110
    }
111
112
    /**
113
     * @param $url
114
     *
115
     * @return string
116
     */
117 View Code Duplication
    protected function getFileContent ( $url , $progress = false )
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    {
119
        $context = stream_context_create ( self::$opts );
120
        if ( $progress )
121
        {
122
            stream_context_set_params ( $context , array (
123
                "notification" => array (
124
                    $this , 'stream_notification_callback'
125
                )
126
            ) );
127
        }
128
129
        return file_get_contents ( $url , false , $context );
130
    }
131
132
    /**
133
     * @param $url
134
     *
135
     * @return string
136
     */
137 View Code Duplication
    protected function getStreamContent ( $url , $progress = false )
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        $context = stream_context_create ( self::$opts );
140
        if ( $progress )
141
        {
142
            stream_context_set_params ( $context , array (
143
                "notification" => array (
144
                    $this , 'stream_notification_callback'
145
                )
146
            ) );
147
        }
148
149
        $handle = fopen ( $url , "r" , null , $context );
150
151
        return stream_get_contents ( $handle );
152
    }
153
154
    public function putContent ( $url , $content )
155
    {
156
        switch ( $this->objProtocol->getProtocol () )
157
        {
158
            case 'curl':
159
                $this->putFopen ( $url , $content );
160
                break;
161
            case 'steam_content':
162
            case 'file_content':
163
                $this->putFileContent ( $url , $content );
164
                break;
165
        }
166
167
    }
168
169
    public function putFileContent ( $url , $content )
170
    {
171
        // check if all is OK
172
        if ( file_put_contents ( $url , $content ) )
173
        {
174
            ProgressBar::getInstance ()->finish ();
175
        }
176
    }
177
178
    public function putFopen ( $url , $content )
179
    {
180
        $fp = fopen ( $url , "a" );
181
        fwrite ( $fp , $content );
182
        fclose ( $fp );
183
    }
184
185
    /**
186
     * Stream downloading
187
     *
188
     * @param $notification_code
189
     * @param $severity
190
     * @param $message
191
     * @param $message_code
192
     * @param $bytes_transferred
193
     * @param $bytes_max
194
     */
195
    public function stream_notification_callback ( $notificationCode , $severity , $message , $messageCode , $bytesTransferred , $bytesMax )
196
    {
197
        $objProgress = ProgressBar::getInstance ();
198
        switch ( $notificationCode )
199
        {
200
            case STREAM_NOTIFY_RESOLVE:
201
            case STREAM_NOTIFY_AUTH_REQUIRED:
202
            case STREAM_NOTIFY_FAILURE:
203
            case STREAM_NOTIFY_AUTH_RESULT:
204
                var_dump ( $notificationCode , $severity , $message , $messageCode , $bytesTransferred , $bytesMax );
0 ignored issues
show
Security Debugging Code introduced by
var_dump($notificationCo...ransferred, $bytesMax); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
205
                /* Ignore */
206
                break;
207
            case STREAM_NOTIFY_CONNECT:
208
                echo "\033[1;32mConnected...\033[0m\n";
209
                break;
210
            case STREAM_NOTIFY_REDIRECTED:
211
                $objProgress->clear ();
212
                break;
213
            case STREAM_NOTIFY_FILE_SIZE_IS:
214
                $objProgress->clear ()->setMaxByte ( $bytesMax );
215
                break;
216
            case STREAM_NOTIFY_PROGRESS:
217
                $objProgress->setProgress ( $bytesTransferred )
218
                            ->render ();
219
                break;
220
            case STREAM_NOTIFY_COMPLETED:
221
                $objProgress->finish ();
222
                break;
223
        }
224
225
    }
226
227
    function progressCallback ( $download_size , $downloaded_size , $upload_size , $uploaded_size )
0 ignored issues
show
The parameter $upload_size is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $uploaded_size is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
228
    {
229
        ProgressBar::getInstance ()
230
                   ->clear ()
231
                   ->setMaxByte ( $download_size )
232
                   ->setProgress ( $downloaded_size )
233
                   ->render ()
234
                   ->finish ();
235
236
    }
237
238
}