Issues (632)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

Apps/ActiveRecord/App.php (6 issues)

1
<?php
2
3
namespace Apps\ActiveRecord;
4
5
use Ffcms\Core\Arch\ActiveModel;
6
use Ffcms\Core\Cache\MemoryObject;
7
use Ffcms\Core\Exception\SyntaxException;
8
use Ffcms\Core\Helper\Type\Any;
9
use Ffcms\Core\Helper\Type\Arr;
10
use Ffcms\Core\Helper\Type\Str;
11
use Ffcms\Core\Traits\SearchableTrait;
12
use Illuminate\Support\Collection;
13
14
/**
15
 * Class App - active record for 'prefix_apps' table.
16
 * @package Apps\ActiveRecord
17
 * @property int $id
18
 * @property string $type
19
 * @property string $sys_name
20
 * @property string $name
21
 * @property string $configs
22
 * @property bool $disabled
23
 * @property string $version
24
 * @property string $created_at
25
 * @property string $updated_at
26
 */
27
class App extends ActiveModel
28
{
29
    use SearchableTrait;
30
31
    protected $casts = [
32
        'id' => 'integer',
33
        'type' => 'string',
34
        'sys_name' => 'string',
35
        'name' => 'serialize',
36
        'configs' => 'serialize',
37
        'disabled' => 'boolean',
38
        'version' => 'string'
39
    ];
40
41
    protected $searchable = [
42
        'columns' => [
43
            'name' => 12,
44
            'sys_name' => 10
45
        ]
46
    ];
47
48
    /**
49
     * Get all objects with query caching
50
     * @param array $columns
51
     * @return \Illuminate\Database\Eloquent\Collection|null
52
     */
53
    public static function all($columns = ['*']): ?Collection
54
    {
55
        $cacheName = 'activercord.app.all.' . implode('.', $columns);
56
        $records = MemoryObject::instance()->get($cacheName);
57
        if ($records === null) {
58
            $records = parent::all($columns);
59
            MemoryObject::instance()->set($cacheName, $records);
60
        }
61
62
        return $records;
63
    }
64
65
    /**
66
     * Get single row by defined type and sys_name with query caching
67
     * @param string $type
68
     * @param string|array $name
69
     * @return self|null
70
     */
71
    public static function getItem($type, $name): ?self
72
    {
73
        foreach (self::all() as $object) {
74
            if ($object->type === $type) { //&& $object->sys_name === $sys_name) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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.

Loading history...
75
                if (Any::isArray($name) && Arr::in($object->sys_name, $name)) { // many different app name - maybe alias or something else
0 ignored issues
show
It seems like $name can also be of type string; however, parameter $haystack of Ffcms\Core\Helper\Type\Arr::in() does only seem to accept array|null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
                if (Any::isArray($name) && Arr::in($object->sys_name, /** @scrutinizer ignore-type */ $name)) { // many different app name - maybe alias or something else
Loading history...
76
                    return $object;
77
                } elseif (Any::isStr($name) && $object->sys_name === $name) {
78
                    return $object;
79
                }
80
            }
81
        }
82
83
        return null;
84
    }
85
86
    /**
87
     * Get application configs
88
     * @param string $type
89
     * @param string $name
90
     * @return array|null|string
91
     */
92
    public static function getConfigs(string $type, string $name)
93
    {
94
        foreach (self::all() as $row) {
95
            if ($row->type === $type && $row->sys_name === $name) {
96
                return $row->configs;
97
            }
98
        }
99
100
        return null;
101
    }
102
103
    /**
104
     * Get single config value by ext type, ext name and config key
105
     * @param string $type
106
     * @param string $name
107
     * @param string $configKey
108
     * @return array|string|null
109
     */
110
    public static function getConfig(string $type, string $name, string $configKey)
111
    {
112
        $configs = self::getConfigs($type, $name);
113
        if (isset($configs[$configKey])) {
114
            return $configs[$configKey];
115
        }
116
117
        return null;
118
    }
119
120
    /**
121
     * Get localized application name
122
     * @return string
123
     */
124
    public function getLocaleName(): string
125
    {
126
        if (!$this->sys_name) {
127
            return '';
128
        }
129
130
        $name = $this->getLocaled('name');
131
        if (Str::likeEmpty($name)) {
0 ignored issues
show
It seems like $name can also be of type array; however, parameter $string of Ffcms\Core\Helper\Type\Str::likeEmpty() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

131
        if (Str::likeEmpty(/** @scrutinizer ignore-type */ $name)) {
Loading history...
132
            $name = $this->sys_name;
133
        }
134
        return $name;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $name could return the type array|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
135
    }
136
137
    /**
138
     * Check if app version match db version of this app
139
     * @return bool
140
     * @throws SyntaxException
141
     */
142
    public function checkVersion(): bool
143
    {
144
        if ($this->sys_name === null) {
145
            throw new SyntaxException('Application object is not founded');
146
        }
147
148
        $scriptVersion = $this->getScriptVersion();
149
150
        return version_compare($scriptVersion, $this->version) === 0;
151
    }
152
153
    /**
154
     * Get extension script version if exists
155
     * @return string
156
     */
157
    public function getScriptVersion(): string
158
    {
159
        $class = 'Apps\Controller\Admin\\' . $this->sys_name;
160
        if (!class_exists($class)) {
161
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the type-hinted return string.
Loading history...
162
        }
163
164
        if (!defined($class . '::VERSION')) {
165
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the type-hinted return string.
Loading history...
166
        }
167
168
        return constant($class . '::VERSION');
169
    }
170
}
171