Issues (159)

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/Documents/Document.php (4 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
 * Storgman - Student Organizations Management
5
 * Copyright (C) 2014-2016, Dejan Angelov <[email protected]>
6
 *
7
 * This file is part of Storgman.
8
 *
9
 * Storgman is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Storgman is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with Storgman.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 * @package Storgman
23
 * @copyright Copyright (C) 2014-2016, Dejan Angelov <[email protected]>
24
 * @license https://github.com/angelov/storgman/blob/master/LICENSE
25
 * @author Dejan Angelov <[email protected]>
26
 */
27
28
namespace Angelov\Storgman\Documents;
29
30
use Angelov\Storgman\Members\Member;
31
use Angelov\Storgman\Documents\Tags\Tag;
32
use Illuminate\Database\Eloquent\Model;
33
34
class Document extends Model
35
{
36
    protected $table = "documents";
37
38
    protected $tagList = [];
39
    protected $openedByList = [];
40
41
    public function getId()
42
    {
43
        return $this->getAttribute('id');
44
    }
45
46
    public function getTitle()
47
    {
48
        return $this->getAttribute('title');
49
    }
50
51
    public function setTitle($title)
52
    {
53
        $this->setAttribute('title', $title);
54
    }
55
56
    public function getDescription()
57
    {
58
        return $this->getAttribute('description');
59
    }
60
61
    public function setDescription($description)
62
    {
63
        $this->setAttribute('description', $description);
64
    }
65
66
    public function getUrl()
67
    {
68
        return $this->getAttribute('url');
69
    }
70
71
    public function setUrl($url)
72
    {
73
        $this->setAttribute('url', $url);
74
    }
75
76
    public function submitter()
77
    {
78
        return $this->belongsTo(Member::class, 'submitted_by');
79
    }
80
81
    /**
82
     * @return Member
83
     */
84
    public function getSubmitter()
85
    {
86
        return $this->submitter;
0 ignored issues
show
The property submitter does not exist on object<Angelov\Storgman\Documents\Document>. 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
    }
88
89
    /**
90
     * @param Member $member
91
     */
92
    public function setSubmitter(Member $member)
93
    {
94
        $this->submitter()->associate($member);
95
    }
96
97
    public function openedBy()
98
    {
99
        return $this->belongsToMany(Member::class, 'document_openings')->withTimestamps();
100
    }
101
102
    public function addOpener(Member $member)
103
    {
104
        $this->openedByList[] = $member;
105
    }
106
107
    /**
108
     * @return Member[]
109
     */
110
    public function getOpeners()
111
    {
112
        return $this->openedBy->all();
0 ignored issues
show
The property openedBy does not seem to exist. Did you mean openedByList?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
113
    }
114
115
    public function countOpenings()
116
    {
117
        return $this->openedBy->count();
0 ignored issues
show
The property openedBy does not seem to exist. Did you mean openedByList?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
118
    }
119
120
    public function countOpeners()
121
    {
122
        $openers = $this->getOpeners();
123
        $counted = [];
124
125
        foreach ($openers as $opener) {
126
            if (! in_array($opener->getId(), $counted)) {
127
                $counted[] = $opener->getId();
128
            }
129
        }
130
131
        return count($counted);
132
    }
133
134
    public function tags()
135
    {
136
        return $this->belongsToMany(Tag::class);
137
    }
138
139
    /**
140
     * @param Tag $tag
141
     */
142
    public function addTag(Tag $tag)
143
    {
144
        $this->tagList[] = $tag;
145
    }
146
147
    /**
148
     * @return Tag[]
149
     */
150
    public function getTags()
151
    {
152
        return $this->tags;
0 ignored issues
show
The property tags does not exist on object<Angelov\Storgman\Documents\Document>. 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...
153
    }
154
155
    /**
156
     * @return \DateTime
157
     */
158
    public function getCreatedAt()
159
    {
160
        return $this->getAttribute('created_at');
161
    }
162
163
    /**
164
     * @return \DateTime
165
     */
166
    public function getUpdatedAt()
167
    {
168
        return $this->getAttribute('updated_at');
169
    }
170
171
    /**
172
     * By default, all members have access to the document
173
     */
174
    public function setVisibleToAllMembers()
175
    {
176
        $this->setAttribute('board_only', false);
177
    }
178
179
    /**
180
     * @return bool
181
     */
182
    public function isVisibleToAllMembers()
183
    {
184
        return (! $this->getAttribute('board_only'));
185
    }
186
187
    public function setVisibleToBoardOnly()
188
    {
189
        $this->setAttribute('board_only', true);
190
    }
191
192
    public function save(array $options = [])
193
    {
194
        parent::save($options);
195
196
        foreach ($this->tagList as $tag) {
197
            $this->tags()->attach($tag);
198
        }
199
200
        foreach ($this->openedByList as $opener) {
201
            $this->openedBy()->attach($opener);
202
        }
203
    }
204
}
205