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

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.

protected/extensions/eauth/EOAuth2Service.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
 * EOAuth2Service class file.
4
 *
5
 * @author Maxim Zemskov <[email protected]>
6
 * @link http://github.com/Nodge/yii-eauth/
7
 * @license http://www.opensource.org/licenses/bsd-license.php
8
 */
9
10
require_once 'EAuthServiceBase.php';
11
12
/**
13
 * EOAuth2Service is a base class for all OAuth 2.0 providers.
14
 *
15
 * @package application.extensions.eauth
16
 */
17
abstract class EOAuth2Service extends EAuthServiceBase implements IAuthService {
18
19
	/**
20
	 * @var string OAuth2 client id.
21
	 */
22
	protected $client_id;
23
24
	/**
25
	 * @var string OAuth2 client secret key.
26
	 */
27
	protected $client_secret;
28
29
	/**
30
	 * @var string OAuth scopes.
31
	 */
32
	protected $scope = '';
33
34
	/**
35
	 * @var array Provider options. Must contain the keys: authorize, access_token.
36
	 */
37
	protected $providerOptions = array(
38
		'authorize' => '',
39
		'access_token' => '',
40
	);
41
42
	/**
43
	 * @var string current OAuth2 access token.
44
	 */
45
	protected $access_token = '';
46
47
	/**
48
	 * @var string Error key name in _GET options.
49
	 */
50
	protected $errorParam = 'error';
51
52
	/**
53
	 * @var string Error description key name in _GET options.
54
	 */
55
	protected $errorDescriptionParam = 'error_description';
56
57
	/**
58
	 * @var string Error code for access_denied response.
59
	 */
60
	protected $errorAccessDeniedCode = 'access_denied';
61
62
63
	public function init($component, $options = array()) {
64
		parent::init($component, $options);
65
66
		// Try to restore access token from session.
67
		$this->restoreAccessToken();
68
	}
69
70
	/**
71
	 * Authenticate the user.
72
	 *
73
	 * @return boolean whether user was successfuly authenticated.
74
	 * @throws EAuthException
75
	 */
76
	public function authenticate() {
77
		if (isset($_GET[$this->errorParam])) {
78
			$error_code = $_GET[$this->errorParam];
79
			if ($error_code === $this->errorAccessDeniedCode) {
80
				// access_denied error (user canceled)
81
				$this->cancel();
82
			}
83
			else {
84
				$error = $error_code;
85
				if (isset($_GET[$this->errorDescriptionParam])) {
86
					$error = $_GET[$this->errorDescriptionParam].' ('.$error.')';
87
				}
88
				throw new EAuthException($error);
89
			}
90
			return false;
91
		}
92
93
		// Get the access_token and save them to the session.
94
		if (isset($_GET['code'])) {
95
			$code = $_GET['code'];
96
			$token = $this->getAccessToken($code);
97
			if (isset($token)) {
98
				$this->authenticated = true;
99
				$this->saveAccessToken($token);
100
			}
101
		}
102
		// Redirect to the authorization page
103
		else {
104
			// Use the URL of the current page as the callback URL.
105 View Code Duplication
			if (isset($_GET['redirect_uri'])) {
0 ignored issues
show
This code seems to be duplicated across 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...
106
				$redirect_uri = $_GET['redirect_uri'];
107
			}
108
			else {
109
				$server = Yii::app()->request->getHostInfo();
110
				$path = Yii::app()->request->getUrl();
111
				$redirect_uri = $server . $path;
112
			}
113
			$url = $this->getCodeUrl($redirect_uri);
114
			Yii::app()->request->redirect($url);
115
		}
116
117
		return $this->getIsAuthenticated();
118
	}
119
120
	/**
121
	 * Returns the url to request to get OAuth2 code.
122
	 *
123
	 * @param string $redirect_uri url to redirect after user confirmation.
124
	 * @return string url to request.
125
	 */
126
	protected function getCodeUrl($redirect_uri) {
127
		$this->setState('redirect_uri', $redirect_uri);
128
		return $this->providerOptions['authorize'] . '?client_id=' . $this->client_id . '&redirect_uri=' . urlencode($redirect_uri) . '&scope=' . $this->scope . '&response_type=code';
129
	}
130
131
	/**
132
	 * Returns the url to request to get OAuth2 access token.
133
	 *
134
	 * @param string $code
135
	 * @return string url to request.
136
	 */
137
	protected function getTokenUrl($code) {
138
		return $this->providerOptions['access_token'] . '?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret . '&code=' . $code . '&redirect_uri=' . urlencode($this->getState('redirect_uri'));
139
	}
140
141
	/**
142
	 * Returns the OAuth2 access token.
143
	 *
144
	 * @param string $code the OAuth2 code. See {@link getCodeUrl}.
145
	 * @return string the token.
146
	 */
147
	protected function getAccessToken($code) {
148
		return $this->makeRequest($this->getTokenUrl($code));
149
	}
150
151
	/**
152
	 * Save access token to the session.
153
	 *
154
	 * @param string $token access token.
155
	 */
156
	protected function saveAccessToken($token) {
157
		$this->setState('auth_token', $token);
158
		$this->access_token = $token;
159
	}
160
161
	/**
162
	 * Restore access token from the session.
163
	 *
164
	 * @return boolean whether the access token was successfuly restored.
165
	 */
166
	protected function restoreAccessToken() {
167
		if (!$this->authenticated) {
168
			if ($this->hasState('auth_token') && $this->getState('expires', 0) > time()) {
169
				$this->access_token = $this->getState('auth_token');
170
				$this->authenticated = true;
171
			}
172
			else {
173
				$this->access_token = null;
174
				$this->authenticated = false;
175
			}
176
		}
177
178
		return $this->authenticated;
179
	}
180
181
	/**
182
	 * Returns fields required for signed request.
183
	 * By default returns array('access_token' => $this->access_token).
184
	 * Used in {@link makeSignedRequest}.
185
	 * 
186
	 * @return array 
187
	 */
188
	protected function getSignedRequestFields()
189
	{
190
		return array('access_token' => $this->access_token);
191
	}
192
193
	/**
194
	 * Returns the protected resource.
195
	 *
196
	 * @param string $url url to request.
197
	 * @param array $options HTTP request options. Keys: query, data, referer.
198
	 * @param boolean $parseJson Whether to parse response in json format.
199
	 * @return stdClass the response.
200
	 * @see makeRequest
201
	 */
202
	public function makeSignedRequest($url, $options = array(), $parseJson = true) {
203
		if (!$this->getIsAuthenticated()) {
204
			throw new CHttpException(401, Yii::t('eauth', 'Unable to complete the request because the user was not authenticated.'));
205
		}
206
207
		// Merge query fields with fields required for signed request.
208
		$options['query'] = 
209
			array_merge(
210
				isset($options['query']) ? $options['query'] : array(), 
211
				$this->getSignedRequestFields()
212
			);
213
214
		$result = $this->makeRequest($url, $options, $parseJson);
215
		
216
		return $result;
217
	}
218
}
219