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/models/menu/Menu.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
 * @author Nikita Melnikov <[email protected]>, 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.models.menu
8
 *
9
 * @method static Menu model(string $class = __CLASS__)
10
 *
11
 * @property int $id
12
 * @property string $name
13
 * @property string $sysname
14
 * @property string $url
15
 * @property int $visible
16
 *
17
 * @property MenuItem[] $items
18
 */
19
class Menu extends FActiveRecord implements IMenuItem
20
{
21
  protected $depth;
22
23
  /**
24
   * @var FActiveRecord[]|IMenuItem[]
25
   */
26
  protected $models;
27
28 9
  public function defaultScope()
29
  {
30
    return array(
31
      'with' => 'items'
32 9
    );
33
  }
34
35 1
  public function relations()
36
  {
37
    return array(
38 1
      'items' => array(self::HAS_MANY, 'MenuItem', 'menu_id', 'order' => 'items.position, items.id'),
39 1
    );
40
  }
41
42
  /**
43
   * Получение массива элементов меню по системному имени
44
   *
45
   * @param string $sysname
46
   * @param integer $depth
47
   *
48
   * @return array
49
   */
50 9
  public function getMenu($sysname, $depth = null)
51
  {
52 9
    $data = array();
53
54
    /**
55
     * @var Menu $menu
56
     */
57
58 9
    $menu = $this->findByAttributes(array('sysname' => $sysname));
59
60
    if( $menu )
61 9
    {
62 9
      $menu->setDepth($depth);
63 9
      $data = $menu->build();
64 9
    }
65
66 9
    return $data;
67
  }
68
69
  /**
70
   * @return array
71
   */
72 9
  public function build()
73
  {
74 9
    $data = array();
75 9
    $this->loadModels();
76
77 9
    foreach($this->items as $item)
78
    {
79 9
      if( $this->depth === 0 )
80 9
        continue;
81
82 9
      $item->setDepth($this->depth - 1);
83 9
      $data[] = $this->buildItem($item);
84 9
    }
85
86 9
    return $data;
87
  }
88
89
  /**
90
   * @param int $depth
91
   */
92 9
  public function setDepth($depth = null)
93
  {
94 9
    if( isset($depth) )
95 9
    {
96 1
      $this->depth = $depth;
97 1
    }
98 9
  }
99
100
  /**
101
   * @return array
102
   */
103 9
  public function getMenuUrl()
104
  {
105 9
    if( empty($this->url) )
106 9
      return '';
0 ignored issues
show
Bug Best Practice introduced by
The return type of return ''; (string) is incompatible with the return type declared by the interface IMenuItem::getMenuUrl of type array.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
107
108 View Code Duplication
    if( substr($this->url, 0, 1) === '/' && substr($this->url, -1, 1) === '/' )
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...
109
      return $this->url;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->url; (string) is incompatible with the return type declared by the interface IMenuItem::getMenuUrl of type array.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
110
    else
111
      return array($this->url);
112
  }
113
114
  /**
115
   * @return array
116
   */
117 9
  public function getChildren()
118
  {
119 9
    return $this->build();
120
  }
121
122
  /**
123
   * @return string
124
   */
125 9
  public function getName()
126
  {
127 9
    return $this->name;
128
  }
129
130 9
  protected function buildItem(MenuItem $item)
131
  {
132 9
    $model = preg_replace("/([A-Z][a-z]+)\w*/", "$1", $item->frontend_model);
133
134
    return array(
135 9
      'label' => $item->getName(),
0 ignored issues
show
Consider using $item->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
136 9
      'url'   => $item->getMenuUrl(),
137 9
      'items' => $item->getChildren(),
138
      'itemOptions' => array(
139 9
        'class' => 'icn-menu-'.strtolower($model).$item->item_id
140 9
      ),
141 9
    );
142
  }
143
144 9
  protected function loadModels()
145
  {
146 9
    if( $this->models === null )
147 9
    {
148 9
      $this->models = array();
149 9
      $loadedModels = CHtml::listData($this->items, 'item_id', 'item_id', 'frontend_model');
150
151 9
      foreach($loadedModels as $modelClass => $modelPk)
152
      {
153
        /**
154
         * @var FActiveRecord $model
155
         */
156 9
        $model = $modelClass::model();
157 9
        $this->models = CMap::mergeArray($this->models, $model->findAllByPk($modelPk));
158 9
      }
159
160 9
      $this->setModels();
161 9
    }
162 9
  }
163
164 9
  protected function setModels()
165
  {
166 9
    foreach($this->models as $model)
167
    {
168 9
      foreach($this->items as $menuItem)
169
      {
170 9
        if( $menuItem->item_id === $model->getPrimaryKey() && $menuItem->frontend_model === get_class($model) )
171 9
        {
172 9
          $menuItem->setModel($model);
173 9
          $model->setDepth(isset($this->depth) ? $this->depth - 1 : null);
174 9
          break;
175
        }
176 9
      }
177 9
    }
178
  }
179
}