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.

extensions/jtogglecolumn/JToggleColumn.php (4 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
 * CToggleColumn class file.
4
 * @author Nikola Trifunovic <[email protected]>
5
 * @link http://www.trifunovic.me/
6
 * @copyright Copyright &copy; 2012 Nikola Trifunovic
7
 * @license http://www.yiiframework.com/license/
8
 */
9
class JToggleColumn extends BDataColumn
10
{
11
  /**
12
   * @var string the attribute name of the data model. Used for column sorting, filtering and to render the corresponding
13
   * attribute value in each data cell. If {@link value} is specified it will be used to rendered the data cell instead of the attribute value.
14
   * @see value
15
   * @see sortable
16
   */
17
  public $name;
18
19
  /**
20
   * @var array the HTML options for the data cell tags.
21
   */
22
  public $htmlOptions = array('class' => 'toggle-column');
23
24
  /**
25
   * @var array the HTML options for the header cell tag.
26
   */
27
  public $headerHtmlOptions = array('class' => 'toggle-column');
28
29
  /**
30
   * @var array the HTML options for the footer cell tag.
31
   */
32
  public $footerHtmlOptions = array('class' => 'toggle-column');
33
34
  /**
35
   * @var string the label for the toggle button. Defaults to "toggle".
36
   * Note that the label will not be HTML-encoded when rendering.
37
   */
38
  public $checkedButtonLabel;
39
40
  /**
41
   * @var string the label for the toggle button. Defaults to "toggle".
42
   * Note that the label will not be HTML-encoded when rendering.
43
   */
44
  public $uncheckedButtonLabel;
45
46
  /**
47
   * @var string the image URL for the toggle button. If not set, an integrated image will be used.
48
   * You may set this property to be false to render a text link instead.
49
   */
50
  public $checkedButtonImageUrl;
51
52
  /**
53
   * @var string the image URL for the toggle button. If not set, an integrated image will be used.
54
   * You may set this property to be false to render a text link instead.
55
   */
56
  public $uncheckedButtonImageUrl;
57
58
  /**
59
   * @var array the configuration for toggle button.
60
   */
61
  public $toggle_button = array();
62
63
  /**
64
   * @var boolean whether the column is sortable. If so, the header cell will contain a link that may trigger the sorting.
65
   * Defaults to true. Note that if {@link name} is not set, or if {@link name} is not allowed by {@link CSort},
66
   * this property will be treated as false.
67
   * @see name
68
   */
69
  public $sortable = true;
70
71
  /**
72
   * @var mixed the HTML code representing a filter input (eg a text field, a dropdown list)
73
   * that is used for this data column. This property is effective only when
74
   * {@link CGridView::filter} is set.
75
   * If this property is not set, a text field will be generated as the filter input;
76
   * If this property is an array, a dropdown list will be generated that uses this property value as
77
   * the list options.
78
   * If you don't want a filter for this data column, set this value to false.
79
   * @since 1.1.1
80
   */
81
  public $filter;
82
83
  /**
84
   * @var string Name of the action
85
   */
86
  public $action;
87
88
  /**
89
   * @var string
90
   */
91
  public $ajaxUrl;
92
93
  /**
94
   * @var string Assets url
95
   */
96
  private $_assetsUrl;
97
98
  /**
99
   * Returns assets url, where check and uncheck images are located
100
   * @return string
101
   */
102
  public function getAssetsUrl()
103
  {
104
    if( $this->_assetsUrl === null )
105
      $this->_assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__).'/images');
106
    return $this->_assetsUrl;
107
  }
108
109
  /**
110
   * Initializes the column.
111
   * This method registers necessary client script for the button column.
112
   */
113
  public function init()
114
  {
115
    if( $this->name === null )
116
      $this->sortable = false;
117
    if( $this->name === null )
118
      throw new CException(Yii::t('toggle_column', 'Model attribute ("name") must be specified for CToggleColumn.'));
119
120
    $this->initDefaultButtons();
121
122
    $this->toggle_button['click'] = 'js:'.$this->toggle_button['click'];
123
124
    $this->registerClientScript();
125
  }
126
127
  /**
128
   * Initializes the default buttons (toggle).
129
   */
130
  protected function initDefaultButtons()
131
  {
132
    if( $this->checkedButtonLabel === null )
133
      $this->checkedButtonLabel = Yii::t('toggle_column', 'Выключить');
134
    if( $this->uncheckedButtonLabel === null )
135
      $this->uncheckedButtonLabel = Yii::t('toggle_column', 'Включить');
136
    if( $this->checkedButtonImageUrl === null )
137
      $this->checkedButtonImageUrl = $this->getAssetsUrl().'/toggle-on.png';
138
    if( $this->uncheckedButtonImageUrl === null )
139
      $this->uncheckedButtonImageUrl = $this->getAssetsUrl().'/toggle-off.png';
140
141
    if( $this->action === null )
142
      $this->action = 'toggle';
143
144
    if( !isset($this->toggle_button['htmlOptions']) )
145
      $this->toggle_button['htmlOptions'] = array('rel' => 'tooltip');
146
147
    $this->toggle_button = array(
148
      'url' => $this->ajaxUrl ? $this->ajaxUrl : 'Yii::app()->controller->createUrl("'.$this->action.'", array("id" => $data["primaryKey"], "attribute" => "'.$this->name.'"))',
149
      'options' => CMap::mergeArray(array('class' => $this->name.'_toggle'), $this->toggle_button['htmlOptions']),
150
    );
151
152
    if( Yii::app()->request->enableCsrfValidation )
153
    {
154
      $csrfTokenName = Yii::app()->request->csrfTokenName;
155
      $csrfToken     = Yii::app()->request->csrfToken;
156
      $csrf          = "\n\t\tdata:{ '$csrfTokenName':'$csrfToken' },";
157
    }
158
    else
159
      $csrf = '';
160
161
    $this->toggle_button['click'] = <<<EOD
162
function() {
163
	var th=this;
164
	$.fn.yiiGridView.update('{$this->grid->id}', {
165
		type:'POST',
166
		url:$(this).attr('href'),$csrf
167
		success:function(data) {
168
			$.fn.yiiGridView.update('{$this->grid->id}');
169
		},
170
		ajaxUpdate:true
171
	});
172
	return false;
173
}
174
EOD;
175
  }
176
177
  /**
178
   * Registers the client scripts for the button column.
179
   */
180
  protected function registerClientScript()
181
  {
182
    $js = array();
183
184
    $function = CJavaScript::encode($this->toggle_button['click']);
185
    $class    = preg_replace('/\s+/', '.', $this->toggle_button['options']['class']);
186
    $js[]     = "jQuery('body').on('click', '#{$this->grid->id} a.{$class}', $function);";
187
188
    if( $js !== array() )
189
      Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id, implode("\n", $js));
190
  }
191
192
  /**
193
   * Renders the data cell content.
194
   * This method renders the view, update and toggle buttons in the data cell.
195
   *
196
   * @param integer $row the row number (zero-based)
197
   * @param mixed   $data the data associated with the row
198
   */
199
  protected function renderDataCellContent($row, $data)
200
  {
201
    ob_start();
202
    $this->renderButton($this->toggle_button, $row, $data);
203
    $toggle_button = ob_get_contents();
204
    ob_clean();
205
    ob_end_clean();
206
    echo $toggle_button;
207
  }
208
209
  /**
210
   * Renders the header cell content.
211
   * This method will render a link that can trigger the sorting if the column is sortable.
212
   */
213
  protected function renderHeaderCellContent()
214
  {
215
    if( $this->grid->enableSorting && $this->sortable && $this->name !== null )
216
      echo $this->grid->dataProvider->getSort()->link($this->name, $this->header);
217 View Code Duplication
    else if( $this->name !== null && $this->header === null )
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...
218
    {
219
      if( $this->grid->dataProvider instanceof CActiveDataProvider )
0 ignored issues
show
The class CActiveDataProvider does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
220
        echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
221
      else
222
        echo CHtml::encode($this->name);
223
    }
224
    else
225
      parent::renderHeaderCellContent();
226
  }
227
228
  /**
229
   * Renders a toggle button.
230
   *
231
   * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements.
232
   * @param integer $row the row number (zero-based)
233
   * @param mixed $data the data object associated with the row
234
   *
235
   * @internal param string $id the ID of the button
236
   */
237
  protected function renderButton($button, $row, $data)
238
  {
239
    if( $this->name !== null )
240
      $checked = CHtml::value($data, $this->name);
241
242
    $button['imageUrl'] = $checked ? $this->checkedButtonImageUrl : $this->uncheckedButtonImageUrl;
0 ignored issues
show
The variable $checked does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
243
    $button['label']    = $checked ? $this->checkedButtonLabel : $this->uncheckedButtonLabel;
244
245
    $label   = $button['label'];
246
    $url     = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#';
247
    $options = isset($button['options']) ? $button['options'] : array();
248
    if( !isset($options['title']) )
249
      $options['title'] = $label;
250 View Code Duplication
    if( isset($button['imageUrl']) && is_string($button['imageUrl']) )
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...
251
      echo CHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options);
252
    else
253
      echo CHtml::link($label, $url, $options);
254
  }
255
256
  /**
257
   * Renders the filter cell content.
258
   * This method will render the {@link filter} as is if it is a string.
259
   * If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered.
260
   * Otherwise if {@link filter} is not false, a text field is rendered.
261
   * @since 1.1.1
262
   */
263
  protected function renderFilterCellContent()
264
  {
265
    if( $this->filter !== null )
266
    {
267
      if( is_string($this->filter) )
268
        echo $this->filter;
269
      else if( $this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false )
270
      {
271
        echo CHtml::activeLabelEx($this->grid->filter, $this->name, array('id' => false));
272
273
        if( is_array($this->filter) )
274
          echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => ''));
275
        else if( $this->filter === null )
276
          echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false));
277
      }
278
      else
279
        parent::renderFilterCellContent();
280
    }
281
  }
282
283
  protected function renderFilterDivContent()
284
  {
285
    if( is_string($this->filter) )
286
      echo $this->filter;
287
    else if( $this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false )
288
    {
289
      echo CHtml::activeLabel($this->grid->filter, $this->name, array('id' => false));
290
      echo CHtml::activeDropDownList($this->grid->filter, $this->name, CHtml::listData($this->grid->filter->yesNoList(), 'id', 'name'), array('id' => false, 'prompt' => ''));
291
    }
292
  }
293
}