Issues (125)

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/Services/SettingsManager.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
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
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 Tinyissue\Services;
13
14
use Illuminate\Support\Collection;
15
use Tinyissue\Model\Setting;
16
17
/**
18
 * SettingsManager singleton class to maintain a collection of all settings.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property int $id
23
 * @property string $name
24
 * @property string $value
25
 * @property string $key
26
 */
27
class SettingsManager extends Collection
28
{
29 63
    public function __construct($items = [])
30
    {
31 63
        parent::__construct($items);
32 63
        $this->load();
33 63
    }
34
35
    /**
36
     * Load all settings.
37
     *
38
     * @return \Illuminate\Database\Eloquent\Collection|bool
39
     */
40 73
    protected function load()
41
    {
42 73
        if ($this->count() === 0) {
43
            // Skip exception if table does not exists
44
            // This method called from RouteServiceProvider, which is called within command line 'artisan migrate'
45
            // before the table exists.
46
            try {
47 64
                $items       = Setting::all();
48 64
                $this->items = is_array($items) ? $items : $this->getArrayableItems($items);
49
            } catch (\Exception $e) {
50
                return false;
51
            }
52
        }
53
54 73
        return $this;
55
    }
56
57
    /**
58
     * Returns a setting value.
59
     *
60
     * @param string     $name
61
     * @param mixed|null $default
62
     *
63
     * @return mixed
64
     */
65 73
    public function get($name, $default = null)
66
    {
67 73
        if ($this->load()) {
68 73
            foreach ($this->all() as $setting) {
69 73
                if ($setting->key === $name) {
70 73
                    return $setting->value;
71
                }
72
            }
73
        }
74
75 1
        return $default;
76
    }
77
78
    /**
79
     * Whether or not the public projects enabled.
80
     *
81
     * @return bool
82
     */
83 63
    public function isPublicProjectsEnabled()
84
    {
85 63
        return (boolean) $this->get('enable_public_projects') === true;
86
    }
87
88
    /**
89
     * Returns date format.
90
     *
91
     * @return string
92
     */
93 33
    public function getDateFormat()
94
    {
95 33
        return (string) $this->get('date_format');
96
    }
97
98
    /**
99
     * Returns first status tag id.
100
     *
101
     * @return int
102
     */
103 37
    public function getFirstStatusTagId()
104
    {
105 37
        return (string) $this->get('first_status_tag');
106
    }
107
108
    /**
109
     * Returns users default language.
110
     *
111
     * @return string
112
     */
113 5
    public function getLanguage()
114
    {
115 5
        return (string) $this->get('language');
116
    }
117
118
    /**
119
     * Save a collection of settings.
120
     *
121
     * @param $values
122
     *
123
     * @return bool
124
     */
125 7
    public function save($values)
126
    {
127 7
        foreach ($values as $name => $value) {
128 7
            $settings = new Setting();
129 7
            $setting  = $settings->where('key', '=', $name)->first();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Tinyissue\Model\Setting>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

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 { }
Loading history...
130 7
            if ($setting) {
131 7
                $setting->value = $value;
132 7
                $setting->save();
133
            }
134 7
            unset($settings, $setting);
135
        }
136
137
        // Reload items
138 7
        $this->items = [];
139 7
        $this->load();
140
141 7
        return true;
142
    }
143
}
144