Issues (10)

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.

lib/IvyCatTestimonialsPosts.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
 * Page Posts Class, main workhorse for the ic_add_testimonials shortcode.
4
 *
5
 * @package     IvyCat AJAX Testimonials
6
 * @author      Eric Amundson <[email protected]>
7
 * @copyright   2017 IvyCat, Inc.
8
 * @license     GPL-2.0+
9
 */
10
11
if ( ! function_exists( 'add_action' ) ) {
12
	wp_die( __( 'You are trying to access this file in a manner not allowed.', 'ivycat-ajax-testimonials' ), __( 'Direct Access Forbidden', 'ivycat-ajax-testimonials' ), array( 'response' => '403' ) );
13
}
14
15
class ICTestimonialPosts {
16
17
	protected $args = array(
18
		'post_type'   => 'testimonials',
19
		'post_status' => 'publish',
20
		'orderby'     => 'date',
21
		'order'       => 'DESC',
22
		'paginate'    => false,
23
		'template'    => false,
24
	); // set defaults for wp_parse_args
25
26
	public function __construct( $atts ) {
27
		self::set_args( $atts );
28
	}
29
30
	/**
31
	 *    Output's the testimonials
32
	 *
33
	 * @return string output of template file
34
	 */
35
	public function output_testimonials() {
36
		if ( ! $this->args ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->args 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...
37
			return '';
38
		}
39
		$page_testimonials = apply_filters( 'testimonials_in_page_results', new WP_Query( $this->args ) ); // New WP_Query object
40
		$output            = '';
41
		if ( $page_testimonials->have_posts() ):
42
			while ( $page_testimonials->have_posts() ):
43
				$output .= self::add_template_part( $page_testimonials );
44
			endwhile;
45
			$output .= ( $this->args['paginate'] ) ? '<div class="pip-nav">' . apply_filters( 'testimonials_in_page_paginate',
46
				$this->paginate_links( $page_testimonials )
47
			) . '</div>' : '';
48
		endif;
49
		wp_reset_postdata();
50
51
		// remove our filters for excerpt more and length
52
		remove_filter( 'excerpt_more', array( 'IvyCatTestimonials', 'ivycat_custom_excerpt_more' ) );
53
		remove_filter( 'excerpt_length', array( 'IvyCatTestimonials', 'ivycat_custom_excerpt_length' ) );
54
55
		return $output;
56
	}
57
58
	protected function paginate_links( $posts ) {
59
		global $wp_query;
60
		$page_url    = home_url( '/' . $wp_query->post->post_name . '/' );
61
		$page        = isset( $_GET['page'] ) ? $_GET['page'] : 1;
0 ignored issues
show
$page 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...
62
		$total_pages = $posts->max_num_pages;
63
		$per_page    = $posts->query_vars['posts_per_page'];
0 ignored issues
show
$per_page 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...
64
		$curr_page   = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0 ) ? $posts->query_vars['paged'] : 1;
65
		$prev        = ( $curr_page && $curr_page > 1 ) ? '<li><a href="' . $page_url . '?page=' . ( $curr_page - 1 ) . '">Previous</a></li>' : '';
66
		$next        = ( $curr_page && $curr_page < $total_pages ) ? '<li><a href="' . $page_url . '?page=' . ( $curr_page + 1 ) . '">Next</a></li>' : '';
67
68
		return '<ul>' . $prev . $next . '</ul>';
69
	}
70
71
	/**
72
	 *    Build additional Arguments for the WP_Query object
73
	 *
74
	 * @param array $atts Attritubes for building the $args array.
75
	 */
76
	protected function set_args( $atts ) {
77
		global $wp_query;
78
		$this->args['posts_per_page'] = get_option( 'posts_per_page' );
79
		// parse the arguments using the defaults
80
		$this->args = wp_parse_args( $atts, $this->args );
81
82
		// Use a specified template
83
		if ( isset( $atts['template'] ) ) {
84
			$this->args['template'] = $atts['template'];
85
		}
86
87
		// show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
88
		if ( isset( $atts['showposts'] ) ) {
89
			$this->args['posts_per_page'] = $atts['showposts'];
90
		}
91
92
		// handle pagination (for code, template pagination is in the template)
93
		if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
94
			$this->args['paged'] = $wp_query->query_vars['page'];
95
		}
96
		if ( false !== $atts['group'] ) {
97
			$this->args['tax_query'] = array(
98
				array(
99
					'taxonomy' => 'testimonial-group',
100
					'field'    => is_numeric( $atts['group'] ) ? 'id' : 'slug',
101
					'terms'    => $atts['group'],
102
				)
103
			);
104
		}
105
		$this->args = apply_filters( 'testimonials_in_page_args', $this->args );
106
	}
107
108
	/**
109
	 *    Tests if a theme has a theme template file that exists
110
	 *
111
	 * @return string|false if template exists, false otherwise.
112
	 */
113
	protected function has_theme_template() {
114
		$template_file = ( $this->args['template'] )
115
			? get_stylesheet_directory() . '/' . $this->args['template'] // use specified template file
116
			: get_stylesheet_directory() . '/testimonials-loop-template.php'; // use default template file
117
118
		return ( file_exists( $template_file ) ) ? $template_file : false;
119
	}
120
121
	/**
122
	 *    Retrieves the post loop template and returns the output
123
	 *
124
	 * @return string results of the output
125
	 */
126
	protected function add_template_part( $ic_testimonials, $singles = false ) {
127
		if ( $singles ) {
128
			setup_postdata( $ic_testimonials );
129
		} else {
130
			$ic_testimonials->the_post();
131
		}
132
		$output = '';
133
		ob_start();
134
		$output .= apply_filters( 'testimonials_in_page_pre_loop', '' );
135
		require( $file_path = self::has_theme_template() )
136
			? $file_path // use template file in theme
137
			: ICTESTI_DIR . '/testimonials-loop-template.php'; // use default plugin template file
138
		$output .= ob_get_contents();
139
		$output .= apply_filters( 'testimonials_in_page_post_loop', '' );
140
141
		return ob_get_clean();
142
	}
143
144
}
145