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

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.

app/models/Permission.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
 /**
4
  * Permission Class
5
  *
6
  * Handles all permissions for accessing resources(usually controllers), and what are the actions a user can perform
7
  *
8
  * This class requires from you to define all permission rules in you PHP code,
9
  * Another approach you could take is to define them in the database,
10
  * But, i find this approach is simpler and less costly at least for this application.
11
  *
12
  * @license    http://opensource.org/licenses/MIT The MIT License (MIT)
13
  * @author     Omar El Gabry <[email protected]>
14
  */
15
16
class Permission {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
18
    /**
19
     * allowed permissions for actions on specific resources
20
     *
21
     * $perms[] = [
22
     *      'role' => 'student', //AROs
23
     *      'resource' => 'Post' //ACOs - actions could be ACOs instead.
24
     *      'actions' => ['edit', 'delete'],
25
     *      'conditions' => ['owner'] - things that you validate against if the user has access to the action
26
     *  ];
27
     *
28
     * @var array
29
     */
30
    public static $perms = [];
31
32
    /**
33
     * check if the $role has access to $action on $resource
34
     *
35
     * @param  string  $role
36
     * @param  string  $resource
37
     * @param  string  $action   if set to "*", then check if $actions parameter was assigned to "*" when using allow() method
38
     *                           This indicates the $role has access to all actions on $resource
39
     * @param  array   $config   configuration data to be passed to condition methods
40
     * @throws Exception if $config is empty or method doesn't exists
41
     * @return boolean
42
     */
43
    public static function check($role, $resource, $action = "*", array $config = []){
44
45
        // checks if action was allowed at least once
46
        $allowed = false;
47
        $action = strtolower($action);
48
49
        foreach(self::$perms as $perm){
50
            if($perm['role'] === $role && $perm['resource'] === $resource){
51
52
                if(in_array($action, $perm["actions"], true) || $perm["actions"] === ["*"]){
53
54
                    $allowed = true;
55
56
                    foreach($perm["conditions"] as $condition){
57
58
                        if (!method_exists(__CLASS__, $condition)) {
59
                            throw new Exception("Permission, Method doesnt exists: " . $condition);
60
                        }
61
62
                        if(self::$condition($config) === false){
63
                            Logger::log("Permission", $role . " is not allowed to perform '" . $action . "' action on " . $resource . " because of " . $condition, __FILE__, __LINE__);
64
                            return false;
65
                        }
66
                    }
67
                }
68
            }
69
        }
70
71
        if(!$allowed){
72
            Logger::log("Permission", $role . " is not allowed to perform '" . $action . "' action on " . $resource, __FILE__, __LINE__);
73
        }
74
75
        return $allowed;
76
    }
77
78
    /**
79
     * Add new rule: allow a $role for $actions on $resource,
80
     * You may add additional $conditions that must be fulfilled as well.
81
     *
82
     * @param  string  $role
83
     * @param  string  $resource
84
     * @param  mixed   $actions
85
     * @param  mixed   $conditions
86
     */
87
    public static function allow($role, $resource, $actions = "*", $conditions = []){
88
89
        $actions = array_map("strtolower", (array)$actions);
90
91
        self::$perms[] = ['role' => $role, 'resource' => $resource, 'actions' => $actions, 'conditions' => (array)$conditions];
92
    }
93
94
    /**
95
     *  deny or remove $actions for a $role on $resource
96
     *
97
     * @param  string  $role
98
     * @param  string  $resource
99
     * @param  mixed   $actions
100
     */
101
    public static function deny($role, $resource, $actions = "*"){
102
103
        $actions = array_map("strtolower", (array)$actions);
104
105
        foreach(self::$perms as $key => &$perm){
106
            if($perm['role'] === $role && $perm['resource'] === $resource){
107
                foreach($perm['actions'] as $index => $action){
108
                    if(in_array($action, $actions, true) || $actions === ["*"]){
109
                        unset($perm['actions'][$index]);
110
                    }
111
                }
112
113
                if(empty($perm['actions'])){
114
                    unset(self::$perms[$key]);
115
                }
116
            }
117
        }
118
    }
119
120
    /** *********************************************** **/
121
    /** **************    Conditions     ************** **/
122
    /** *********************************************** **/
123
124
    /**
125
     * checks if user is owner
126
     *
127
     * @param  array $config
128
     * @return bool
129
     */
130
    private static function owner($config){
131
132
        $database = Database::openConnection();
133
134
        $database->prepare('SELECT * FROM '.$config["table"]. ' WHERE id = :id AND user_id = :user_id LIMIT 1');
135
        $database->bindValue(':id', (int)$config["id"]);
136
        $database->bindValue(':user_id', (int)$config["user_id"]);
137
        $database->execute();
138
139
        return $database->countRows() === 1;
140
    }
141
142
 }
143