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.

abstract-wc-stripe-connect-rest-controller.php (3 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;
5
}
6
7
/**
8
 * Stripe Connect base REST controller class.
9
 */
10
abstract class WC_Stripe_Connect_REST_Controller extends WP_REST_Controller {
11
12
	/**
13
	 * Endpoint namespace.
14
	 *
15
	 * @var string
16
	 */
17
	protected $namespace = 'wc/v1';
18
19
	/**
20
	 * Stripe connect api.
21
	 *
22
	 * @var object $api
23
	 */
24
	private $api;
25
26
	/**
27
	 * Constructor.
28
	 *
29
	 * @param WC_Stripe_Connect_API $api stripe connect api.
30
	 */
31
	public function __construct( WC_Stripe_Connect_API $api ) {
32
33
		$this->api = $api;
34
	}
35
36
	/**
37
	 * Registers rest routes for stripe connect functionality
38
	 */
39
	public function register_routes() {
40
41 View Code Duplication
		if ( method_exists( $this, 'get' ) ) {
0 ignored issues
show
This code seems to be duplicated across 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...
42
			register_rest_route(
43
				$this->namespace,
44
				'/' . $this->rest_base,
45
				array(
46
					array(
47
						'methods'             => 'GET',
48
						'callback'            => array( $this, 'get_internal' ),
49
						'permission_callback' => array( $this, 'check_permission' ),
50
					),
51
				)
52
			);
53
		}
54
55 View Code Duplication
		if ( method_exists( $this, 'post' ) ) {
0 ignored issues
show
This code seems to be duplicated across 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...
56
			register_rest_route(
57
				$this->namespace,
58
				'/' . $this->rest_base,
59
				array(
60
					array(
61
						'methods'             => 'POST',
62
						'callback'            => array( $this, 'post_internal' ),
63
						'permission_callback' => array( $this, 'check_permission' ),
64
					),
65
				)
66
			);
67
		}
68
69 View Code Duplication
		if ( method_exists( $this, 'delete' ) ) {
0 ignored issues
show
This code seems to be duplicated across 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...
70
			register_rest_route(
71
				$this->namespace,
72
				'/' . $this->rest_base,
73
				array(
74
					array(
75
						'methods'             => 'DELETE',
76
						'callback'            => array( $this, 'delete_internal' ),
77
						'permission_callback' => array( $this, 'check_permission' ),
78
					),
79
				)
80
			);
81
		}
82
	}
83
84
	/**
85
	 * Send get request.
86
	 *
87
	 * @param array $request request.
88
	 *
89
	 * @return array
90
	 */
91
	public function get_internal( $request ) {
92
93
		$this->prevent_route_caching();
94
95
		return $this->get( $request );
96
	}
97
98
	/**
99
	 * Send post request.
100
	 *
101
	 * @param array $request request.
102
	 *
103
	 * @return array
104
	 */
105
	public function post_internal( $request ) {
106
107
		$this->prevent_route_caching();
108
109
		return $this->post( $request );
110
	}
111
112
	/**
113
	 * Sends delete request.
114
	 *
115
	 * @param array $request request.
116
	 *
117
	 * @return array
118
	 */
119
	public function delete_internal( $request ) {
120
121
		$this->prevent_route_caching();
122
123
		return $this->delete( $request );
124
	}
125
126
	/**
127
	 * Validate the requester's permissions
128
	 *
129
	 * @param array $request request.
130
	 *
131
	 * @return bool
132
	 */
133
	public function check_permission( $request ) {
134
135
		return current_user_can( 'manage_woocommerce' );
136
	}
137
138
	/**
139
	 * Consolidate cache prevention mechanisms.
140
	 */
141
	public function prevent_route_caching() {
142
143
		if ( ! defined( 'DONOTCACHEPAGE' ) ) {
144
			define( 'DONOTCACHEPAGE', true ); // Play nice with WP-Super-Cache.
145
		}
146
147
		// Prevent our REST API endpoint responses from being added to browser cache.
148
		add_filter( 'rest_post_dispatch', array( $this, 'send_nocache_header' ), PHP_INT_MAX, 2 );
149
	}
150
151
	/**
152
	 * Send a no-cache header for WCS REST API responses. Prompted by cache issues
153
	 * on the Pantheon hosting platform.
154
	 *
155
	 * See: https://pantheon.io/docs/cache-control/
156
	 *
157
	 * @param  WP_REST_Response $response REST API response.
158
	 * @param  WP_REST_Server   $server   server.
159
	 *
160
	 * @return WP_REST_Response passthrough $response parameter
161
	 */
162
	public function send_nocache_header( $response, $server ) {
163
164
		$server->send_header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
165
166
		return $response;
167
	}
168
}
169