Issues (37)

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.

src/Config/Config.php (1 issue)

1
<?php
2
3
namespace GeminiLabs\Pollux\Config;
4
5
use GeminiLabs\Pollux\Application;
6
use GeminiLabs\Pollux\Config\ConfigManager;
7
8
class Config
9
{
10
	const ID = 'config';
11
12
	/**
13
	 * @var string
14
	 */
15
	public $hook;
16
17
	/**
18
	 * @var Application
19
	 */
20
	protected $app;
21
22
	/**
23
	 * @return string
24
	 */
25
	public static function id()
26
	{
27
		return Application::PREFIX . static::ID;
28
	}
29
30
	public function __construct( Application $app )
31
	{
32
		$this->app = $app;
33
	}
34
35
	/**
36
	 * @return void
37
	 */
38
	public function init()
39
	{
40
		if( $this->app->config->disable_config )return;
41
42
		add_action( 'admin_menu',     [$this, 'registerPage'] );
43
		add_action( 'admin_menu',     [$this, 'registerSetting'] );
44
		add_action( 'current_screen', [$this, 'resetPage'] );
45
	}
46
47
	/**
48
	 * @return array
49
	 * @callback register_setting
50
	 */
51
	public function filterSavedSettings( array $settings )
52
	{
53
		return $this->app->make( ConfigManager::class )->setTimestamp( $settings );
54
	}
55
56
	/**
57
	 * @return void
58
	 * @action admin_menu
59
	 */
60
	public function registerPage()
61
	{
62
		$this->hook = add_submenu_page(
0 ignored issues
show
Documentation Bug introduced by
It seems like add_submenu_page('option...y($this, 'renderPage')) can also be of type false. However, the property $hook is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
63
			'options-general.php',
64
			__( 'Pollux', 'pollux' ),
65
			__( 'Pollux', 'pollux' ),
66
			'manage_options',
67
			$this->app->id,
68
			[$this, 'renderPage']
69
		);
70
	}
71
72
	/**
73
	 * @return void
74
	 * @action admin_menu
75
	 */
76
	public function registerSetting()
77
	{
78
		register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] );
79
	}
80
81
	/**
82
	 * @return void
83
	 * @callback add_submenu_page
84
	 */
85
	public function renderPage()
86
	{
87
		$this->app->render( 'config/script' );
88
		$query = [
89
			'page' => $this->app->id,
90
			'action' => 'reset',
91
			'_wpnonce' => wp_create_nonce( static::id() ),
92
		];
93
		$this->app->render( 'config/index', [
94
			'config' => $this->app->make( ConfigManager::class ),
95
			'heading' => __( 'Pollux Settings', 'pollux' ),
96
			'id' => static::id(),
97
			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ))),
98
			'has_meta_box' => $this->app->gatekeeper->hasDependency( 'meta-box/meta-box.php' ),
99
		]);
100
	}
101
102
	/**
103
	 * @return void
104
	 * @action pollux/{static::ID}/init
105
	 */
106
	public function resetPage()
107
	{
108
		if( filter_input( INPUT_GET, 'page' ) !== $this->app->id
109
			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
110
		)return;
111
		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) {
112
			delete_option( static::id() );
113
			$this->app->make( ConfigManager::class )->compile( true );
114
			add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' );
115
		}
116
		else {
117
			add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ));
118
		}
119
		set_transient( 'settings_errors', get_settings_errors(), 30 );
120
		wp_safe_redirect( add_query_arg( 'settings-updated', 'true',  wp_get_referer() ));
121
		exit;
122
	}
123
}
124