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/admin/settings/class-wc-settings-api.php (4 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
 * WooCommerce API Settings
4
 *
5
 * @author   WooThemes
6
 * @category Admin
7
 * @package  WooCommerce/Admin
8
 * @version  2.4.0
9
 */
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit; // Exit if accessed directly
13
}
14
15
if ( ! class_exists( 'WC_Settings_Rest_API' ) ) :
16
17
/**
18
 * WC_Settings_Rest_API.
19
 */
20
class WC_Settings_Rest_API extends WC_Settings_Page {
21
22
	/**
23
	 * Constructor.
24
	 */
25 View Code Duplication
	public function __construct() {
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...
26
		$this->id    = 'api';
27
		$this->label = __( 'API', 'woocommerce' );
28
29
		add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
30
		add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
31
		add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
32
		add_action( 'woocommerce_settings_form_method_tab_' . $this->id, array( $this, 'form_method' ) );
33
		add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
34
35
		$this->notices();
36
	}
37
38
	/**
39
	 * Get sections.
40
	 *
41
	 * @return array
42
	 */
43
	public function get_sections() {
44
		$sections = array(
45
			''         => __( 'Settings', 'woocommerce' ),
46
			'keys'     => __( 'Keys/Apps', 'woocommerce' ),
47
			'webhooks' => __( 'Webhooks', 'woocommerce' )
48
		);
49
50
		return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
51
	}
52
53
	/**
54
	 * Get settings array.
55
	 *
56
	 * @return array
57
	 */
58
	public function get_settings() {
59
		$settings = apply_filters( 'woocommerce_settings_rest_api', array(
60
			array(
61
				'title' => __( 'General Options', 'woocommerce' ),
62
				'type'  => 'title',
63
				'desc'  => '',
64
				'id'    => 'general_options'
65
			),
66
67
			array(
68
				'title'   => __( 'API', 'woocommerce' ),
69
				'desc'    => __( 'Enable the REST API', 'woocommerce' ),
70
				'id'      => 'woocommerce_api_enabled',
71
				'type'    => 'checkbox',
72
				'default' => 'yes',
73
			),
74
75
			array(
76
				'type' => 'sectionend',
77
				'id' => 'general_options'
78
			),
79
		) );
80
81
		return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
82
	}
83
84
	/**
85
	 * Form method.
86
	 *
87
	 * @param  string $method
88
	 *
89
	 * @return string
90
	 */
91
	public function form_method( $method ) {
0 ignored issues
show
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
		global $current_section;
93
94 View Code Duplication
		if ( 'webhooks' == $current_section ) {
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...
95
			if ( isset( $_GET['edit-webhook'] ) ) {
96
				$webhook_id = absint( $_GET['edit-webhook'] );
97
				$webhook    = new WC_Webhook( $webhook_id );
98
99
				if ( 'trash' != $webhook->post_data->post_status ) {
100
					return 'post';
101
				}
102
			}
103
104
			return 'get';
105
		}
106
107
		if ( 'keys' == $current_section ) {
108
			if ( isset( $_GET['create-key'] ) || isset( $_GET['edit-key'] ) ) {
109
				return 'post';
110
			}
111
112
			return 'get';
113
		}
114
115
		return 'post';
116
	}
117
118
	/**
119
	 * Notices.
120
	 */
121
	private function notices() {
122
		if ( isset( $_GET['section'] ) && 'webhooks' == $_GET['section'] ) {
123
			WC_Admin_Webhooks::notices();
124
		}
125
		if ( isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
126
			WC_Admin_API_Keys::notices();
127
		}
128
	}
129
130
	/**
131
	 * Output the settings.
132
	 */
133
	public function output() {
134
		global $current_section;
135
136
		if ( 'webhooks' == $current_section ) {
137
			WC_Admin_Webhooks::page_output();
138
		} else if ( 'keys' == $current_section ) {
139
			WC_Admin_API_Keys::page_output();
140
		} else {
141
			$settings = $this->get_settings( $current_section );
0 ignored issues
show
The call to WC_Settings_Rest_API::get_settings() has too many arguments starting with $current_section.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
142
			WC_Admin_Settings::output_fields( $settings );
143
		}
144
	}
145
146
	/**
147
	 * Save settings.
148
	 */
149
	public function save() {
150
		global $current_section;
151
152
		if ( apply_filters( 'woocommerce_rest_api_valid_to_save', ! in_array( $current_section, array( 'keys', 'webhooks' ) ) ) ) {
153
			$settings = $this->get_settings();
154
			WC_Admin_Settings::save_fields( $settings );
155
		}
156
	}
157
}
158
159
endif;
160
161
return new WC_Settings_Rest_API();
162