Issues (3948)

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/ProjectPermissionModel.php (13 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
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Model;
13
14
use Jitamin\Filter\ProjectGroupRoleProjectFilter;
15
use Jitamin\Filter\ProjectGroupRoleUsernameFilter;
16
use Jitamin\Filter\ProjectUserRoleProjectFilter;
17
use Jitamin\Filter\ProjectUserRoleUsernameFilter;
18
use Jitamin\Foundation\Database\Model;
19
use Jitamin\Foundation\Security\Role;
20
21
/**
22
 * Project Permission.
23
 */
24
class ProjectPermissionModel extends Model
25
{
26
    /**
27
     * Get query for project users overview.
28
     *
29
     * @param array  $project_ids
30
     * @param string $role
31
     *
32
     * @return \PicoDb\Table
33
     */
34
    public function getQueryByRole(array $project_ids, $role)
35
    {
36
        if (empty($project_ids)) {
37
            $project_ids = [-1];
38
        }
39
40
        return $this
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
41
            ->db
42
            ->table(ProjectUserRoleModel::TABLE)
43
            ->join(UserModel::TABLE, 'id', 'user_id')
44
            ->join(ProjectModel::TABLE, 'id', 'project_id')
45
            ->eq(ProjectUserRoleModel::TABLE.'.role', $role)
46
            ->eq(ProjectModel::TABLE.'.is_private', 0)
47
            ->in(ProjectModel::TABLE.'.id', $project_ids)
48
            ->columns(
49
                UserModel::TABLE.'.id',
50
                UserModel::TABLE.'.username',
51
                UserModel::TABLE.'.name',
52
                ProjectModel::TABLE.'.name AS project_name',
53
                ProjectModel::TABLE.'.id'
54
            );
55
    }
56
57
    /**
58
     * Get all usernames (fetch users from groups).
59
     *
60
     * @param int    $project_id
61
     * @param string $input
62
     *
63
     * @return array
64
     */
65
    public function findUsernames($project_id, $input)
66
    {
67
        $userMembers = $this->projectUserRoleQuery
0 ignored issues
show
The property projectUserRoleQuery does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
68
            ->withFilter(new ProjectUserRoleProjectFilter($project_id))
69
            ->withFilter(new ProjectUserRoleUsernameFilter($input))
70
            ->getQuery()
71
            ->findAllByColumn('username');
72
73
        $groupMembers = $this->projectGroupRoleQuery
0 ignored issues
show
The property projectGroupRoleQuery does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
74
            ->withFilter(new ProjectGroupRoleProjectFilter($project_id))
75
            ->withFilter(new ProjectGroupRoleUsernameFilter($input))
76
            ->getQuery()
77
            ->findAllByColumn('username');
78
79
        $members = array_unique(array_merge($userMembers, $groupMembers));
80
81
        sort($members);
82
83
        return $members;
84
    }
85
86
    /**
87
     * Return true if everybody is allowed for the project.
88
     *
89
     * @param int $project_id Project id
90
     *
91
     * @return bool
92
     */
93
    public function isEverybodyAllowed($project_id)
94
    {
95
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
96
                    ->table(ProjectModel::TABLE)
97
                    ->eq('id', $project_id)
98
                    ->eq('is_everybody_allowed', 1)
99
                    ->exists();
100
    }
101
102
    /**
103
     * Return true if the user is allowed to access a project.
104
     *
105
     * @param int $project_id
106
     * @param int $user_id
107
     *
108
     * @return bool
109
     */
110
    public function isUserAllowed($project_id, $user_id)
111
    {
112
        if ($this->userSession->isAdmin()) {
0 ignored issues
show
The property userSession does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
113
            return true;
114
        }
115
116
        return in_array(
117
            $this->projectUserRoleModel->getUserRole($project_id, $user_id),
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
118
            [Role::PROJECT_MANAGER, Role::PROJECT_MEMBER, Role::PROJECT_VIEWER]
119
        );
120
    }
121
122
    /**
123
     * Return true if the user is assignable.
124
     *
125
     * @param int $project_id
126
     * @param int $user_id
127
     *
128
     * @return bool
129
     */
130
    public function isAssignable($project_id, $user_id)
131
    {
132
        if ($this->userModel->isActive($user_id)) {
0 ignored issues
show
The property userModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
133
            $role = $this->projectUserRoleModel->getUserRole($project_id, $user_id);
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
134
135
            return !empty($role) && $role !== Role::PROJECT_VIEWER;
136
        }
137
138
        return false;
139
    }
140
141
    /**
142
     * Return true if the user is member.
143
     *
144
     * @param int $project_id
145
     * @param int $user_id
146
     *
147
     * @return bool
148
     */
149
    public function isMember($project_id, $user_id)
150
    {
151
        return in_array($this->projectUserRoleModel->getUserRole($project_id, $user_id), [Role::PROJECT_MEMBER, Role::PROJECT_MANAGER, Role::PROJECT_VIEWER]);
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
152
    }
153
154
    /**
155
     * Get active project ids by user.
156
     *
157
     * @param int $user_id
158
     *
159
     * @return array
160
     */
161
    public function getActiveProjectIds($user_id)
162
    {
163
        return array_keys($this->projectUserRoleModel->getActiveProjectsByUser($user_id));
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
164
    }
165
166
    /**
167
     * Get all project ids by user.
168
     *
169
     * @param int $user_id
170
     *
171
     * @return array
172
     */
173
    public function getProjectIds($user_id)
174
    {
175
        return array_keys($this->projectUserRoleModel->getProjectsByUser($user_id));
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
176
    }
177
178
    /**
179
     * Copy permissions to another project.
180
     *
181
     * @param int $project_src_id Project Template
182
     * @param int $project_dst_id Project that receives the copy
183
     *
184
     * @return bool
185
     */
186
    public function duplicate($project_src_id, $project_dst_id)
187
    {
188
        return $this->projectUserRoleModel->duplicate($project_src_id, $project_dst_id) &&
0 ignored issues
show
The property projectUserRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
189
            $this->projectGroupRoleModel->duplicate($project_src_id, $project_dst_id);
0 ignored issues
show
The property projectGroupRoleModel does not exist on object<Jitamin\Model\ProjectPermissionModel>. 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...
190
    }
191
}
192