Issues (1191)

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.

src/Application/Application.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 namespace Anomaly\Streams\Platform\Application;
2
3
use Illuminate\Foundation\Bus\DispatchesJobs;
4
5
/**
6
 * Class Application
7
 *
8
 * @link    http://pyrocms.com/
9
 * @author  PyroCMS, Inc. <[email protected]>
10
 * @author  Ryan Thompson <[email protected]>
11
 */
12
class Application
13
{
14
15
    use DispatchesJobs;
16
17
    /**
18
     * The application locale.
19
     *
20
     * @var string
21
     */
22
    protected $locale = null;
23
24
    /**
25
     * The enabled state of the application.
26
     *
27
     * @var bool
28
     */
29
    protected $enabled = null;
30
31
    /**
32
     * Keep installed status around.
33
     *
34
     * @var bool
35
     */
36
    protected $installed = null;
37
38
    /**
39
     * The application reference.
40
     *
41
     * @var string
42
     */
43
    protected $reference = 'default';
44
45
    /**
46
     * The application repository.
47
     *
48
     * @var ApplicationRepository
49
     */
50
    protected $applications;
51
52
    /**
53
     * Create a new Application instance.
54
     *
55
     * @param ApplicationRepository $model
0 ignored issues
show
There is no parameter named $model. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
56
     */
57
    public function __construct(ApplicationRepository $applications)
58
    {
59
        $this->applications = $applications;
60
61
        $this->reference = env('DEFAULT_REFERENCE', $this->reference);
62
    }
63
64
    /**
65
     * Setup the application.
66
     */
67
    public function setup()
68
    {
69
        $this->setTablePrefix();
70
    }
71
72
    /**
73
     * Set the database table prefix going forward.
74
     * We really don't need a core table from here on out.
75
     */
76
    public function setTablePrefix()
77
    {
78
        app('db')->getSchemaBuilder()->getConnection()->setTablePrefix($this->getReference() . '_');
79
        app('db')->getSchemaBuilder()->getConnection()->getSchemaGrammar()->setTablePrefix($this->getReference() . '_');
80
    }
81
82
    /**
83
     * Get the reference.
84
     *
85
     * @return null
86
     */
87
    public function getReference()
88
    {
89
        return $this->reference;
90
    }
91
92
    /**
93
     * Set the reference.
94
     *
95
     * @param $reference
96
     * @return $this
97
     */
98
    public function setReference($reference)
99
    {
100
        $this->reference = $reference;
101
102
        return $this;
103
    }
104
105
    /**
106
     * Get the storage path for the application.
107
     *
108
     * @param  string $path
109
     * @return string
110
     */
111
    public function getStoragePath($path = '')
112
    {
113
        return storage_path('streams/' . $this->getReference()) . ($path ? '/' . $path : $path);
114
    }
115
116
    /**
117
     * Get the public assets path for the application.
118
     *
119
     * @param  string $path
120
     * @return string
121
     */
122
    public function getAssetsPath($path = '')
123
    {
124
        return public_path('app/' . $this->getReference()) . ($path ? '/' . $path : $path);
125
    }
126
127
    /**
128
     * Get the resources path for the application.
129
     *
130
     * @param  string $path
131
     * @return string
132
     */
133
    public function getResourcesPath($path = '')
134
    {
135
        return base_path('resources/' . $this->getReference()) . ($path ? '/' . $path : $path);
136
    }
137
138
    /**
139
     * Return the app reference.
140
     *
141
     * @return string
142
     */
143
    public function tablePrefix()
144
    {
145
        return $this->reference . '_';
146
    }
147
148
    /**
149
     * Locate the app by request or passed
150
     * variable and set the application reference.
151
     *
152
     * @return bool
153
     */
154
    public function locate()
155
    {
156
        if ($app = $this->applications->findByDomain(app('request')->root())) {
157
158
            $this->installed = true;
159
            $this->locale    = $app->locale;
0 ignored issues
show
The property locale does not exist on object<Anomaly\Streams\P...ation\ApplicationModel>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
160
            $this->enabled   = $app->enabled;
0 ignored issues
show
The property enabled does not exist on object<Anomaly\Streams\P...ation\ApplicationModel>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
161
            $this->reference = $app->reference;
0 ignored issues
show
The property reference does not exist on object<Anomaly\Streams\P...ation\ApplicationModel>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
162
163
            return true;
164
        }
165
166
        return false;
167
    }
168
169
    /**
170
     * Get the resolved locale.
171
     *
172
     * @return string
173
     */
174
    public function getLocale()
175
    {
176
        return $this->locale;
177
    }
178
179
    /**
180
     * Return if the application is enabled.
181
     *
182
     * @return bool
183
     */
184
    public function isEnabled()
185
    {
186
        if (is_null($this->enabled)) {
187
            return true;
188
        }
189
190
        return $this->enabled;
191
    }
192
193
    /**
194
     * Is the application installed?
195
     *
196
     * @return bool
197
     */
198
    public function isInstalled()
199
    {
200
        if (is_null($this->installed)) {
201
            $this->installed = file_exists(base_path('.env'));
202
        }
203
204
        return $this->installed;
205
    }
206
}
207