Issues (865)

Security Analysis    4 potential vulnerabilities

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 (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
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 (1)
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.

data-stores/class-getpaid-customer-data-store.php (2 issues)

1
<?php
2
3
/**
4
 * GetPaid_Customer_Data_Store class file.
5
 *
6
 */
7
if ( ! defined( 'ABSPATH' ) ) {
8
	exit;
9
}
10
11
/**
12
 * Customer Data Store: Stored in a custom table.
13
 *
14
 * @version  1.0.19
15
 */
16
class GetPaid_Customer_Data_Store {
17
18
	/*
19
	|--------------------------------------------------------------------------
20
	| CRUD Methods
21
	|--------------------------------------------------------------------------
22
	*/
23
24
	/**
25
	 * Method to create a new customer in the database.
26
	 *
27
	 * @param GetPaid_Customer $customer customer object.
28
	 */
29
	public function create( &$customer ) {
30
		global $wpdb;
31
32
		$values  = array();
33
		$formats = array();
34
35
		$fields = self::get_database_fields();
36
		unset( $fields['id'] );
37
38
		foreach ( $fields as $key => $format ) {
39
			$values[ $key ] = $customer->get( $key, 'edit' );
40
			$formats[]      = $format;
41
		}
42
43
		$result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
44
45
		if ( $result ) {
46
			$customer->set_id( $wpdb->insert_id );
47
			$customer->apply_changes();
48
			$customer->clear_cache();
49
			do_action( 'getpaid_new_customer', $customer );
50
			return true;
51
		}
52
53
		return false;
54
	}
55
56
	/**
57
	 * Method to read a customer from the database.
58
	 *
59
	 * @param GetPaid_Customer $customer customer object.
60
	 *
61
	 */
62
	public function read( &$customer ) {
63
		global $wpdb;
64
65
		$customer->set_defaults();
66
67
		if ( ! $customer->get_id() ) {
68
			$customer->last_error = 'Invalid customer.';
69
			$customer->set_id( 0 );
70
			return false;
71
		}
72
73
		// Maybe retrieve from the cache.
74
		$raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
75
76
		// If not found, retrieve from the db.
77
		if ( false === $raw_customer ) {
78
79
			$raw_customer = $wpdb->get_row(
80
				$wpdb->prepare(
81
					"SELECT * FROM {$wpdb->prefix}getpaid_customers WHERE id = %d",
82
					$customer->get_id()
83
				)
84
			);
85
86
			// Update the cache with our data
87
			wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
88
89
		}
90
91
		if ( ! $raw_customer ) {
92
			$raw_customer->last_error = 'Invalid customer.';
93
			return false;
94
		}
95
96
		// Loop through raw customer fields.
97
		foreach ( (array) $raw_customer as $key => $value ) {
98
			$customer->set( $key, $value );
99
		}
100
101
		$customer->set_object_read( true );
102
		do_action( 'getpaid_read_customer', $customer );
103
104
	}
105
106
	/**
107
	 * Method to update a customer in the database.
108
	 *
109
	 * @param GetPaid_Customer $customer Customer object.
110
	 */
111
	public function update( &$customer ) {
112
		global $wpdb;
113
114
		do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
115
116
		$changes = $customer->get_changes();
117
		$values  = array();
118
		$format  = array();
0 ignored issues
show
The assignment to $format is dead and can be removed.
Loading history...
119
120
		foreach ( self::get_database_fields() as $key => $format ) {
121
			if ( array_key_exists( $key, $changes ) ) {
122
				$values[ $key ] = $customer->get( $key, 'edit' );
123
				$formats[]      = $format;
124
			}
125
		}
126
127
		if ( empty( $values ) ) {
128
			return;
129
		}
130
131
		$wpdb->update(
132
			$wpdb->prefix . 'getpaid_customers',
133
			$values,
134
			array(
135
				'id' => $customer->get_id(),
136
			),
137
			$formats,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $formats does not seem to be defined for all execution paths leading up to this point.
Loading history...
138
			'%d'
139
		);
140
141
		// Apply the changes.
142
		$customer->apply_changes();
143
144
		// Delete cache.
145
		$customer->clear_cache();
146
147
		// Fire a hook.
148
		do_action( 'getpaid_update_customer', $customer );
149
150
	}
151
152
	/**
153
	 * Method to delete a customer from the database.
154
	 *
155
	 * @param GetPaid_Customer $customer
156
	 */
157
	public function delete( &$customer ) {
158
		global $wpdb;
159
160
		do_action( 'getpaid_before_delete_customer', $customer );
161
162
		$wpdb->delete(
163
			$wpdb->prefix . 'getpaid_customers',
164
			array(
165
				'id' => $customer->get_id(),
166
			),
167
			'%d'
168
		);
169
170
		// Delete cache.
171
		$customer->clear_cache();
172
173
		// Fire a hook.
174
		do_action( 'getpaid_delete_customer', $customer );
175
176
		$customer->set_id( 0 );
177
	}
178
179
	/*
180
	|--------------------------------------------------------------------------
181
	| Additional Methods
182
	|--------------------------------------------------------------------------
183
	*/
184
	public static function get_database_fields() {
185
186
		$fields = array(
187
			'id'             => '%d',
188
			'user_id'        => '%d',
189
			'email'          => '%s',
190
			'email_cc'       => '%s',
191
			'status'         => '%s',
192
			'purchase_value' => '%f',
193
			'purchase_count' => '%d',
194
			'date_created'   => '%s',
195
			'date_modified'  => '%s',
196
			'uuid'           => '%s',
197
		);
198
199
		// Add address fields.
200
		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
201
202
			// Skip id, user_id and email.
203
			if ( ! in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
204
				$fields[ $field ] = '%s';
205
			}
206
		}
207
208
		return $fields;
209
	}
210
211
}
212