Issues (27)

Security Analysis    no request data  

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.

src/Plugin.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 * Copyright (c) 2017 Salah Alkhwlani <[email protected]>
5
 *
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Yemenifree\WpSecurity;
11
12
use Illuminate\Support\Collection;
13
use Yemenifree\WpSecurity\Helpers\WPGitHubUpdater;
14
use Yemenifree\WpSecurity\Interfaces\Activable;
15
use Yemenifree\WpSecurity\Interfaces\Initializable;
16
use Yemenifree\WpSecurity\Interfaces\Installable;
17
use Yemenifree\WpSecurity\Interfaces\Loadable;
18
use Yemenifree\WpSecurity\Modules\ConfigSecurity;
19
use Yemenifree\WpSecurity\Modules\CoreSecurity;
20
use Yemenifree\WpSecurity\Modules\HtaccessSecurity;
21
use Yemenifree\WpSecurity\Modules\PluginSecurity;
22
use Yemenifree\WpSecurity\Modules\ResetSecurity;
23
use Yemenifree\WpSecurity\Modules\UploadZipSecurity;
24
use Yemenifree\WpSecurity\Modules\XmlrpcDisabled;
25
26
class Plugin
27
{
28
    /**
29
     * list of active modules.
30
     *
31
     * @var array|Collection
32
     */
33
    protected $modules;
34
35
    /**
36
     * plugin dir.
37
     *
38
     * @var string
39
     */
40
    protected $plugin_dir;
41
42
    /**
43
     * base name of plugin.
44
     *
45
     * @var string
46
     */
47
    private $basename;
48
49
    public function __construct($basename)
50
    {
51
        $this->basename = $basename;
52
        $this->plugin_dir = \dirname($this->basename);
53
        $this->modules = [
54
            HtaccessSecurity::class => [],
55
            ConfigSecurity::class => [],
56
            XmlrpcDisabled::class => [],
57
            CoreSecurity::class => [],
58
            ResetSecurity::class => [],
59
            UploadZipSecurity::class => [],
60
            PluginSecurity::class => [$this->basename],
61
        ];
62
63
        $this->initModules();
64
    }
65
66
    /**
67
     * create object from each modules.
68
     *
69
     * @return Collection
70
     */
71
    protected function initModules()
72
    {
73
        return $this->modules = $this->getModules()->map(function ($args, $module) {
74
            return new $module(...$args);
75
        });
76
    }
77
78
    /**
79
     * get list active modules.
80
     *
81
     * @return Collection
82
     */
83
    public function getModules()
84
    {
85
        return $this->modules instanceof Collection ? $this->modules : collect($this->modules);
86
    }
87
88
    /**
89
     * Load the plugin by hooking into WordPress actions and filters.
90
     * Method should be invoked immediately on plugin load.
91
     */
92
    public function load()
93
    {
94
        // Load all modules that require immediate loading.
95
        $this->getModules()->reject(function ($module) {
96
            return !$module instanceof Loadable;
97
        })->each(function ($module) {
98
            $module->load();
99
        });
100
101
        // Register initialization method.
102
        /** @scrutinizer ignore-call */
103
        add_action('init', [$this, 'init'], 10, 0);
104
    }
105
106
    /**
107
     * Perform initialization tasks.
108
     * Method should be run (early) in init hook.
109
     */
110
    public function init()
111
    {
112
        // Initialize all modules that require initialization.
113
        $this->getModules()->reject(function ($module) {
114
            return !$module instanceof Initializable;
115
        })->each(function ($module) {
116
            $module->init();
117
        });
118
119
        // Initialize updater
120
        $this->updater();
121
    }
122
123
    /**
124
     * update plugin from github.
125
     */
126
    public function updater()
127
    {
128
        // note the use of is_admin() to double check that this is happening in the admin
129
        /** @scrutinizer ignore-call */
130
        if (!is_admin()) {
0 ignored issues
show
The function is_admin was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

130
        if (!/** @scrutinizer ignore-call */ is_admin()) {
Loading history...
131
            return;
132
        }
133
134
        $config = [
135
            'slug' => $this->basename,
136
            'proper_folder_name' => $this->plugin_dir,
137
            'api_url' => 'https://api.github.com/repos/yemenifree/wp-security',
138
            'raw_url' => 'https://raw.github.com/yemenifree/wp-security/master',
139
            'github_url' => 'https://github.com/yemenifree/wp-security',
140
            'zip_url' => 'https://github.com/yemenifree/wp-security/archive/{version}.zip',
141
            'sslverify' => false,
142
            'requires' => '4.7',
143
            'tested' => '4.7',
144
            'readme' => 'README.md',
145
        ];
146
        new WPGitHubUpdater($config);
147
    }
148
149
    /**
150
     * Perform activation and installation tasks.
151
     * Method should be run on plugin activation.
152
     *
153
     * @link https://developer.wordpress.org/plugins/the-basics/activation-deactivation-hooks/
154
     */
155
    public function activate()
156
    {
157
        // Install every module that requires it.
158
        $this->getModules()->reject(function ($module) {
159
            return !$module instanceof Installable;
160
        })->each(function ($module) {
161
            $module->install();
162
        });
163
164
        // Activate every module that requires it.
165
        $this->getModules()->reject(function ($module) {
166
            return !$module instanceof Activable;
167
        })->each(function ($module) {
168
            $module->activate();
169
        });
170
    }
171
172
    /**
173
     * Perform deactivation tasks.
174
     * Method should be run on plugin deactivation.
175
     *
176
     * @link https://developer.wordpress.org/plugins/the-basics/activation-deactivation-hooks/
177
     */
178
    public function deactivate()
179
    {
180
        // Activate every module that requires it.
181
        $this->getModules()->reject(function ($module) {
182
            return !$module instanceof Activable;
183
        })->each(function ($module) {
184
            $module->deactivate();
185
        });
186
    }
187
188
    /**
189
     * Perform uninstallation tasks.
190
     * Method should be run on plugin uninstall.
191
     *
192
     * @link https://developer.wordpress.org/plugins/the-basics/uninstall-methods/
193
     */
194
    public function uninstall()
195
    {
196
        // Uninstall every module that requires it.
197
        $this->getModules()->reject(function ($module) {
198
            return !$module instanceof Installable;
199
        })->each(function ($module) {
200
            $module->uninstall();
201
        });
202
    }
203
}
204