Issues (52)

Security Analysis    not enabled

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.

include/license/class-bd-edd-api-wrapper.php (4 issues)

Labels
1
<?php
2
/**
3
 * Wrapper for EDD API.
4
 *
5
 * @since      5.0
6
 *
7
 * @author     Sudar
8
 *
9
 * @package    BulkDelete\License
10
 */
11
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
12
13
class BD_EDD_API_Wrapper {
14
	/**
15
	 * Store url.
16
	 *
17
	 * @since 5.0
18
	 */
19
	const STORE_URL = 'https://bulkwp.com';
20
21
	/**
22
	 * Check license.
23
	 *
24
	 * @since  5.0
25
	 * @static
26
	 *
27
	 * @param string $addon   Addon name
28
	 * @param string $license The license code
29
	 *
30
	 * @return array|false False if request fails, API response otherwise
31
	 */
32
	public static function check_license( $addon, $license ) {
33
		$api_params = array(
34
			'edd_action' => 'check_license',
35
			'license'    => trim( $license ),
36
			'item_name'  => urlencode( $addon ),
37
			'url'        => home_url(),
38
		);
39
40
		$license_data = array(
41
			'license'   => $license,
42
			'item_name' => $addon,
43
			'validity'  => 'invalid',
44
		);
45
46
		$response = self::call_edd_api( $api_params );
47
48
		if ( $response && isset( $response->license ) ) {
0 ignored issues
show
The property license does not exist on true.
Loading history...
49
			if ( 'valid' == $response->license ) {
50
				$license_data['license']    = $license;
51
				$license_data['validity']   = 'valid';
52
				$license_data['expires']    = $response->expires;
53
				$license_data['addon-name'] = $response->item_name;
54
			} elseif ( 'invalid' == $response->license ) {
55
				$license_data['validity']   = 'invalid';
56
			} elseif ( 'site_inactive' == $response->license ) {
57
				$license_data['validity']   = 'invalid';
58
			}
59
60
			return $license_data;
61
		}
62
63
		return false;
64
	}
65
66
	/**
67
	 * Activate license.
68
	 *
69
	 * @since  5.0
70
	 * @static
71
	 *
72
	 * @param string $addon   The addon that needs to be activated
73
	 * @param string $license The license code
74
	 *
75
	 * @return array|false False if request fails, License info otherwise
76
	 */
77
	public static function activate_license( $addon, $license ) {
78
		$api_params = array(
79
			'edd_action' => 'activate_license',
80
			'license'    => trim( $license ),
81
			'item_name'  => urlencode( $addon ),
82
			'url'        => home_url(),
83
		);
84
85
		$response = self::call_edd_api( $api_params );
86
87
		if ( $response && isset( $response->success ) ) {
0 ignored issues
show
The property success does not exist on true.
Loading history...
88
			if ( 'true' == $response->success ) {
89
				return array(
90
					'license'    => $license,
91
					'validity'   => 'valid',
92
					'expires'    => $response->expires,
93
					'addon-name' => $response->item_name,
94
				);
95
			} else {
96
				$err_response = array(
97
					'validity'   => 'invalid',
98
				);
99
100
				if ( isset( $response->error ) ) {
101
					$err_response['error'] = $response->error;
102
				}
103
104
				return $err_response;
105
			}
106
		}
107
108
		return false;
109
	}
110
111
	/**
112
	 * Deactivate License.
113
	 *
114
	 * @since  5.0
115
	 * @static
116
	 *
117
	 * @param string $addon   The addon that needs to be deactivated
118
	 * @param string $license The license code
119
	 *
120
	 * @return bool True if deactivated, False otherwise
121
	 */
122
	public static function deactivate_license( $addon, $license ) {
123
		$api_params = array(
124
			'edd_action' => 'deactivate_license',
125
			'license'    => trim( $license ),
126
			'item_name'  => urlencode( $addon ),
127
			'url'        => home_url(),
128
		);
129
130
		$response = self::call_edd_api( $api_params );
131
132
		if ( $response && isset( $response->license ) ) {
0 ignored issues
show
The property license does not exist on true.
Loading history...
133
			if ( 'deactivated' == $response->license ) {
134
				return true;
135
			}
136
		}
137
138
		return false;
139
	}
140
141
	/**
142
	 * Call the EDD API.
143
	 *
144
	 * @since  5.0
145
	 * @static
146
	 * @access private
147
	 *
148
	 * @param array $api_params Parameters for API
149
	 *
150
	 * @return array|bool $license_data False if request fails, API response otherwise
151
	 */
152
	private static function call_edd_api( $api_params ) {
153
		$response = wp_remote_get( add_query_arg( $api_params, self::STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
154
155
		// make sure the response came back okay
156
		if ( is_wp_error( $response ) ) {
157
			return false;
158
		}
159
160
		$license_object = json_decode( wp_remote_retrieve_body( $response ) );
0 ignored issues
show
It seems like $response can also be of type WP_Error; however, parameter $response of wp_remote_retrieve_body() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

160
		$license_object = json_decode( wp_remote_retrieve_body( /** @scrutinizer ignore-type */ $response ) );
Loading history...
161
162
		return $license_object;
163
	}
164
}
165