Issues (685)

Security Analysis    no request data  

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/View/Helper/AclHelper.php (5 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
namespace App\View\Helper;
3
4
use Acl\Auth\ActionsAuthorize;
5
use Acl\Controller\Component\AclComponent;
6
use Cake\Controller\ComponentRegistry;
7
use Cake\Network\Request;
8
use Cake\Routing\Router;
9
use Cake\View\Helper;
10
use Cake\View\View;
11
12
class AclHelper extends Helper
13
{
14
15
    /**
16
     * Helpers used.
17
     *
18
     * @var array
19
     */
20
    public $helpers = ['Html'];
21
22
    /**
23
     * Acl Instance.
24
     *
25
     * @var object
26
     */
27
    public $Acl;
28
29
    /**
30
     * ActionsAuthorize Instance.
31
     *
32
     * @var object
33
     */
34
    public $Authorize;
35
36
    /**
37
     * Construct method.
38
     *
39
     * @param \Cake\View\View $view The view that was fired.
40
     * @param array $config The config passed to the class.
41
     */
42
    public function __construct(View $view, $config = [])
43
    {
44
        parent::__construct($view, $config);
45
46
        $collection = new ComponentRegistry();
47
        $this->Acl = new AclComponent($collection);
48
49
        $this->Authorize = new ActionsAuthorize($collection);
50
        $this->Authorize->config($this->config());
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Core\InstanceConfigTrait::config() has been deprecated with message: 3.4.0 use setConfig()/getConfig() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
51
    }
52
53
    /**
54
     * Check if the user can access to the given URL.
55
     *
56
     * @param array $params The params to check.
57
     *
58
     * @return bool
59
     */
60
    public function check(array $params = [])
61
    {
62
        if (!$this->request->session()->read('Auth.User')) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->request->session()->read('Auth.User') of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
63
            return false;
64
        }
65
66
        $params += ['_base' => false];
67
68
        $url = Router::url($params);
69
        $params = Router::parse($url);
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Routing\Router::parse() has been deprecated with message: 3.4.0 Use Router::parseRequest() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
70
71
        $user = [$this->Authorize->config('userModel') => $this->request->session()->read('Auth.User')];
72
73
        $request = new Request();
74
        $request->addParams($params);
75
76
        $action = $this->Authorize->action($request);
77
78
        return $this->Acl->check($user, $action);
79
    }
80
81
    /**
82
     * Generate the link only if the user has access to the given url.
83
     *
84
     * @param string $title The content to be wrapped by <a> tags.
85
     * @param string|array|null $url Cake-relative URL or array of URL parameters, or
86
     * external URL (starts with http://)
87
     * @param array $options Array of options and HTML attributes.
88
     *
89
     * @return string
90
     */
91
    public function link($title, $url = null, array $options = [])
92
    {
93
        if (!$this->check($url)) {
0 ignored issues
show
It seems like $url defined by parameter $url on line 91 can also be of type null or string; however, App\View\Helper\AclHelper::check() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
94
            return '';
95
        }
96
97
        return $this->Html->link($title, $url, $options);
0 ignored issues
show
The property Html does not exist on object<App\View\Helper\AclHelper>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
98
    }
99
}
100