Issues (214)

Security Analysis    no request data  

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.

src/Extensions/Woocommerce/Functions.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
 * m'Manager | Invoices Management System
4
 * 
5
 * This content is released under the Proprietary License (Proprietary)
6
 *
7
 * Copyright (c) 2017, Eric Claver AKAFFOU - All Rights Reserved
8
 * Unauthorized copying of this file, via any medium is strictly prohibited
9
 * Proprietary and confidential
10
 * 
11
 * @package m'Manager
12
 * @author  Eric Claver AKAFFOU
13
 * @copyright   Copyright (c) 2017, on'Eric Computing, Inc. (https://www.onericcomputing.com/)
14
 * @license https://www.mmanager.fr  Proprietary License
15
 * @link    https://codecanyon.net/item/mmanager-invoices-management-system/19866435?s_rank=1
16
 * @since   Version 1.0.0
17
 * @filesource
18
 */
19
20
namespace Mmanager\Extensions\Woocommerce;
21
use Mmanager\Extensions\Database\Builder;
22
use Automattic\WooCommerce\HttpClient\HttpClientException;
23
use Automattic\WooCommerce\Client;
24
25
class Functions {
26
	protected $db;
27
	protected $builder;
28
	protected $options;
29
	
30
	public function __construct() {
31
		$this->builder = new Builder('woocommerce');
32
		$this->db = $this->builder->getDB();
33
		$this->options = $this->getOptions();
34
	}
35
	public function getUserKeys() {
36
		return array(
37
			'store_url' => $this->getOption('home'),
38
			'consumer_key' => $this->getOption('wpt_wc_api_consumer_consumer_key'),
39
			'consumer_secret' => $this->getOption('wpt_wc_api_consumer_consumer_secret')
40
		);
41
	}
42
	public function get($endpoint, $params) {
43
		if ($this->synched()) {
44
			try {
45
				// Array of response results.
46
				$woocommerce = $this->wc_api_connect();
47
				$results = $woocommerce->get($endpoint, $params);
48
				// Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ...
49
50
				// Last request data.
51
				$lastRequest = $woocommerce->http->getRequest();
52
				$lastRequest->getUrl(); // Requested URL (string).
53
				$lastRequest->getMethod(); // Request method (string).
54
				$lastRequest->getParameters(); // Request parameters (array).
55
				$lastRequest->getHeaders(); // Request headers (array).
56
				$lastRequest->getBody(); // Request body (JSON).
57
58
				// Last response data.
59
				$lastResponse = $woocommerce->http->getResponse();
60
				$lastResponse->getCode(); // Response code (int).
61
				$lastResponse->getHeaders(); // Response headers (array).
62
				$lastResponse->getBody(); // Response body (JSON).
63
64
				return $results;
65
66
			} catch (HttpClientException $e) {
0 ignored issues
show
The class Automattic\WooCommerce\H...ent\HttpClientException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
67
				$e->getMessage(); // Error message.
68
				$e->getRequest(); // Last request data.
69
				$e->getResponse(); // Last response data.
70
			}
71
		}
72
	}
73
	public function post($endpoint, $data) {
74
		if ($this->synched()) {
75
			$woocommerce = $this->wc_api_connect();
76
			return $woocommerce->post($endpoint, $data);
77
		}
78
	}
79
	public function put($endpoint, $data) {
80
		if ($this->synched()) {
81
			$woocommerce = $this->wc_api_connect();
82
			return $woocommerce->put($endpoint, $data);
83
		}
84
	}
85
	public function delete($endpoint, $params = []) {
0 ignored issues
show
The parameter $params 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...
86
		if ($this->synched()) {
87
			$woocommerce = $this->wc_api_connect();
88
			return $woocommerce->delete($endpoint, $params = []);
89
		}
90
	}
91
	public function options($endpoint) {
92
		if ($this->synched()) {
93
			$woocommerce = $this->wc_api_connect();
94
			return $woocommerce->options($endpoint);
95
		}
96
	}
97
	public function getOrdersID() {
98
		$ids = [];
99
		$query = "SELECT ID FROM wp_posts where post_type = 'shop_order'";
100
		$results = $this->db->get_results($query);
101
		if ($results) {
102
			foreach ($results as $id) {
103
				array_push($ids, $id->ID);
104
			}
105
		}
106
		return $ids;
107
	}
108
	public function getOptions() {
109
		$query = "SELECT * FROM wp_options";
110
		return $this->db->get_results($query);
111
	}
112
	public function getOption($option_name) {
113
		$options = $this->getOptions();
114
		foreach ($options as $option) {
115
			if ($option->option_name == $option_name) {
116
				return $option->option_value;
117
			}
118
		}
119
	}
120
	public function synched() {
121
		$options = $this->options;
122
		foreach ($options as $option) {
123
			if ($option->option_name === 'wpt_wc_mmanager_connect_sync_data' && $option->option_value == 'on') {
124
				return true;
125
			}
126
		}
127
	}
128
	/**
129
	 * Connect to the WooCommerce API.
130
	 *
131
	 * @return \Automattic\WooCommerce\Client|bool
132
	 */
133
	public function wc_api_connect() {
134
		static $connection;
135
	 
136
		if ( isset( $connection ) ) {
137
			return $connection;
138
		}
139
	 
140
		$keys = $this->getUserKeys();
141
142
		if ( ! $keys ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $keys 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...
143
			$connection = false;
144
	 
145
			return $connection;
146
		}
147
	 
148
		$connection = new Client(
149
			$keys['store_url'],
150
			$keys['consumer_key'],
151
			$keys['consumer_secret'],
152
			array(
153
				'wp_api'     => true,
154
				'version'    => 'wc/v2',
155
				'verify_ssl' => false, // Allow self-signed certificates (remove for prod)
156
			)
157
		);
158
	 
159
		return $connection;
160
	}
161
}
162
163