Issues (850)

Security Analysis    4 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  Cross-Site Scripting (1)
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.
  Header Injection
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/class-getpaid-template.php (1 issue)

1
<?php
2
if ( ! defined( 'ABSPATH' ) ) {
3
	exit;
4
}
5
6
/**
7
 * Template Class
8
 *
9
 */
10
class GetPaid_Template {
11
12
    /**
13
     * @param string
14
     */
15
    public $templates_dir;
16
17
    /**
18
     * @param string
19
     */
20
    public $templates_url;
21
22
    /**
23
	 * Class constructor.
24
	 *
25
	 * @since 1.0.19
26
	 */
27
	public function __construct() {
28
29
        $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' );
30
        $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' );
31
32
        // Oxygen plugin
33
		if ( defined( 'CT_VERSION' ) ) {
34
			add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 );
35
		}
36
37
    }
38
39
    /**
40
	 * Checks if this is a preview page
41
	 *
42
	 * @since 1.0.19
43
	 * @return bool
44
	 */
45
	public function is_preview() {
46
        return $this->is_divi_preview() ||
47
            $this->is_elementor_preview() ||
48
            $this->is_beaver_preview() ||
49
            $this->is_siteorigin_preview() ||
50
            $this->is_cornerstone_preview() ||
51
            $this->is_fusion_preview() ||
52
            $this->is_oxygen_preview();
53
    }
54
55
    /**
56
	 * Checks if this is an elementor preview page
57
	 *
58
	 * @since 1.0.19
59
	 * @return bool
60
	 */
61
	public function is_elementor_preview() {
62
		return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
63
	}
64
65
	/**
66
	 * Checks if this is a DIVI preview page
67
	 *
68
	 * @since 1.0.19
69
	 * @return bool
70
	 */
71
	public function is_divi_preview() {
72
		return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
73
	}
74
75
	/**
76
	 * Checks if this is a beaver builder preview page
77
	 *
78
	 * @since 1.0.19
79
	 * @return bool
80
	 */
81
	public function is_beaver_preview() {
82
		return isset( $_REQUEST['fl_builder'] );
83
	}
84
85
	/**
86
	 * Checks if this is a siteorigin builder preview page
87
	 *
88
	 * @since 1.0.19
89
	 * @return bool
90
	 */
91
	public function is_siteorigin_preview() {
92
		return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
93
	}
94
95
	/**
96
	 * Checks if this is a cornerstone builder preview page
97
	 *
98
	 * @since 1.0.19
99
	 * @return bool
100
	 */
101
	public function is_cornerstone_preview() {
102
		return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
103
	}
104
105
	/**
106
	 * Checks if this is a fusion builder preview page
107
	 *
108
	 * @since 1.0.19
109
	 * @return bool
110
	 */
111
	public function is_fusion_preview() {
112
		return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
113
	}
114
115
	/**
116
	 * Checks if this is an oxygen builder preview page
117
	 *
118
	 * @since 1.0.19
119
	 * @return bool
120
	 */
121
	public function is_oxygen_preview() {
122
		return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === 'oxy_render_' || substr( $_REQUEST['action'], 0, 10 ) === 'ct_render_' ) );
123
    }
124
125
    /**
126
     * Locates a template path.
127
     *
128
     * @param string $template_name e.g payment-forms/cart.php The template to locate.
129
     * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
130
     * @param string $default_path The root path to the default template. Defaults to invoicing/templates
131
     */
132
	public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
133
134
        // Load the defaults for the template path and default path.
135
        $template_path = empty( $template_path ) ? 'invoicing' : $template_path;
136
        $default_path  = empty( $default_path ) ? $this->templates_dir : $default_path;
137
        $default_path  = apply_filters( 'getpaid_template_default_template_path', $default_path, $template_name );
138
139
        // Is it overidden?
140
        $template = locate_template(
141
            array( trailingslashit( $template_path ) . $template_name, 'wpinv-' . $template_name )
142
        );
143
144
        // If not, load the default template.
145
        if ( empty( $template ) ) {
146
            $template = trailingslashit( $default_path ) . $template_name;
147
        }
148
149
        return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path );
0 ignored issues
show
The call to oxygen_override_template() has too many arguments starting with $template_path. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        return /** @scrutinizer ignore-call */ apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path );

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. Please note the @ignore annotation hint above.

Loading history...
150
    }
151
152
    /**
153
	 * Loads a template
154
	 *
155
	 * @since 1.0.19
156
	 * @return bool
157
	 */
158
	protected function load_template( $template_name, $template_path, $args ) {
159
160
        if ( is_array( $args ) ) {
161
            extract( $args );
162
        }
163
164
        // Fires before loading a template.
165
	    do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
166
167
        // Load the template.
168
	    include $template_path;
169
170
        // Fires after loading a template.
171
        do_action( 'wpinv_after_template_part', $template_name, $template_path, $args );
172
173
    }
174
175
    /**
176
     * Displays a template.
177
     *
178
     * First checks if there is a template overide, if not it loads the default template.
179
     *
180
     * @param string $template_name e.g payment-forms/cart.php The template to locate.
181
     * @param array $args An array of args to pass to the template.
182
     * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
183
     * @param string $default_path The root path to the default template. Defaults to invoicing/templates
184
     */
185
	public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
186
187
        // Locate the template.
188
        $located = $this->locate_template( $template_name, $template_path, $default_path );
189
190
        // Abort if the file does not exist.
191
        if ( ! file_exists( $located ) ) {
192
            getpaid_doing_it_wrong( __METHOD__, sprintf( '<code>%s</code> does not exist.', $located ), '2.0.0' );
193
            return;
194
        }
195
196
        $this->load_template( $template_name, $located, $args );
197
198
    }
199
200
    /**
201
     * Retrieves a template.
202
     *
203
     * First checks if there is a template overide, if not it loads the default template.
204
     *
205
     * @param string $template_name e.g payment-forms/cart.php The template to locate.
206
     * @param array $args An array of args to pass to the template.
207
     * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
208
     * @param string $default_path The root path to the default template. Defaults to invoicing/templates
209
     */
210
	public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
211
        ob_start();
212
        $this->display_template( $template_name, $args, $template_path, $default_path );
213
        return ob_get_clean();
214
    }
215
216
    /**
217
	 * Get the GetPaid templates theme path.
218
	 *
219
	 *
220
	 * @return string Template path.
221
	 */
222
	public static function get_theme_template_path() {
223
		$template   = get_template();
224
		$theme_root = get_theme_root( $template );
225
226
		return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() );
227
228
	}
229
230
	/**
231
	 * Oxygen locate theme template.
232
	 *
233
	 * @param string $template The template.
234
	 * @return string The theme template.
235
	 */
236
	public static function oxygen_locate_template( $template ) {
237
238
		if ( empty( $template ) ) {
239
			return '';
240
		}
241
242
		$has_filter = has_filter( 'template', 'ct_oxygen_template_name' );
243
244
		// Remove template filter
245
		if ( $has_filter ) {
246
			remove_filter( 'template', 'ct_oxygen_template_name' );
247
		}
248
249
		$template = self::get_theme_template_path() . '/' . $template;
250
251
		if ( ! file_exists( $template ) ) {
252
			$template = '';
253
		}
254
255
		// Add template filter
256
		if ( $has_filter ) {
257
			add_filter( 'template', 'ct_oxygen_template_name' );
258
		}
259
260
		return $template;
261
	}
262
263
	/**
264
	 * Oxygen override theme template.
265
	 *
266
	 * @param string $located Located template.
267
	 * @param string $template_name Template name.
268
	 * @return string Located template.
269
	 */
270
	public function oxygen_override_template( $located, $template_name ) {
271
272
        $oxygen_overide = self::oxygen_locate_template( $template_name );
273
		if ( ! empty( $oxygen_overide ) ) {
274
			return $oxygen_overide;
275
		}
276
277
		return $located;
278
	}
279
280
}
281