Issues (1182)

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/emails/class-wc-email-customer-note.php (2 issues)

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
if ( ! defined( 'ABSPATH' ) ) {
4
	exit; // Exit if accessed directly
5
}
6
7
if ( ! class_exists( 'WC_Email_Customer_Note' ) ) :
8
9
/**
10
 * Customer Note Order Email.
11
 *
12
 * Customer note emails are sent when you add a note to an order.
13
 *
14
 * @class       WC_Email_Customer_Note
15
 * @version     2.3.0
16
 * @package     WooCommerce/Classes/Emails
17
 * @author      WooThemes
18
 * @extends     WC_Email
19
 */
20
class WC_Email_Customer_Note extends WC_Email {
21
22
	/**
23
	 * Customer note.
24
	 *
25
	 * @var string
26
	 */
27
	public $customer_note;
28
29
	/**
30
	 * Constructor.
31
	 */
32
	public function __construct() {
33
34
		$this->id             = 'customer_note';
35
		$this->customer_email = true;
36
		$this->title          = __( 'Customer note', 'woocommerce' );
37
		$this->description    = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' );
38
39
		$this->template_html  = 'emails/customer-note.php';
40
		$this->template_plain = 'emails/plain/customer-note.php';
41
42
		$this->subject        = __( 'Note added to your {site_title} order from {order_date}', 'woocommerce');
43
		$this->heading        = __( 'A note has been added to your order', 'woocommerce');
44
45
		// Triggers
46
		add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) );
47
48
		// Call parent constructor
49
		parent::__construct();
50
	}
51
52
	/**
53
	 * Trigger.
54
	 *
55
	 * @param array $args
56
	 */
57
	public function trigger( $args ) {
58
59
		if ( $args ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $args of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
60
61
			$defaults = array(
62
				'order_id'      => '',
63
				'customer_note' => ''
64
			);
65
66
			$args = wp_parse_args( $args, $defaults );
67
68
			extract( $args );
69
70
			if ( $order_id && ( $this->object = wc_get_order( $order_id ) ) ) {
0 ignored issues
show
Documentation Bug introduced by
It seems like wc_get_order($order_id) can also be of type false. However, the property $object is declared as type object. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
71
				$this->recipient               = $this->object->billing_email;
72
				$this->customer_note           = $customer_note;
73
74
				$this->find['order-date']      = '{order_date}';
75
				$this->find['order-number']    = '{order_number}';
76
77
				$this->replace['order-date']   = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
78
				$this->replace['order-number'] = $this->object->get_order_number();
79
			} else {
80
				return;
81
			}
82
		}
83
84
		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
85
			return;
86
		}
87
88
		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
89
	}
90
91
	/**
92
	 * Get content html.
93
	 *
94
	 * @access public
95
	 * @return string
96
	 */
97
	public function get_content_html() {
98
		return wc_get_template_html( $this->template_html, array(
99
			'order'         => $this->object,
100
			'email_heading' => $this->get_heading(),
101
			'customer_note' => $this->customer_note,
102
			'sent_to_admin' => false,
103
			'plain_text'    => false,
104
			'email'			=> $this
105
		) );
106
	}
107
108
	/**
109
	 * Get content plain.
110
	 *
111
	 * @access public
112
	 * @return string
113
	 */
114
	public function get_content_plain() {
115
		return wc_get_template_html( $this->template_plain, array(
116
			'order'         => $this->object,
117
			'email_heading' => $this->get_heading(),
118
			'customer_note' => $this->customer_note,
119
			'sent_to_admin' => false,
120
			'plain_text'    => true,
121
			'email'			=> $this
122
		) );
123
	}
124
}
125
126
endif;
127
128
return new WC_Email_Customer_Note();
129