Issues (197)

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.

...-stripe-email-failed-renewal-authentication.php (1 issue)

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
if ( ! defined( 'ABSPATH' ) ) {
3
	exit; // Exit if accessed directly.
4
}
5
6
/**
7
 * Failed Renewal/Pre-Order Authentication Notification
8
 *
9
 * @extends WC_Email_Customer_Invoice
10
 */
11
class WC_Stripe_Email_Failed_Renewal_Authentication extends WC_Stripe_Email_Failed_Authentication {
12
	/**
13
	 * Constructor.
14
	 *
15
	 * @param WC_Email[] $email_classes All existing instances of WooCommerce emails.
16
	 */
17 View Code Duplication
	public function __construct( $email_classes = array() ) {
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...
18
		$this->id             = 'failed_renewal_authentication';
19
		$this->title          = __( 'Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe' );
20
		$this->description    = __( 'Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe' );
21
		$this->customer_email = true;
22
23
		$this->template_html  = 'emails/failed-renewal-authentication.php';
24
		$this->template_plain = 'emails/plain/failed-renewal-authentication.php';
25
		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
26
27
		// Triggers the email at the correct hook.
28
		add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ) );
29
30
		if ( isset( $email_classes['WCS_Email_Customer_Renewal_Invoice'] ) ) {
31
			$this->original_email = $email_classes['WCS_Email_Customer_Renewal_Invoice'];
32
		}
33
34
		// We want all the parent's methods, with none of its properties, so call its parent's constructor, rather than my parent constructor.
35
		parent::__construct();
36
	}
37
38
	/**
39
	 * Triggers the email while also disconnecting the original Subscriptions email.
40
	 *
41
	 * @param WC_Order $order The order that is being paid.
42
	 */
43
	public function trigger( $order ) {
44
		if ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order->get_id() ) || wcs_is_subscription( $order->get_id() ) || wcs_order_contains_renewal( $order->get_id() ) ) ) {
45
			parent::trigger( $order );
46
47
			// Prevent the renewal email from WooCommerce Subscriptions from being sent.
48
			if ( isset( $this->original_email ) ) {
49
				remove_action( 'woocommerce_generated_manual_renewal_order_renewal_notification', array( $this->original_email, 'trigger' ) );
50
				remove_action( 'woocommerce_order_status_failed_renewal_notification', array( $this->original_email, 'trigger' ) );
51
			}
52
53
			// Prevent the retry email from WooCommerce Subscriptions from being sent.
54
			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'prevent_retry_notification_email' ), 100, 3 );
55
56
			// Send email to store owner indicating communication is happening with the customer to request authentication.
57
			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'set_store_owner_custom_email' ), 100, 3 );
58
		}
59
	}
60
61
	/**
62
	 * Returns the default subject of the email (modifyable in settings).
63
	 *
64
	 * @return string
65
	 */
66
	public function get_default_subject() {
67
		return __( 'Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe' );
68
	}
69
70
	/**
71
	 * Returns the default heading of the email (modifyable in settings).
72
	 *
73
	 * @return string
74
	 */
75
	public function get_default_heading() {
76
		return __( 'Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe' );
77
	}
78
79
	/**
80
	 * Prevent all customer-facing retry notifications from being sent after this email.
81
	 *
82
	 * @param array $rule_array   The raw details about the retry rule.
83
	 * @param int   $retry_number The number of the retry.
84
	 * @param int   $order_id     The ID of the order that needs payment.
85
	 * @return array
86
	 */
87
	public function prevent_retry_notification_email( $rule_array, $retry_number, $order_id ) {
88
		if ( wcs_get_objects_property( $this->object, 'id' ) === $order_id ) {
89
			$rule_array['email_template_customer'] = '';
90
		}
91
92
		return $rule_array;
93
	}
94
95
	/**
96
	 * Send store owner a different email when the retry is related to an authentication required error.
97
	 *
98
	 * @param array $rule_array   The raw details about the retry rule.
99
	 * @param int   $retry_number The number of the retry.
100
	 * @param int   $order_id     The ID of the order that needs payment.
101
	 * @return array
102
	 */
103
	public function set_store_owner_custom_email( $rule_array, $retry_number, $order_id ) {
104
		if (
105
			wcs_get_objects_property( $this->object, 'id' ) === $order_id &&
106
			'' !== $rule_array['email_template_admin'] // Only send our email if a retry admin email was already going to be sent.
107
		) {
108
			$rule_array['email_template_admin'] = 'WC_Stripe_Email_Failed_Authentication_Retry';
109
		}
110
111
		return $rule_array;
112
	}
113
}
114