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/widgets/DateIntervalWidget.php (3 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
 * @author Sergey Glagolev <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package frontend.widgets
8
 * Пример использования в формах
9
 * <div>
10
 * 'elements' => array(
11
 *   ...
12
 *   'birthday' => array(
13
 *     'type' => 'DateIntervalWidget',
14
 *     'form' => $this,
15
 *     'template' => '<span class="select-container form-size-third date-select">{day}</span>
16
 *                    <span class="select-container form-size-third date-select">{month}</span>
17
 *                    <span class="select-container form-size-third date-select">{year}</span>',
18
 *     'attribute' => 'birthday',
19
 *     'rangeYears' => array(intval(date("Y"))-100, intval(date("Y"))-5),
20
 *   ),
21
 *   ...
22
 * ),
23
 *
24
 * или
25
 *
26
 * 'elements' => array(
27
 *   ...
28
 *   'birthday' => array(
29
 *     'type' => 'DateIntervalWidget',
30
 *     'form' => $this,
31
 *     'layout' => '{input}'
32
 *     'template' => '<div class="form-row m20">{label}<div class="form-field">
33
 *                     <span class="select-container form-size-third date-select">{day}</span>
34
 *                     <span class="select-container form-size-third date-select">{month}</span>
35
 *                     <span class="select-container form-size-third date-select">{year}</span>
36
 *                    {error}</div></div>',
37
 *     'attribute' => 'birthday',
38
 *     'rangeYears' => array(intval(date("Y"))-100, intval(date("Y"))-5),
39
 *   ),
40
 *   ...
41
 * ),
42
 * </div>
43
 */
44
class DateIntervalWidget extends CWidget
45
{
46
  public $model;
47
48
  public $attribute;
49
50
  /**
51
   * @var FForm
52
   */
53
  public $form;
54
55
  public $rangeYears;
56
57
  /**
58
   * @var FFormInputElement
59
   */
60
  public $element;
61
62
  public $hideCalendar = true;
63
64
  public $template = '{day}{month}{year}{calendar}{input}{error}';
65
66
  /**
67
   * @var DateTime
68
   */
69
  private $selectData;
70
71 1
  public function init()
72
  {
73 1
    if( empty($this->rangeYears) )
74 1
      $this->rangeYears = array(intval(date("Y")), intval(date("Y")) + 1);
75
76 1
    if( isset($this->form->elements[$this->attribute]) )
77 1
      $this->element = $this->form->elements[$this->attribute];
78
79 1
    $this->selectData = DateTime::createFromFormat('d.m.Y', $this->model->{$this->attribute});
0 ignored issues
show
Documentation Bug introduced by
It seems like \DateTime::createFromFor...el->{$this->attribute}) can also be of type false. However, the property $selectData is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
80 1
  }
81
82 1
  public function run()
83
  {
84 1
    echo strtr($this->template, array(
85 1
      '{label}' => $this->element->getLabel(),
86 1
      '{day}' => $this->getDays(),
87 1
      '{month}' => $this->renderMonths(),
88 1
      '{year}' => $this->renderYears(),
89 1
      '{calendar}' => $this->renderCalendar(),
90 1
      '{error}' => $this->errorInMainLayout() ? '' : $this->renderError(),
91 1
    ));
92 1
    echo $this->renderInput();
93
94 1
    $this->registerScript();
95 1
  }
96
97 1
  private function renderInput()
98
  {
99 1
    $defaultData = !empty($this->form->model->{$this->attribute}) ? $this->form->model->{$this->attribute} : null;
100
101 1
    return CHtml::hiddenField(CHtml::resolveName($this->model, $this->attribute), $defaultData);
102
  }
103
104
  private function renderError()
105
  {
106
    return $this->form->getActiveFormWidget()->error($this->form->model, $this->attribute);
107
  }
108
109 1
  private function renderCalendar()
110
  {
111 1
    $this->registerCalendarScript();
112
113 1
    return CHtml::tag('div', array('class' => 'calendar m5', 'style' => $this->hideCalendar ? 'display: none;' : ''), true);
114
  }
115
116 1
  private function getDays()
117
  {
118 1
    $selectedValue = $this->selectData ? intval($this->selectData->format('d')) : null;
119 1
    return CHtml::dropDownList('day', $selectedValue, $this->valToKeys(range(1, 31)), array('class' => $this->getElementCssClass()));
120
  }
121
122 1
  private function renderMonths()
123
  {
124 1
    $selectedValue = $this->selectData ? intval($this->selectData->format('m')) : null;
125 1
    return CHtml::dropDownList('month', $selectedValue, Yii::app()->locale->getMonthNames(), array('class' => $this->getElementCssClass()));
126
  }
127
128 1
  private function renderYears()
129
  {
130 1
    $selectedValue = $this->selectData ? $this->selectData->format('Y') : null;
131 1
    return CHtml::dropDownList('year', $selectedValue, $this->valToKeys(range($this->rangeYears[0], $this->rangeYears[1])), array('class' => $this->getElementCssClass()));
132
  }
133
134 1
  private function getElementCssClass()
135
  {
136 1
    return CHtml::activeId($this->model, $this->attribute).'_element';
137
  }
138
139 1
  private function getAttributeId()
140
  {
141 1
    return CHtml::getIdByName(CHtml::resolveName($this->model, $this->attribute));
142
  }
143
144 1
  private function valToKeys($array)
145
  {
146 1
    $newArray = array();
147
148 1
    foreach($array as $value)
149 1
      $newArray[$value] = $value;
150
151 1
    return $newArray;
152
  }
153
154 1
  private function errorInMainLayout()
155
  {
156 1
    return strpos($this->element->getLayout(), '{error}') !== false;
157
  }
158
159 1 View Code Duplication
  private function registerCalendarScript()
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...
160
  {
161 1
    Yii::app()->clientScript->registerScript(__CLASS__.__METHOD__, "
162
    
163
    if( $('.calendar').length )
164
    {
165
      $('.calendar').datePicker({inline:true}).bind('dateSelected', function(e, selectedDate) {
166 1
          var selector = '.".$this->getElementCssClass()."';
167
          $(selector + '[name=day]').val(selectedDate.getDate()).trigger('change');
168
          $(selector + '[name=month]').val(selectedDate.getMonth() + 1).trigger('change');
169
          $(selector + '[name=year]').val(selectedDate.getFullYear()).trigger('change');
170
171 1
          $('#".$this->getAttributeId()."').val(selectedDate.asString('dd.mm.yyyy')).trigger('change');
172
        });
173
    }
174 1
    ");
175 1
  }
176
177 1 View Code Duplication
  private function registerScript()
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...
178
  {
179 1
    Yii::app()->clientScript->registerScript(__CLASS__.__METHOD__, "
180 1
      $('.".$this->getElementCssClass()."').on('change', function(e) {
181 1
        var selector = '.".$this->getElementCssClass()."';
182
        var date = new Date(
183
          $(selector + '[name=year]').val(),
184
          $(selector + '[name=month]').val() - 1,
185
          $(selector + '[name=day]').val()
186
        );
187
188 1
        $('#".$this->getAttributeId()."').val(date.asString('dd.mm.yyyy')).trigger('change');
189
      });
190 1
    ");
191
  }
192
}