Issues (234)

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.

includes/abstracts/admin-page.php (2 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
2
/**
3
 * Settings Page
4
 *
5
 * @package SimpleCalendar/Admin
6
 */
7
namespace SimpleCalendar\Abstracts;
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
/**
14
 * The Admin Page.
15
 *
16
 * @since 3.0.0
17
 */
18
abstract class Admin_Page {
19
20
	/**
21
	 * Admin page ID.
22
	 *
23
	 * @access public
24
	 * @var string
25
	 */
26
	public $id = '';
27
28
	/**
29
	 * Option group.
30
	 *
31
	 * @access public
32
	 * @var string
33
	 */
34
	public $option_group = '';
35
36
	/**
37
	 * Admin Page label.
38
	 *
39
	 * @access public
40
	 * @var string
41
	 */
42
	public $label = '';
43
44
	/**
45
	 * Admin Page description.
46
	 *
47
	 * @access public
48
	 * @var string
49
	 */
50
	public $description = '';
51
52
	/**
53
	 * Amdin Page settings sections.
54
	 *
55
	 * @access public
56
	 * @var array Associative array with section id (key) and section name (value)
57
	 */
58
	public $sections;
59
60
	/**
61
	 * Admin Page settings fields.
62
	 *
63
	 * @access public
64
	 * @var array
65
	 */
66
	public $fields;
67
68
	/**
69
	 * Saved values.
70
	 *
71
	 * @access protected
72
	 * @var array
73
	 */
74
	protected $values = array();
75
76
	/**
77
	 * Get admin page settings.
78
	 *
79
	 * @since  3.0.0
80
	 *
81
	 * @return array
82
	 */
83
	public function get_settings() {
84
85
		$settings = array();
86
87
		$settings[ $this->id ] = array(
88
			'label'         => $this->label,
89
			'description'   => $this->description,
90
		);
91
92
		if ( ! empty( $this->sections ) && is_array( $this->sections ) ) {
93
94
			foreach ( $this->sections as $section => $content ) {
95
96
				$settings[ $this->id ]['sections'][ $section ] = array(
97
					'title'         => isset( $content['title'] ) ? $content['title'] : '',
98
					'description'   => isset( $content['description'] ) ? $content['description'] : '',
99
					'callback'      => array( $this, 'add_settings_section_callback' ),
100
					'fields'        => isset( $this->fields[ $section ] ) ? $this->fields[ $section ] : '',
101
				);
102
103
			}
104
105
		}
106
107
		return apply_filters( 'simcal_get_' . $this->option_group . '_' . $this->id , $settings );
108
	}
109
110
	/**
111
	 * Get option value.
112
	 *
113
	 * @since  3.0.0
114
	 * @access protected
115
	 *
116
	 * @param  string $section
117
	 * @param  string $setting
118
	 *
119
	 * @return string
120
	 */
121
	protected function get_option_value( $section, $setting ) {
122
123
		$option = $this->values;
124
125
		if ( ! empty( $option ) && is_array( $option ) ) {
126
			return isset( $option[ $section ][ $setting ] ) ? $option[ $section ][ $setting ] : '';
127
		}
128
129
		return '';
130
	}
131
132
	/**
133
	 * Add sections for this page.
134
	 *
135
	 * @since  3.0.0
136
	 *
137
	 * @return array
138
	 */
139
	abstract public function add_sections();
140
141
	/**
142
	 * Get settings fields.
143
	 *
144
	 * @since  3.0.0
145
	 *
146
	 * @return array
147
	 */
148
	abstract public function add_fields();
149
150
	/**
151
	 * Default basic callback for page sections.
152
	 *
153
	 * @since  3.0.0
154
	 *
155
	 * @param  array $section
156
	 *
157
	 * @return string
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
158
	 */
159
	public function add_settings_section_callback( $section ) {
160
161
		$callback    = isset( $section['callback'][0] ) ? $section['callback'][0] : '';
162
		$sections    = isset( $callback->sections ) ? $callback->sections : '';
163
		$description = isset( $sections[ $section['id'] ]['description'] ) ? $sections[ $section['id'] ]['description'] : '';
164
		$default     = $description ? '<p>' . $description . '</p>' : '';
165
166
		echo apply_filters( 'simcal_' . $this->option_group . '_' . $this->id . '_sections_callback', $default );
167
	}
168
169
	/**
170
	 * Register setting callback.
171
	 *
172
	 * Callback function for sanitizing and validating options before they are updated.
173
	 *
174
	 * @since  3.0.0
175
	 *
176
	 * @param  array $settings Settings inputs.
177
	 *
178
	 * @return array Sanitized settings.
0 ignored issues
show
Should the return type not be array|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
179
	 */
180
	public function validate( $settings ) {
181
182
		$sanitized = '';
183
184
		if ( is_array( $settings ) ) {
185
			foreach ( $settings as $k => $v ) {
186
				$sanitized[ $k ] = simcal_sanitize_input( $v );
187
			}
188
		} else {
189
			$sanitized = simcal_sanitize_input( $settings );
190
		}
191
192
		return $sanitized;
193
	}
194
195
}
196