Issues (103)

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/install.php (1 issue)

Labels
Severity

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
 * BetterOptin Installer
4
 *
5
 * @package   BetterOptin/Install
6
 * @author    ThemeAvenue <[email protected]>
7
 * @license   GPL-2.0+
8
 * @link      http://themeavenue.net
9
 * @copyright 2015 ThemeAvenue
10
 */
11
12
// If this file is called directly, abort.
13
if ( ! defined( 'WPINC' ) ) {
14
	die;
15
}
16
17
register_activation_hook( WPBO_PLUGIN_FILE, 'wpbo_activate' );
18
add_action( 'wpmu_new_blog', 'wpbo_activate_new_site' );
19
20
/**
21
 * Fired when the plugin is activated.
22
 *
23
 * @since    1.0.0
24
 *
25
 * @param    boolean    $network_wide    True if WPMU superadmin uses
26
 *                                       "Network Activate" action, false if
27
 *                                       WPMU is disabled or plugin is
28
 *                                       activated on an individual blog.
29
 */
30
function wpbo_activate( $network_wide ) {
31
32
	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
33
34
		if ( $network_wide  ) {
35
36
			// Get all blog ids
37
			$blog_ids = wpbo_get_blog_ids();
38
39
			foreach ( $blog_ids as $blog_id ) {
0 ignored issues
show
The expression $blog_ids of type array|false is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
40
41
				switch_to_blog( $blog_id );
42
				wpbo_single_activate();
43
			}
44
45
			restore_current_blog();
46
47
		} else {
48
			wpbo_single_activate();
49
		}
50
51
	} else {
52
		wpbo_single_activate();
53
	}
54
55
}
56
57
/**
58
 * Get all blog ids of blogs in the current network that are:
59
 * - not archived
60
 * - not spam
61
 * - not deleted
62
 *
63
 * @since    1.0.0
64
 *
65
 * @return   array|false    The blog ids, false if no matches.
66
 */
67
function wpbo_get_blog_ids() {
68
69
	global $wpdb;
70
71
	// get an array of blog ids
72
	$sql = "SELECT blog_id FROM $wpdb->blogs
73
			WHERE archived = '0' AND spam = '0'
74
			AND deleted = '0'";
75
76
	return $wpdb->get_col( $sql );
77
78
}
79
80
/**
81
 * Fired for each blog when the plugin is activated.
82
 *
83
 * @since    1.0.0
84
 */
85
function wpbo_single_activate() {
86
87
	/* Add new role */
88
	$subscriber = get_role( 'subscriber' );
89
	add_role( 'betteroptin', 'BetterOptin', $subscriber->capabilities );
90
91
	/* Create database table */
92
	wpbo_create_table();
93
	wpbo_failsafe_create_table();
94
95
	/* Write database version */
96
	update_option( 'wpbo_db_version', WPBO_DB_VERSION );
97
98
	$defaults = get_option( 'wpbo_options', array() );
99
100
	// Register default options
101
	if ( empty( $defaults ) ) {
102
103
		// Get default options
104
		if ( ! function_exists( 'wpbo_settings_general' ) ) {
105
			require( WPBO_PATH . 'includes/admin/settings/settings-general.php' );
106
		}
107
108
		$options = apply_filters( 'wpbo_plugin_settings', array() );
109
110
		foreach ( $options as $section_id => $section ) {
111
112
			foreach ( $section['options'] as $option ) {
113
114
				if ( ! isset( $option['id'] ) ) {
115
					continue;
116
				}
117
118
				$value                     = isset( $option['default'] ) ? $option['default'] : '';
119
				$defaults[ $option['id'] ] = $value;
120
121
			}
122
123
		}
124
125
		if ( ! empty( $defaults ) ) {
126
			update_option( 'wpbo_options', serialize( $defaults ) );
127
		}
128
129
	}
130
131
	/**
132
	 * Add an option in DB to know when the plugin has just been activated.
133
	 *
134
	 * @link http://stackoverflow.com/questions/7738953/is-there-a-way-to-determine-if-a-wordpress-plugin-is-just-installed/13927297#13927297
135
	 */
136
	add_option( 'wpbo_just_activated', true );
137
138
}
139
140
/**
141
 * Fired when a new site is activated with a WPMU environment.
142
 *
143
 * @since    1.0.0
144
 *
145
 * @param    int    $blog_id    ID of the new blog.
146
 */
147
function wpbo_activate_new_site( $blog_id ) {
148
149
	if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
150
		return;
151
	}
152
153
	switch_to_blog( $blog_id );
154
	wpbo_single_activate();
155
	restore_current_blog();
156
157
}
158
159
/**
160
 * Redirect the user to the about page if the plugin was just installed
161
 *
162
 * @return void
163
 */
164
function wpbo_maybe_redirect_about() {
165
166
	if ( ! is_admin() ) {
167
		return;
168
	}
169
170
	$activated = get_option( 'wpbo_just_activated', false );
171
172
	/**
173
	 * First thing we check if the plugin has just been activated.
174
	 * If so, we take the user to the about page and delete the
175
	 * option we used for the check.
176
	 */
177
	if ( $activated ) {
178
179
		/* Delete the option */
180
		delete_option( 'wpbo_just_activated' );
181
182
		/* Redirect to about page */
183
		wp_redirect( add_query_arg( array(
184
			'post_type' => 'wpbo-popup',
185
			'page'      => 'wpbo-about'
186
		), admin_url( 'edit.php' ) ) );
187
188
		/* Don't do anything else */
189
		exit;
190
191
	}
192
193
}