Issues (1)

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.

plugin/Application.php (1 issue)

1
<?php
2
3
namespace GeminiLabs\Logger;
4
5
use GeminiLabs\Logger\Log;
6
7
final class Application
8
{
9
	const ID = 'logger';
10
11
	public $file;
12
	public $languages;
13
	public $log;
14
	public $name;
15
	public $version;
16
17
	protected static $instance;
18
19
	/**
20
	 * @return static
21
	 */
22
	public static function load()
23
	{
24
		if( empty( static::$instance )) {
25
			static::$instance = new static;
26
		}
27
		return static::$instance;
28
	}
29
30
	/**
31
	 * @return void
32
	 */
33
	public function __construct()
34
	{
35
		$this->file = trailingslashit( dirname( __DIR__ )).static::ID.'.php';
36
		$this->log = new Log( $this->path( 'development.log' ));
37
		$plugin = get_file_data( $this->file, [
38
			'languages' => 'Domain Path',
39
			'name' => 'Plugin Name',
40
			'version' => 'Version',
41
		], 'plugin' );
42
		array_walk( $plugin, function( $value, $key ) {
43
			$this->$key = $value;
44
		});
45
	}
46
47
	/**
48
	 * @return void
49
	 */
50
	public function init()
51
	{
52
		add_action( 'admin_init',     [$this, 'clearLog'] );
53
		add_action( 'plugins_loaded', [$this, 'registerLanguages'] );
54
		add_action( 'admin_menu',     [$this, 'registerMenu'] );
55
		add_action( 'admin_menu',     [$this, 'registerSettings'] );
56
		add_filter( 'all',            [$this, 'initLogger'] );
57
	}
58
59
	/**
60
	 * Usage: apply_filters( 'logger', $data, $optional_log_type );
61
	 * @return static
62
	 */
63
	public function initLogger()
64
	{
65
		$args = func_get_args() + ['', null, 'debug'];
66
		if( $args[0] !== static::ID || is_null( $args[1] ))return;
67
		return $this->log->log( $args[2], $args[1] );
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->log->log($args[2], $args[1]) returns the type GeminiLabs\Logger\Log which is incompatible with the documented return type GeminiLabs\Logger\Application.
Loading history...
68
	}
69
70
	/**
71
	 * @return void
72
	 */
73
	public function clearLog()
74
	{
75
		$request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY );
76
		if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return;
77
		check_admin_referer( $request['action'] );
78
		$this->log->clear();
79
		add_action( 'admin_notices', [$this, 'renderNotice'] );
80
	}
81
82
	/**
83
	 * @param string $file
84
	 * @return string
85
	 */
86
	public function path( $file = '' )
87
	{
88
		$basepath = trailingslashit( realpath( plugin_dir_path( $this->file )));
89
		return $basepath.ltrim( trim( $file ), '/' );
90
	}
91
92
	/**
93
	 * @return void
94
	 */
95
	public function registerLanguages()
96
	{
97
		load_plugin_textdomain( static::ID, '',
98
			trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
99
		);
100
	}
101
102
	/**
103
	 * @return void
104
	 * @action admin_menu
105
	 */
106
	public function registerMenu()
107
	{
108
		add_submenu_page(
109
			'tools.php',
110
			__( 'Logger', 'logger' ),
111
			__( 'Logger', 'logger' ),
112
			'manage_options',
113
			static::ID,
114
			[$this, 'renderSettingsPage']
115
		);
116
	}
117
118
	/**
119
	 * @return void
120
	 * @action admin_menu
121
	 */
122
	public function registerSettings()
123
	{
124
		register_setting( static::ID, static::ID );
125
	}
126
127
	/**
128
	 * @param string $view
129
	 * @return void|null
130
	 */
131
	public function render( $view, array $data = [] )
132
	{
133
		if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return;
134
		extract( $data );
135
		include $file;
136
	}
137
138
	/**
139
	 * @return void
140
	 */
141
	public function renderNotice()
142
	{
143
		$this->render( 'notice', [
144
			'notice' => __( 'The log was cleared.', 'logger' ),
145
			'status' => 'success',
146
		]);
147
	}
148
149
	/**
150
	 * @return void
151
	 * @callback add_submenu_page
152
	 */
153
	public function renderSettingsPage()
154
	{
155
		$this->render( 'settings', [
156
			'id' => static::ID,
157
			'log' => $this->log,
158
			'settings' => $this->getSettings(),
159
			'title' => __( 'Logger', 'logger' ),
160
		]);
161
	}
162
163
	/**
164
	 * @return object
165
	 */
166
	protected function getSettings()
167
	{
168
		$settings = get_option( static::ID, [] );
169
		if( empty( $settings )) {
170
			update_option( static::ID, $settings = [
171
				'enabled' => 0,
172
			]);
173
		}
174
		return (object)$settings;
175
	}
176
}
177