Issues (10)

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.

php/class-fragment-cache.php (1 issue)

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
namespace Rarst\Fragment_Cache;
4
5
/**
6
 * Abstract base class for implementation of fragment type handler.
7
 */
8
abstract class Fragment_Cache {
9
10
	/** @var bool $in_callback Static flag to catch and prevent nested caching calls.  */
11
	static $in_callback = false;
0 ignored issues
show
The visibility should be declared for property $in_callback.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
12
13
	/** @var int $timeout Cache timeout duration.  */
14
	public $timeout;
15
16
	/** @var string $type Handler type name. */
17
	protected $type;
18
19
	/**
20
	 * Create object and set parameters from passed.
21
	 *
22
	 * @param array $args Configuration arguments.
23
	 */
24
	public function __construct( $args ) {
25
26
		$this->type    = $args['type'];
27
		$this->timeout = $args['timeout'];
28
	}
29
30
	/**
31
	 * Enable fragment handler.
32
	 */
33
	abstract public function enable();
34
35
	/**
36
	 * Disable fragment handler.
37
	 */
38
	abstract public function disable();
39
40
	/**
41
	 * Wrapper to retrieve data through TLC Transient.
42
	 *
43
	 * @param string $name Name of fragment.
44
	 * @param array  $args Arguments.
45
	 * @param mixed  $salt Optional salt data.
46
	 *
47
	 * @return mixed
48
	 */
49
	public function fetch( $name, $args, $salt = '' ) {
50
51
		global $current_user;
52
53
		static $empty_user;
54
55
		if ( self::$in_callback || apply_filters( 'fc_skip_cache', false, $this->type, $name, $args, $salt ) ) {
56
			return $this->callback( $name, $args );
57
		}
58
59
		// Anonymize front-end run for consistency.
60
		if ( is_user_logged_in() ) {
61
62
			if ( empty( $empty_user ) ) {
63
				$empty_user = new \WP_User( 0 );
64
			}
65
66
			$stored_user  = $current_user;
67
			$current_user = $empty_user;
68
		}
69
70
		$salt   = maybe_serialize( $salt );
71
		$output = tlc_transient( 'fragment-cache-' . $this->type . '-' . $name . $salt )
72
				->updates_with( array( $this, 'wrap_callback' ), array( $name, $args ) )
73
				->expires_in( $this->timeout )
74
				->get();
75
76
		if ( ! empty( $stored_user ) ) {
77
			$current_user = $stored_user;
78
		}
79
80
		return $output;
81
	}
82
83
	/**
84
	 * Wraps callback to correctly set execution flag.
85
	 *
86
	 * @param string $name Fragment name.
87
	 * @param array  $args Arguments.
88
	 *
89
	 * @return string
90
	 */
91
	public function wrap_callback( $name, $args ) {
92
93
		self::$in_callback = true;
94
		$output = $this->callback( $name, $args );
95
		self::$in_callback = false;
96
97
		return $output;
98
	}
99
100
	/**
101
	 * Used to generate data to be cached.
102
	 *
103
	 * @param string $name Fragment name.
104
	 * @param array  $args Arguments.
105
	 *
106
	 * @return string
107
	 */
108
	abstract protected function callback( $name, $args );
109
110
	/**
111
	 * Get human-readable HTML comment with timestamp to append to cached fragment.
112
	 *
113
	 * @param string $name Fragment name.
114
	 *
115
	 * @return string
116
	 */
117
	public function get_comment( $name ) {
118
119
		return '<!-- ' . esc_html( $name ) . ' ' . esc_html( $this->type ) . ' cached on ' . date_i18n( DATE_RSS ) . ' -->';
120
	}
121
}
122