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.

payment-tokens/class-wc-payment-token-cc.php (13 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
if ( ! defined( 'ABSPATH' ) ) {
3
	exit; // Exit if accessed directly
4
}
5
6
/**
7
 * WooCommerce Credit Card Payment Token.
8
 *
9
 * Representation of a payment token for credit cards.
10
 *
11
 * @class 		WC_Payment_Token_CC
12
 * @since		2.6.0
13
 * @category 	PaymentTokens
14
 * @package 	WooCommerce/PaymentTokens
15
 * @author		WooThemes
16
 */
17
class WC_Payment_Token_CC extends WC_Payment_Token {
18
19
	/** @protected string Token Type String. */
20
	protected $type = 'CC';
21
22
 	/**
0 ignored issues
show
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
23
	 * Validate credit card payment tokens.
24
	 *
25
	 * These fields are required by all credit card payment tokens:
26
	 * expiry_month  - string Expiration date (MM) for the card
27
	 * expiry_year   - string Expiration date (YYYY) for the card
28
	 * last4         - string Last 4 digits of the card
29
	 * card_type     - string Card type (visa, mastercard, etc)
30
	 *
31
	 * @since 2.6.0
32
	 * @return boolean True if the passed data is valid
33
	 */
34
	public function validate() {
35
		if ( false === parent::validate() ) {
36
			return false;
37
		}
38
39
		if ( ! $this->get_last4() ) {
40
			return false;
41
		}
42
43
		if ( ! $this->get_expiry_year() ) {
44
			return false;
45
		}
46
47
		if ( ! $this->get_expiry_month() ) {
48
			return false;
49
		}
50
51
		if ( ! $this->get_card_type() ) {
52
			return false;
53
		}
54
55
		if ( 4 !== strlen( $this->get_expiry_year() ) ) {
56
			return false;
57
		}
58
59
		if ( 2 !== strlen( $this->get_expiry_month() ) ) {
60
			return false;
61
		}
62
63
		return true;
64
	}
65
66
	/**
67
	 * Get type to display to user.
68
	 * @return string
69
	 */
70
	public function get_display_name() {
71
		$display = wc_get_credit_card_type_label( $this->get_card_type() );
72
		$display .= '&nbsp;' . sprintf( __( 'ending in %s', 'woocommerce' ), $this->get_last4() );
73
		$display .= ' ' . sprintf( __( '(expires %s)', 'woocommerce' ), $this->get_expiry_month() . '/' . substr( $this->get_expiry_year(), 2 ) );
74
		return $display;
75
	}
76
77
	/**
78
	 * Returns the card type (mastercard, visa, ...).
79
	 * @since 2.6.0
80
	 * @return string Card type
81
	 */
82
	public function get_card_type() {
83
		return $this->get_meta( 'card_type' );
84
	}
85
86
	/**
87
	 * Set the card type (mastercard, visa, ...).
88
	 * @since 2.6.0
89
	 * @param string $type
90
	 */
91
	public function set_card_type( $type ) {
92
		$this->add_meta_data( 'card_type', $type, true );
0 ignored issues
show
'card_type' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$type is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
true is of type boolean, but the function expects a false|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
93
	}
94
95
	/**
96
	 * Returns the card expiration year (YYYY).
97
	 * @since 2.6.0
98
	 * @return string Expiration year
99
	 */
100
	public function get_expiry_year() {
101
		return $this->get_meta( 'expiry_year' );
102
	}
103
104
	/**
105
	 * Set the expiration year for the card (YYYY format).
106
	 * @since 2.6.0
107
	 * @param string $year
108
	 */
109
	public function set_expiry_year( $year ) {
110
		$this->add_meta_data( 'expiry_year', $year, true );
0 ignored issues
show
'expiry_year' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$year is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
true is of type boolean, but the function expects a false|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
111
	}
112
113
	/**
114
	 * Returns the card expiration month (MM).
115
	 * @since 2.6.0
116
	 * @return string Expiration month
117
	 */
118
	public function get_expiry_month() {
119
		return $this->get_meta( 'expiry_month' );
120
	}
121
122
	/**
123
	 * Set the expiration month for the card (formats into MM format).
124
	 * @since 2.6.0
125
	 * @param string $month
126
	 */
127
	public function set_expiry_month( $month ) {
128
		$this->add_meta_data( 'expiry_month', str_pad( $month, 2, '0', STR_PAD_LEFT ), true );
0 ignored issues
show
'expiry_month' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
str_pad($month, 2, '0', STR_PAD_LEFT) is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
true is of type boolean, but the function expects a false|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
129
	}
130
131
	/**
132
	 * Returns the last four digits.
133
	 * @since 2.6.0
134
	 * @return string Last 4 digits
135
	 */
136
	public function get_last4() {
137
		return $this->get_meta( 'last4' );
138
	}
139
140
	/**
141
	 * Set the last four digits.
142
	 * @since 2.6.0
143
	 * @param string $last4
144
	 */
145
	public function set_last4( $last4 ) {
146
		$this->add_meta_data( 'last4', $last4, true );
0 ignored issues
show
'last4' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$last4 is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
true is of type boolean, but the function expects a false|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
147
	}
148
149
}
150