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

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.

src/components/TbEditableSaver.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
 *## EditableSaver class file.
4
 *
5
 * @author Vitaliy Potapov <[email protected]>
6
 * @link https://github.com/vitalets/x-editable-yii
7
 * @copyright Copyright &copy; Vitaliy Potapov 2012
8
 * @version 1.1.0
9
 */
10
11
/**
12
 * EditableSaver helps to update model by editable widget submit request.
13
 *
14
 * @package booster.widgets.supplementary
15
*/
16
class TbEditableSaver extends CComponent
17
{
18
	/**
19
	 * scenarion used in model for update
20
	 *
21
	 * @var mixed
22
	 */
23
	public $scenario = 'editable';
24
25
	/**
26
	 * name of model
27
	 *
28
	 * @var mixed
29
	 */
30
	public $modelClass;
31
	/**
32
	 * primaryKey value
33
	 *
34
	 * @var mixed
35
	 */
36
	public $primaryKey;
37
	/**
38
	 * name of attribute to be updated
39
	 *
40
	 * @var mixed
41
	 */
42
	public $attribute;
43
	/**
44
	 * model instance
45
	 *
46
	 * @var CActiveRecord
47
	 */
48
	public $model;
49
50
	/**
51
	 * @var mixed new value of attribute
52
	 */
53
	public $value;
54
55
	/**
56
	 * http status code returned in case of error
57
	 */
58
	public $errorHttpCode = 400;
59
60
	/**
61
	 * name of changed attributes. Used when saving model
62
	 *
63
	 * @var mixed
64
	 */
65
	protected $changedAttributes = array();
66
67
	/**
68
	 *### ._construct()
69
	 *
70
	 * Constructor
71
	 *
72
	 * @param $modelClass
73
	 *
74
	 * @throws CException
75
	 * @internal param mixed $modelName
76
	 * @return \TbEditableSaver
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
77
	 */
78
	public function __construct($modelClass)
79
	{
80
		if (empty($modelClass)) {
81
			throw new CException(Yii::t(
82
				'TbEditableSaver.editable',
83
				'You should provide modelClass in constructor of EditableSaver.'
84
			));
85
		}
86
87
		$this->modelClass = $modelClass;
88
89
		//for non-namespaced models do ucfirst (for backwards compability)
90
		//see https://github.com/vitalets/x-editable-yii/issues/9
91
		if (strpos($this->modelClass, '\\') === false) {
92
			$this->modelClass = ucfirst($this->modelClass);
93
		}
94
	}
95
96
	/**
97
	 *### .update()
98
	 *
99
	 * main function called to update column in database
100
	 *
101
	 */
102
	public function update()
103
	{
104
		//get params from request
105
		$this->primaryKey = yii::app()->request->getParam('pk');
106
		$this->attribute = yii::app()->request->getParam('name');
107
		$this->value = yii::app()->request->getParam('value');
108
109
		//checking params
110
		if (empty($this->attribute)) {
111
			throw new CException(Yii::t('TbEditableSaver.editable', 'Property "attribute" should be defined.'));
112
		}
113
		if (empty($this->primaryKey)) {
114
			throw new CException(Yii::t('TbEditableSaver.editable', 'Property "primaryKey" should be defined.'));
115
		}
116
117
		//loading model
118
		$this->model = CActiveRecord::model($this->modelClass)->findByPk($this->primaryKey);
119
		if (!$this->model) {
120
			throw new CException(Yii::t(
121
				'TbEditableSaver.editable',
122
				'Model {class} not found by primary key "{pk}"',
123
				array(
124
					'{class}' => get_class($this->model),
125
					'{pk}' => is_array($this->primaryKey) ? CJSON::encode($this->primaryKey) : $this->primaryKey
126
				)
127
			));
128
		}
129
130
		//set scenario
131
		$this->model->setScenario($this->scenario);
132
133
		//commented to be able to work with virtual attributes
134
		//see https://github.com/vitalets/yii-bootstrap-editable/issues/15
135
		/*
136
		//is attribute exists
137
		if (!$this->model->hasAttribute($this->attribute)) {
138
			throw new CException(Yii::t('EditableSaver.editable', 'Model {class} does not have attribute "{attr}"', array(
139
			  '{class}'=>get_class($this->model), '{attr}'=>$this->attribute)));
140
		}
141
		*/
142
143
		//is attribute safe
144
		if (!$this->model->isAttributeSafe($this->attribute)) {
145
			throw new CException(Yii::t(
146
				'editable',
147
				'Model {class} rules do not allow to update attribute "{attr}"',
148
				array(
149
					'{class}' => get_class($this->model),
150
					'{attr}' => $this->attribute
151
				)
152
			));
153
		}
154
155
		//setting new value
156
		$this->setAttribute($this->attribute, $this->value);
157
158
		//validate attribute
159
		$this->model->validate(array($this->attribute));
160
		$this->checkErrors();
161
162
		//trigger beforeUpdate event
163
		$this->beforeUpdate();
164
		$this->checkErrors();
165
166
		//saving (no validation, only changed attributes)
167
		if ($this->model->save(false, $this->changedAttributes)) {
168
			//trigger afterUpdate event
169
			$this->afterUpdate();
170
		} else {
171
			$this->error(Yii::t('TbEditableSaver.editable', 'Error while saving record!'));
172
		}
173
	}
174
175
	/**
176
	 *### .checkErros()
177
	 *
178
	 * errors as CHttpException
179
	 * @internal param $msg
180
	 * @throws CHttpException
181
	 */
182
	public function checkErrors()
183
	{
184
		if (!$this->model->hasErrors())
185
			return;
186
187
		$msg = array();
188
		foreach ($this->model->getErrors() as $attribute => $errors) {
189
			// TODO: make use of $attribute elements
190
			$msg = array_merge($msg, $errors);
191
		}
192
		$this->error($msg[0]);
193
	}
194
195
	/**
196
	 *### .error()
197
	 *
198
	 * errors as CHttpException
199
	 *
200
	 * @param $msg
201
	 *
202
	 * @throws CHttpException
203
	 */
204
	public function error($msg)
205
	{
206
		throw new CHttpException($this->errorHttpCode, $msg);
207
	}
208
209
	/**
210
	 *### .setAttribute()
211
	 *
212
	 * setting new value of attribute.
213
	 * Attrubute name also stored in array to save only changed attributes
214
	 *
215
	 * @param mixed $name
216
	 * @param mixed $value
217
	 */
218
	public function setAttribute($name, $value)
219
	{
220
		$this->model->$name = $value;
221
		if (!in_array($name, $this->changedAttributes)) {
222
			$this->changedAttributes[] = $name;
223
		}
224
	}
225
226
	/**
227
	 *### .onBeforeUpdate()
228
	 *
229
	 * This event is raised before the update is performed.
230
	 *
231
	 * @param CModelEvent $event the event parameter
232
	 */
233
	public function onBeforeUpdate($event)
234
	{
235
		$this->raiseEvent('onBeforeUpdate', $event);
236
	}
237
238
	/**
239
	 *### .onAfterUpdate()
240
	 *
241
	 * This event is raised after the update is performed.
242
	 *
243
	 * @param CModelEvent $event the event parameter
244
	 */
245
	public function onAfterUpdate($event)
246
	{
247
		$this->raiseEvent('onAfterUpdate', $event);
248
	}
249
250
	/**
251
	 *### .beforeUpdate()
252
	 *
253
	 * beforeUpdate
254
	 *
255
	 */
256
	protected function beforeUpdate()
257
	{
258
		$this->onBeforeUpdate(new CModelEvent($this));
259
	}
260
261
	/**
262
	 *### .afterUpdate()
263
	 *
264
	 * afterUpdate
265
	 *
266
	 */
267
	protected function afterUpdate()
268
	{
269
		$this->onAfterUpdate(new CModelEvent($this));
270
	}
271
}
272