Issues (4335)

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/donors/actions.php (16 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
 * Insert donor comment to donation.
4
 *
5
 * @since 2.2.0
6
 *
7
 * @param int   $donation_id
8
 * @param array $donation_data
9
 *
10
 */
11
function __give_insert_donor_donation_comment( $donation_id, $donation_data ) {
12
	$is_anonymous_donation = isset( $_POST['give_anonymous_donation'] )
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
13
		? absint( $_POST['give_anonymous_donation'] )
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
14
		: 0;
15
16
	if ( ! empty( $_POST['give_comment'] ) ) {
17
		$comment_meta = array( 'author_email' => $donation_data['user_info']['email'] );
18
19
		if( ! give_has_upgrade_completed('v230_move_donation_note' ) ) {
0 ignored issues
show
Space after opening control structure is required
Loading history...
No space before opening parenthesis is prohibited
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
20
			// Backward compatibility.
21
			$comment_meta = array( 'comment_author_email' => $donation_data['user_info']['email'] );
22
		}
23
24
		$comment_id = give_insert_donor_donation_comment(
0 ignored issues
show
$comment_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
			$donation_id,
26
			$donation_data['user_info']['donor_id'],
27
			trim( $_POST['give_comment'] ), // We are sanitizing comment in Give_comment:add
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
Detected usage of a non-sanitized input variable: $_POST
Loading history...
28
			$comment_meta
29
		);
30
	}
31
32
	give_update_meta( $donation_id, '_give_anonymous_donation', $is_anonymous_donation );
33
}
34
35
add_action( 'give_insert_payment', '__give_insert_donor_donation_comment', 10, 2 );
36
37
38
/**
39
 * Validate donor comment
40
 *
41
 * @since 2.2.0
42
 */
43
function __give_validate_donor_comment() {
44
	// Check wp_check_comment_data_max_lengths for comment length validation.
45
	if ( ! empty( $_POST['give_comment'] ) ) {
46
		$max_lengths = wp_get_comment_fields_max_lengths();
47
		$comment     = give_clean( $_POST['give_comment'] );
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
Detected usage of a non-sanitized input variable: $_POST
Loading history...
48
49
		if ( mb_strlen( $comment, '8bit' ) > $max_lengths['comment_content'] ) {
50
			give_set_error( 'comment_content_column_length', __( 'Your comment is too long.', 'give' ) );
51
		}
52
	}
53
}
54
add_action( 'give_checkout_error_checks', '__give_validate_donor_comment', 10, 1 );
55
56
57
/**
58
 * Update donor comment status when donation status update
59
 *
60
 * @since 2.2.0
61
 *
62
 * @param $donation_id
63
 * @param $status
64
 */
65
function __give_update_donor_donation_comment_status( $donation_id, $status ) {
66
	$approve = absint( 'publish' === $status );
67
68
	/* @var WP_Comment $note */
69
	$donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) );
70
71
	if( $donor_comment instanceof WP_Comment ) {
0 ignored issues
show
The class WP_Comment does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Space after opening control structure is required
Loading history...
No space before opening parenthesis is prohibited
Loading history...
72
		wp_set_comment_status( $donor_comment->comment_ID, (string) $approve );
73
	}
74
}
75
76
add_action( 'give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2 );
77
78
/**
79
 * Remove donor comment when donation delete
80
 *
81
 * @since 2.2.0
82
 *
83
 * @param $donation_id
84
 */
85
function __give_remove_donor_donation_comment( $donation_id ) {
86
	/* @var WP_Comment $note */
87
	$donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) );
88
89
	if( $donor_comment instanceof WP_Comment ) {
0 ignored issues
show
The class WP_Comment does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Space after opening control structure is required
Loading history...
No space before opening parenthesis is prohibited
Loading history...
90
		wp_delete_comment( $donor_comment->comment_ID );
91
	}
92
}
93
94
add_action( 'give_payment_deleted', '__give_remove_donor_donation_comment', 10 );
95