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/pages/calendars.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
 * Calendar Settings Page
4
 *
5
 * @package SimpleCalendar/Admin
6
 */
7
namespace SimpleCalendar\Admin\Pages;
8
9
use SimpleCalendar\Abstracts\Calendar;
10
use SimpleCalendar\Abstracts\Admin_Page;
11
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit;
14
}
15
16
/**
17
 * Calendar settings.
18
 *
19
 * Handles settings for specific calendar types and outputs the markup the settings page. a settings page.
20
 *
21
 * @since 3.0.0
22
 */
23
class Calendars extends Admin_Page {
24
25
	/**
26
	 * Calendar Types.
27
	 *
28
	 * @access private
29
	 * @var array
30
	 */
31
	private $calendar_types = array();
32
33
	/**
34
	 * Constructor.
35
	 *
36
	 * @since 3.0.0
37
	 */
38 View Code Duplication
	public function __construct() {
0 ignored issues
show
This method seems to be duplicated in 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...
39
40
		$this->id               = 'calendars';
41
		$this->option_group     = 'settings';
42
		$this->label            = __( 'Calendars', 'google-calendar-events' );
43
		//$this->description      = __( 'Manage calendar preferences and calendar types settings and options.', 'google-calendar-events' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
45
		$calendars = simcal_get_calendar_types();
46
		$calendar_settings = array();
47
		if ( ! empty( $calendars ) && is_array( $calendars ) ) {
48
			foreach ( $calendars as $calendar => $views ) {
49
50
				$calendar_type = simcal_get_calendar( $calendar );
51
52
				if ( $calendar_type instanceof Calendar ) {
53
					$settings = $calendar_type->settings_fields();
54
					if ( ! empty( $settings ) ) {
55
						$calendar_settings[ $calendar ] = $settings;
56
					}
57
				}
58
			}
59
		}
60
61
		$this->calendar_types = $calendar_settings;
62
		$this->sections       = $this->add_sections();
63
		$this->fields         = $this->add_fields();
64
	}
65
66
	/**
67
	 * Add sections.
68
	 *
69
	 * @since  3.0.0
70
	 *
71
	 * @return array
72
	 */
73
	public function add_sections() {
74
75
		$sections = array(
76
			'general' => array(
77
				'title'       => __( 'General', 'google-calendar-events' ),
78
				'description' => '',
79
			),
80
		);
81
82
		$calendar_types = $this->calendar_types;
83
84
		if ( ! empty( $calendar_types ) && is_array( $calendar_types ) ) {
85
			foreach ( $calendar_types as $calendar_type => $type ) {
86
87
				$sections[ $calendar_type ] = array(
88
					'title' => $type['name'],
89
					'description' => $type['description'],
90
				);
91
92
			}
93
		}
94
95
		arsort( $calendar_types );
96
97
		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', $sections );
98
	}
99
100
	/**
101
	 * Add fields.
102
	 *
103
	 * @since  3.0.0
104
	 *
105
	 * @return array
106
	 */
107
	public function add_fields() {
108
109
		$fields       = array();
110
		$feed_types   = $this->calendar_types;
111
		$this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id );
112
113
		foreach ( $this->sections as $section => $contents ) :
114
115
			if ( 'general' == $section ) {
116
117
				$options    = array();
118
				$post_types = get_post_types(
119
					array(
120
						'public' => false,
121
						'publicly_queriable' => false,
122
						'show_ui' => false,
123
					),
124
					'objects',
125
					'not'
126
				);
127
				unset( $post_types['attachment'] );
128
				unset( $post_types['calendar'] );
129
				unset( $post_types['gce_feed'] );
130
				foreach ( $post_types as $slug => $post_type ) {
131
					$options[ $slug ] = $post_type->label;
132
				}
133
				asort( $options );
134
135
				$fields[ $section ][] = array(
136
					'type'        => 'select',
137
					'multiselect' => 'multiselect',
138
					'enhanced'    => 'enhanced',
139
					'title'       => __( 'Attach Calendars', 'google-calendar-events' ),
140
					'tooltip'     => __( 'You can choose on which content types to add the ability to attach calendars.', 'google-calendar-events' ),
141
					'name'        => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][attach_calendars_posts]',
142
					'id'          => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-attach-calendars-posts',
143
					'value'       => $this->get_option_value( $section, 'attach_calendars_posts' ),
144
					'default'     => 'post,page',
145
					'options'     => $options,
146
				);
147
148 View Code Duplication
			} elseif ( isset( $feed_types[ $section ]['fields'] ) ) {
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...
149
150
				foreach ( $feed_types[ $section ]['fields'] as $key => $args ) {
151
152
					$fields[ $section ][] = array_merge( $args, array(
153
						'name'  => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][' . $key . ']',
154
						'id'    => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $key,
155
						'value' => $this->get_option_value( $section, $key )
156
					) );
157
158
				}
159
160
			}
161
162
		endforeach;
163
164
		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields );
165
	}
166
167
}
168