This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 Gitamin. |
||
5 | * |
||
6 | * Copyright (C) 2015-2016 The Gitamin 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 | # == Schema Information |
||
0 ignored issues
–
show
|
|||
13 | # |
||
14 | # Table name: projects |
||
15 | # |
||
16 | # id :integer not null, primary key |
||
17 | # name :string(255) |
||
18 | # path :string(255) |
||
19 | # description :text |
||
20 | # created_at :timestamp |
||
21 | # updated_at :timestamp |
||
22 | # creator_id :integer |
||
23 | # issues_enabled :boolean default(TRUE), not null |
||
24 | # wall_enabled :boolean default(TRUE), not null |
||
25 | # pull_requests_enabled :boolean default(TRUE), not null |
||
26 | # wiki_enabled :boolean default(TRUE), not null |
||
27 | # owner_id :integer |
||
28 | # issues_tracker :string(255) default("gitlab"), not null |
||
29 | # issues_tracker_id :string(255) |
||
30 | # snippets_enabled :boolean default(TRUE), not null |
||
31 | # last_activity_at :timestamp |
||
32 | # import_url :string(255) |
||
33 | # visibility_level :integer default(0), not null |
||
34 | # archived :boolean default(FALSE), not null |
||
35 | # avatar :string(255) |
||
36 | # import_status :string(255) |
||
37 | # repository_size :float default(0.0) |
||
38 | # star_count :integer default(0), not null |
||
39 | # import_type :string(255) |
||
40 | # import_source :string(255) |
||
41 | # commit_count :integer default(0) |
||
42 | # |
||
43 | |||
44 | namespace Gitamin\Models; |
||
45 | |||
46 | use AltThree\Validator\ValidatingTrait; |
||
47 | use Gitamin\Presenters\ProjectPresenter; |
||
48 | use Gitamin\Presenters\Traits\HasVisibilities; |
||
49 | use Illuminate\Database\Eloquent\Builder; |
||
50 | use Illuminate\Database\Eloquent\Model; |
||
51 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
52 | use McCool\LaravelAutoPresenter\HasPresenter; |
||
53 | |||
54 | class Project extends Model implements HasPresenter |
||
55 | { |
||
56 | use SoftDeletes, ValidatingTrait, HasVisibilities; |
||
57 | |||
58 | /** |
||
59 | * List of attributes that have default values. |
||
60 | * |
||
61 | * @var mixed[] |
||
62 | */ |
||
63 | protected $attributes = [ |
||
64 | 'owner_id' => 0, |
||
65 | 'description' => '', |
||
66 | 'path' => '', |
||
67 | 'creator_id' => 0, |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * The attributes that should be casted to native types. |
||
72 | * |
||
73 | * @var string[] |
||
74 | */ |
||
75 | protected $casts = [ |
||
76 | 'id' => 'int', |
||
77 | 'owner_id' => 'int', |
||
78 | 'description' => 'string', |
||
79 | 'path' => 'string', |
||
80 | 'issues_enabled' => 'boolean', |
||
81 | 'creator_id' => 'int', |
||
82 | 'deleted_at' => 'date', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * The fillable properties. |
||
87 | * |
||
88 | * @var string[] |
||
89 | */ |
||
90 | protected $fillable = [ |
||
91 | 'name', |
||
92 | 'description', |
||
93 | 'visibility_level', |
||
94 | 'tags', |
||
95 | 'path', |
||
96 | 'issues_enabled', |
||
97 | 'creator_id', |
||
98 | 'owner_id', |
||
99 | ]; |
||
100 | |||
101 | /** |
||
102 | * The validation rules. |
||
103 | * |
||
104 | * @var string[] |
||
105 | */ |
||
106 | public $rules = [ |
||
107 | 'name' => 'required|string', |
||
108 | 'visibility_level' => 'int|required', |
||
109 | 'path' => 'required|string|max:15', |
||
110 | ]; |
||
111 | |||
112 | /** |
||
113 | * Projects can belong to a group. |
||
114 | * |
||
115 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
116 | */ |
||
117 | public function owner() |
||
118 | { |
||
119 | return $this->belongsTo(Group::class, 'owner_id', 'id'); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Projects can belong to a creator. |
||
124 | * |
||
125 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
126 | */ |
||
127 | public function creator() |
||
128 | { |
||
129 | return $this->belongsTo(User::class, 'creator_id', 'id'); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Lookup all of the issues reported on the project. |
||
134 | * |
||
135 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
136 | */ |
||
137 | public function issues() |
||
138 | { |
||
139 | return $this->hasMany(Issue::class, 'project_id', 'id'); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Projects can have many tags. |
||
144 | * |
||
145 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
146 | */ |
||
147 | public function tags() |
||
148 | { |
||
149 | return $this->belongsToMany(Tag::class); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Find by owner_path & project_path, or throw an exception. |
||
154 | * |
||
155 | * @param string $owner_path |
||
156 | * @param string $project_path |
||
157 | * @param string[] $columns |
||
158 | * |
||
159 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
160 | * |
||
161 | * @return \Gitamin\Models\User |
||
162 | */ |
||
163 | public static function findByPath($owner_path, $project_path, $columns = ['*']) |
||
164 | { |
||
165 | $project = Owner::findByPath($owner_path)->project($project_path, $columns); |
||
0 ignored issues
–
show
The method
project does not exist on object<Gitamin\Models\User> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
166 | /* Another way |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
65% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
167 | $project = static::leftJoin('owners', function ($join) { |
||
168 | $join->on('projects.owner_id', '=', 'owners.id'); |
||
169 | })->where('projects.path', '=', $project_path)->where('owners.path', '=', $owner_path)->first($columns); |
||
170 | */ |
||
171 | if (! $project) { |
||
172 | throw new ModelNotFoundException(); |
||
173 | } |
||
174 | |||
175 | return $project; |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Finds all projects by visibility_level. |
||
180 | * |
||
181 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
182 | * @param int $visibility_level |
||
183 | * |
||
184 | * @return \Illuminate\Database\Eloquent\Builder |
||
185 | */ |
||
186 | public function scopeVisibilityLevel(Builder $query, $visibility_level) |
||
187 | { |
||
188 | return $query->where('visibility_level', $visibility_level); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Finds all projects which don't have the given visibility_level. |
||
193 | * |
||
194 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
195 | * @param int $visibility_level |
||
196 | * |
||
197 | * @return \Illuminate\Database\Eloquent\Builder |
||
198 | */ |
||
199 | public function scopeNotVisibilityLevel(Builder $query, $visibility_level) |
||
200 | { |
||
201 | return $query->where('visibility_level', '<>', $visibility_level); |
||
202 | } |
||
203 | |||
204 | /** |
||
205 | * Looks up the human readable version of the visibility_level. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getHumanVisibilityLevelAttribute() |
||
210 | { |
||
211 | return trans('gitamin.projects.status.'.$this->visibility_level); |
||
0 ignored issues
–
show
The property
visibility_level does not exist on object<Gitamin\Models\Project> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
212 | } |
||
213 | |||
214 | /** |
||
215 | * Returns project route. |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function getUrlAttribute() |
||
220 | { |
||
221 | return route('projects.project_show', ['owner' => $this->owner_path, 'project' => $this->path]); |
||
0 ignored issues
–
show
The property
owner_path does not exist on object<Gitamin\Models\Project> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() The property
path does not exist on object<Gitamin\Models\Project> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
222 | } |
||
223 | |||
224 | /** |
||
225 | * Returns project owner path. |
||
226 | * |
||
227 | * @return string |
||
228 | */ |
||
229 | public function getOwnerPathAttribute() |
||
230 | { |
||
231 | return $this->owner->path; |
||
0 ignored issues
–
show
The property
owner does not exist on object<Gitamin\Models\Project> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Returns all of the tags on this project. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | public function getTagsListAttribute() |
||
240 | { |
||
241 | $tags = $this->tags->map(function ($tag) { |
||
0 ignored issues
–
show
The property
tags does not exist on object<Gitamin\Models\Project> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
242 | return $tag->name; |
||
243 | }); |
||
244 | |||
245 | return implode(', ', $tags->toArray()); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * Get the presenter class. |
||
250 | * |
||
251 | * @return string |
||
252 | */ |
||
253 | public function getPresenterClass() |
||
254 | { |
||
255 | return ProjectPresenter::class; |
||
256 | } |
||
257 | } |
||
258 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.