Issues (130)

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.

vendors/class.product-vendors-export-handler.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 12.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Bootstraps the Vendor system
4
 *
5
 * @package     PrintCenter\Vendor
6
 * @since       1.0.0
7
 */
8
9
10
// Exit if accessed directly
11
if( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
/**
16
 * Product Vendors Import/Export Handler
17
 *
18
 * @since 1.0.0
19
 */
20
class WooCommerce_Product_Vendors_Export_Handler {
21
22
23
	/**
24
	 * Setup class
25
	 *
26
	 * @access      public
27
	 * @since       1.0.0
28
	 */
29
	public function __construct() {
30
		// Customer / Order CSV Export column headers/data
31
		add_filter( 'wc_customer_order_csv_export_order_headers', array( $this, 'add_vendors_to_csv_export_column_headers' ), 10, 2 );
32
		add_filter( 'wc_customer_order_csv_export_order_row_one_row_per_item', array( $this, 'add_vendors_to_csv_export_column_data' ), 10, 4 );
33
34
		// Customer / Order CSV Export line item data
35
		add_filter( 'wc_customer_order_csv_export_order_line_item', array( $this, 'csv_export_line_item_data' ), 10, 5 );
36
	}
37
38
39
	/**
40
	 * Adds support for Customer/Order CSV Export by adding a vendor column header
41
	 *
42
	 * @access      public
43
	 * @since       1.0.0
44
	 * @param       array $headers existing array of header key/names for the CSV export
45
	 * @param       WC_Customer_Order_CSV_Export_Generator $csv_generator instance
46
	 * @return      array
47
	 */
48
	public function add_vendors_to_csv_export_column_headers( $headers, $csv_generator ) {
0 ignored issues
show
The parameter $csv_generator 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...
49
		$headers['vendors'] = 'vendors';
50
51
		return $headers;
52
	}
53
54
55
	/**
56
	 * Adds support for Customer/Order CSV Export by adding product vendor data
57
	 * for each order item row
58
	 *
59
	 * @access      public
60
	 * @since       1.0.0
61
	 * @param       array $order_data generated order data matching the column keys in the header
62
	 * @param       array $item data for the specific item
63
	 * @param       WC_Order $order order being exported
64
	 * @param       WC_Customer_Order_CSV_Export_Generator $csv_generator instance
65
	 * @return      array
66
	 */
67
	public function add_vendors_to_csv_export_column_data( $order_data, $item, $order, $csv_generator ) {
0 ignored issues
show
The parameter $order 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...
The parameter $csv_generator 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...
68
		$vendors = array();
69
70
		if ( isset( $item['id'] ) && $product_id = $item['id'] ) {
71
			if ( $product_vendors = get_product_vendors( $product_id ) ) {
72
				foreach ( (array) $product_vendors as $vendor ) {
73
					$vendors[] = $vendor->title;
74
				}
75
			}
76
		}
77
78
		$order_data['vendors'] = implode( ', ', $vendors );
79
80
		return $order_data;
81
	}
82
83
84
	/**
85
	 * Filter the individual line item entry to add product id for older versions
86
	 * of Customer/Order CSV Export
87
	 *
88
	 * @access      public
89
	 * @since       1.0.0
90
	 * @param       array $line_item line item data in key => value format
91
	 * @param       array $item WC order item data
92
	 * @param       WC_Product $product the product
93
	 * @param       WC_Order $order the order
94
	 * @param       WC_Customer_Order_CSV_Export_Generator $csv_generator instance
95
	 * @return      array
96
	 */
97
	public function csv_export_line_item_data( $line_item, $item, $product, $order, $csv_generator ) {
98
		if ( isset( $csv_generator->order_format ) && ( 'default_one_row_per_item' == $csv_generator->order_format || 'legacy_one_row_per_item' == $csv_generator->order_format ) ) {
99
			$line_item['id'] = $product->id;
100
		}
101
102
		return $line_item;
103
	}
104
}
105