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/ColumnRestrictionModel.php (8 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\Foundation\Database\Model;
15
16
/**
17
 * Class ColumnRestrictionModel.
18
 */
19
class ColumnRestrictionModel extends Model
20
{
21
    /**
22
     * SQL table name.
23
     *
24
     * @var string
25
     */
26
    const TABLE = 'column_has_restrictions';
27
28
    const RULE_ALLOW_TASK_CREATION = 'allow.task_creation';
29
    const RULE_ALLOW_TASK_OPEN_CLOSE = 'allow.task_open_close';
30
    const RULE_BLOCK_TASK_CREATION = 'block.task_creation';
31
    const RULE_BLOCK_TASK_OPEN_CLOSE = 'block.task_open_close';
32
33
    /**
34
     * Get rules.
35
     *
36
     * @return array
37
     */
38 View Code Duplication
    public function getRules()
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...
39
    {
40
        return [
41
            self::RULE_ALLOW_TASK_CREATION   => t('Task creation is permitted for this column'),
42
            self::RULE_ALLOW_TASK_OPEN_CLOSE => t('Closing or opening a task is permitted for this column'),
43
            self::RULE_BLOCK_TASK_CREATION   => t('Task creation is blocked for this column'),
44
            self::RULE_BLOCK_TASK_OPEN_CLOSE => t('Closing or opening a task is blocked for this column'),
45
        ];
46
    }
47
48
    /**
49
     * Fetch one restriction.
50
     *
51
     * @param int $project_id
52
     * @param int $restriction_id
53
     *
54
     * @return array|null
55
     */
56
    public function getById($project_id, $restriction_id)
57
    {
58
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ColumnRestrictionModel>. 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...
59
            ->table(self::TABLE)
60
            ->columns(
61
                self::TABLE.'.restriction_id',
62
                self::TABLE.'.project_id',
63
                self::TABLE.'.role_id',
64
                self::TABLE.'.column_id',
65
                self::TABLE.'.rule',
66
                'pr.role',
67
                'c.title as column_title'
68
            )
69
            ->left(ColumnModel::TABLE, 'c', 'id', self::TABLE, 'column_id')
70
            ->left(ProjectRoleModel::TABLE, 'pr', 'role_id', self::TABLE, 'role_id')
71
            ->eq(self::TABLE.'.project_id', $project_id)
72
            ->eq(self::TABLE.'.restriction_id', $restriction_id)
73
            ->findOne();
74
    }
75
76
    /**
77
     * Get all project column restrictions.
78
     *
79
     * @param int $project_id
80
     *
81
     * @return array
82
     */
83
    public function getAll($project_id)
84
    {
85
        $rules = $this->getRules();
86
        $restrictions = $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ColumnRestrictionModel>. 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...
87
            ->table(self::TABLE)
88
            ->columns(
89
                self::TABLE.'.restriction_id',
90
                self::TABLE.'.project_id',
91
                self::TABLE.'.role_id',
92
                self::TABLE.'.column_id',
93
                self::TABLE.'.rule',
94
                'pr.role',
95
                'c.title as column_title'
96
            )
97
            ->left(ColumnModel::TABLE, 'c', 'id', self::TABLE, 'column_id')
98
            ->left(ProjectRoleModel::TABLE, 'pr', 'role_id', self::TABLE, 'role_id')
99
            ->eq(self::TABLE.'.project_id', $project_id)
100
            ->findAll();
101
102
        foreach ($restrictions as &$restriction) {
103
            $restriction['title'] = $rules[$restriction['rule']];
104
        }
105
106
        return $restrictions;
107
    }
108
109
    /**
110
     * Get restrictions.
111
     *
112
     * @param int    $project_id
113
     * @param string $role
114
     *
115
     * @return array
116
     */
117 View Code Duplication
    public function getAllByRole($project_id, $role)
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...
118
    {
119
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ColumnRestrictionModel>. 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...
120
            ->table(self::TABLE)
121
            ->columns(
122
                self::TABLE.'.restriction_id',
123
                self::TABLE.'.project_id',
124
                self::TABLE.'.role_id',
125
                self::TABLE.'.column_id',
126
                self::TABLE.'.rule',
127
                'pr.role'
128
            )
129
            ->eq(self::TABLE.'.project_id', $project_id)
130
            ->eq('pr.role', $role)
131
            ->left(ProjectRoleModel::TABLE, 'pr', 'role_id', self::TABLE, 'role_id')
132
            ->findAll();
133
    }
134
135
    /**
136
     * Create a new column restriction.
137
     *
138
     * @param int $project_id
139
     * @param int $role_id
140
     * @param int $column_id
141
     * @param int $rule
142
     *
143
     * @return bool|int
144
     */
145 View Code Duplication
    public function create($project_id, $role_id, $column_id, $rule)
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...
146
    {
147
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ColumnRestrictionModel>. 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...
148
            ->table(self::TABLE)
149
            ->persist([
150
                'project_id' => $project_id,
151
                'role_id'    => $role_id,
152
                'column_id'  => $column_id,
153
                'rule'       => $rule,
154
            ]);
155
    }
156
157
    /**
158
     * Remove a permission.
159
     *
160
     * @param int $restriction_id
161
     *
162
     * @return bool
163
     */
164
    public function remove($restriction_id)
165
    {
166
        return $this->db->table(self::TABLE)->eq('restriction_id', $restriction_id)->remove();
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\ColumnRestrictionModel>. 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...
167
    }
168
}
169