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/admin/notice.php (3 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
 * Admin Notice
4
 *
5
 * @package SimpleCalendar/Admin
6
 */
7
namespace SimpleCalendar\Admin;
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
/**
14
 * Admin notice.
15
 *
16
 * An admin notice as an object.
17
 *
18
 * @since 3.0.0
19
 */
20
class Notice {
21
22
	/**
23
	 * Notice id.
24
	 * Will be the notice key in saved notices option.
25
	 *
26
	 * @access public
27
	 * @var string|array
28
	 */
29
	public $id = '';
30
31
	/**
32
	 * Notice type
33
	 * Gives the notice a CSS class.
34
	 *
35
	 * @access public
36
	 * @var string notice|error|updated|update-nag
37
	 */
38
	public $type = '';
39
40
	/**
41
	 * Additional classes.
42
	 *
43
	 * @access public
44
	 * @var string
45
	 */
46
	public $class = '';
47
48
	/**
49
	 * To which users the notice should be shown.
50
	 * If not set, will be visible to all users.
51
	 *
52
	 * @access public
53
	 * @var string
54
	 */
55
	public $capability = '';
56
57
	/**
58
	 * In which screen the notice should appear.
59
	 * If not set, will appear in every dashboard page/screen.
60
	 *
61
	 * @access public
62
	 * @var array
63
	 */
64
	public $screen = array();
65
66
	/**
67
	 * For which posts edit screens the notice should appear.
68
	 * If not set, will fallback on $screen rule only.
69
	 *
70
	 * @access public
71
	 * @var array
72
	 */
73
	public $post = array();
74
75
	/**
76
	 * Can the notice be dismissed by the user?
77
	 * If false, you need to set up a dismissal event.
78
	 *
79
	 * @access public
80
	 * @var bool
81
	 */
82
	public $dismissible = true;
83
84
	/**
85
	 * Whether to hide notice while keeping it stored.
86
	 * If false, will keep the notice in option without showing it.
87
	 *
88
	 * @access public
89
	 * @var bool
90
	 */
91
	public $visible = true;
92
93
	/**
94
	 * The notice content.
95
	 * Supports html. You would normally wrap this in paragraph tags.
96
	 *
97
	 * @access public
98
	 * @var string
99
	 */
100
	public $content = '';
101
102
	/**
103
	 * Make a notice.
104
	 *
105
	 * @since 3.0.0
106
	 *
107
	 * @param array $notice
108
	 */
109
	public function __construct( $notice ) {
110
111
		if ( ! empty( $notice['id'] ) && ! empty( $notice['content'] ) ) {
112
113
			// Content.
114
			$this->id = is_array( $notice['id'] ) ? array_map( 'sanitize_key', $notice['id'] ) : sanitize_key( $notice['id'] );
115
			$this->content = wp_kses_post( $notice['content'] );
116 View Code Duplication
			if ( ! empty( $notice['class'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
				$this->class = is_array( $notice['class'] ) ? join( ' ', array_map( 'esc_attr', $notice['class'] ) ) : esc_attr( $notice['class'] );
118
			}
119
120
			// Type.
121
			$default = 'notice';
122
			$type = isset( $notice['type'] ) ? esc_attr( $notice['type'] ) : $default;
123
			$types = array(
124
				'error',
125
				'notice',
126
				'updated',
127
				'update-nag',
128
			);
129
			$this->type = in_array( $type, $types ) ? $type : $default;
130
131
			// Visibility.
132
			if ( ! empty( $notice['capability'] ) ) {
133
				$this->capability = esc_attr( $notice['capability'] );
134
			}
135 View Code Duplication
			if ( ! empty( $notice['screen'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
				$this->screen = is_array( $notice['screen'] ) ? array_map( 'esc_attr', $notice['screens'] ) : array( esc_attr( $notice['screen'] ) );
137
			}
138 View Code Duplication
			if ( ! empty( $notice['post'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
				$this->post = is_array( $notice['post'] ) ? array_map( 'intval', $notice['post'] ) : array( intval( $notice['post'] ) );
140
			}
141
			if ( ! empty( $notice['dismissible'] ) ) {
142
				$this->dismissible = $notice['dismissible'] === false ? false: true;
143
			}
144
			if ( ! empty( $notice['visible'] ) ) {
145
				$this->visible = $notice['visible'] === false ? false: true;
146
			}
147
		}
148
149
	}
150
151
	/**
152
	 * Add the notice.
153
	 *
154
	 * @since 3.0.0
155
	 */
156
	public function add() {
157
		if ( ! empty( $this->id ) && ! empty( $this->content ) ) {
158
			$notices = get_option( 'simple-calendar_admin_notices', array() );
159
			if ( is_array( $this->id ) ) {
160
				foreach ( $this->id as $k => $v ) {
161
					$notices[ $k ][ $v ] = $this;
162
				}
163
			} else {
164
				$notices[ $this->id ][] = $this;
165
			}
166
			update_option( 'simple-calendar_admin_notices', $notices );
167
		}
168
	}
169
170
	/**
171
	 * Remove the notice.
172
	 *
173
	 * @since 3.0.0
174
	 */
175
	public function remove() {
176
		if ( ! empty( $this->id ) && ! empty( $this->content ) ) {
177
			$notices = get_option( 'simple-calendar_admin_notices', array() );
178
			if ( is_array( $this->id ) ) {
179
				foreach ( $this->id as $k => $v ) {
180
					unset( $notices[ $k ] );
181
				}
182
			} else {
183
				unset( $notices[ $this->id ] );
184
			}
185
			update_option( 'simple-calendar_admin_notices', $notices );
186
		}
187
	}
188
189
}
190