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.

reports/class-getpaid-subscription-exporter.php (1 issue)

Severity
1
<?php
2
/**
3
 * Contains the class that exports subscriptions.
4
 *
5
 *
6
 */
7
8
defined( 'ABSPATH' ) || exit;
9
10
/**
11
 * GetPaid_Subscription_Exporter Class.
12
 */
13
class GetPaid_Subscription_Exporter extends GetPaid_Graph_Downloader {
14
15
	/**
16
	 * Retrieves subscription query args.
17
	 *
18
	 * @param array $args Args to search for.
19
	 * @return array
20
	 */
21
	public function get_subscription_query_args( $args ) {
22
23
		$query_args = array(
24
			'status'      => 'all',
25
			'number'      => -1,
26
			'count_total' => false,
27
			'fields'      => 'all',
28
		);
29
30
		if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) {
31
			$query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
32
		}
33
34
		$date_query = array();
35
		if ( ! empty( $args['to_date'] ) ) {
36
			$date_query['before'] = wpinv_clean( $args['to_date'] );
37
		}
38
39
		if ( ! empty( $args['from_date'] ) ) {
40
			$date_query['after'] = wpinv_clean( $args['from_date'] );
41
		}
42
43
		if ( ! empty( $date_query ) ) {
44
			$date_query['inclusive']          = true;
45
			$query_args['date_created_query'] = array( $date_query );
46
		}
47
48
		return $query_args;
49
	}
50
51
	/**
52
	 * Retrieves subscriptions.
53
	 *
54
	 * @param array $query_args GetPaid_Subscriptions_Query args.
55
	 * @return WPInv_Subscription[]
56
	 */
57
	public function get_subscriptions( $query_args ) {
58
59
		// Get subscriptions.
60
		$subscriptions = new GetPaid_Subscriptions_Query( $query_args );
61
62
		// Prepare the results.
63
		return $subscriptions->get_results();
64
65
	}
66
67
	/**
68
	 * Handles the actual download.
69
	 *
70
	 */
71
	public function export( $post_type, $args ) {
72
73
		$subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) );
74
		$stream        = $this->prepare_output();
75
		$headers       = $this->get_export_fields();
76
		$file_type     = $this->prepare_file_type( 'subscriptions' );
77
78
		if ( 'csv' == $file_type ) {
79
			$this->download_csv( $subscriptions, $stream, $headers );
80
		} elseif ( 'xml' == $file_type ) {
81
			$this->download_xml( $subscriptions, $stream, $headers );
82
		} else {
83
			$this->download_json( $subscriptions, $stream, $headers );
84
		}
85
86
		fclose( $stream );
87
		exit;
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
88
	}
89
90
	/**
91
	 * Prepares a single subscription for download.
92
	 *
93
	 * @param WPInv_Subscription $subscription The subscription to prepare..
94
	 * @param array $fields The fields to stream.
95
	 * @since       1.0.19
96
	 * @return array
97
	 */
98
	public function prepare_row( $subscription, $fields ) {
99
100
		$prepared      = array();
101
		$amount_fields = $this->get_amount_fields();
102
		$invoice       = $subscription->get_parent_payment();
103
104
		foreach ( $fields as $field ) {
105
106
			$value  = '';
107
			$method = "get_$field";
108
109
			if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) {
110
111
				if ( method_exists( $invoice, $method ) ) {
112
					$value  = $invoice->$method();
113
				}
114
} elseif ( method_exists( $subscription, $method ) ) {
115
				$value  = $subscription->$method();
116
			}
117
118
			if ( in_array( $field, $amount_fields ) ) {
119
				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
120
			}
121
122
			$prepared[ $field ] = wpinv_clean( $value );
123
124
		}
125
126
		return $prepared;
127
	}
128
129
	/**
130
	 * Retrieves export fields.
131
	 *
132
	 * @since       1.0.19
133
	 * @return array
134
	 */
135
	public function get_export_fields() {
136
137
		$fields = array(
138
			'id',
139
			'currency',
140
			'initial_amount',
141
			'recurring_amount',
142
			'trial_period',
143
			'frequency',
144
			'period',
145
			'bill_times',
146
			'parent_payment_id',
147
			'profile_id',
148
			'product_id',
149
			'status',
150
			'date_created',
151
			'date_expires',
152
153
			'customer_id',
154
			'customer_first_name',
155
			'customer_last_name',
156
			'customer_phone',
157
			'customer_email',
158
			'customer_country',
159
			'customer_city',
160
			'customer_state',
161
			'customer_zip',
162
			'customer_company',
163
			'customer_vat_number',
164
			'customer_address',
165
166
    	);
167
168
		return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields );
169
	}
170
171
	/**
172
	 * Retrieves amount fields.
173
	 *
174
	 * @since       1.0.19
175
	 * @return array
176
	 */
177
	public function get_amount_fields() {
178
179
		$fields = array(
180
			'initial_amount',
181
			'recurring_amount',
182
    	);
183
184
		return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields );
185
	}
186
187
}
188