Issues (4122)

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/skins/QuickTemplate.php (2 issues)

Labels
Severity

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
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 * http://www.gnu.org/copyleft/gpl.html
17
 *
18
 * @file
19
 */
20
21
/**
22
 * Generic wrapper for template functions, with interface
23
 * compatible with what we use of PHPTAL 0.7.
24
 * @ingroup Skins
25
 */
26
abstract class QuickTemplate {
27
28
	/** @var Config $config */
29
	protected $config;
30
31
	/**
32
	 * @param Config $config
33
	 */
34
	function __construct( Config $config = null ) {
35
		$this->data = [];
0 ignored issues
show
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
36
		$this->translator = new MediaWikiI18N();
0 ignored issues
show
The property translator does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37 View Code Duplication
		if ( $config === null ) {
38
			wfDebug( __METHOD__ . ' was called with no Config instance passed to it' );
39
			$config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
40
		}
41
		$this->config = $config;
42
	}
43
44
	/**
45
	 * Sets the value $value to $name
46
	 * @param string $name
47
	 * @param mixed $value
48
	 */
49
	public function set( $name, $value ) {
50
		$this->data[$name] = $value;
51
	}
52
53
	/**
54
	* extends the value of data with name $name with the value $value
55
	* @since 1.25
56
	* @param string $name
57
	* @param mixed $value
58
	*/
59
	public function extend( $name, $value ) {
60
		if ( $this->haveData( $name ) ) {
61
			$this->data[$name] = $this->data[$name] . $value;
62
		} else {
63
			$this->data[$name] = $value;
64
		}
65
	}
66
67
	/**
68
	 * Gets the template data requested
69
	 * @since 1.22
70
	 * @param string $name Key for the data
71
	 * @param mixed $default Optional default (or null)
72
	 * @return mixed The value of the data requested or the deafult
73
	 */
74 View Code Duplication
	public function get( $name, $default = null ) {
75
		if ( isset( $this->data[$name] ) ) {
76
			return $this->data[$name];
77
		} else {
78
			return $default;
79
		}
80
	}
81
82
	/**
83
	 * @param string $name
84
	 * @param mixed $value
85
	 */
86
	public function setRef( $name, &$value ) {
87
		$this->data[$name] =& $value;
88
	}
89
90
	/**
91
	 * @param MediaWikiI18N $t
92
	 */
93
	public function setTranslator( &$t ) {
94
		$this->translator = &$t;
95
	}
96
97
	/**
98
	 * Main function, used by classes that subclass QuickTemplate
99
	 * to show the actual HTML output
100
	 */
101
	abstract public function execute();
102
103
	/**
104
	 * @private
105
	 * @param string $str
106
	 */
107
	function text( $str ) {
108
		echo htmlspecialchars( $this->data[$str] );
109
	}
110
111
	/**
112
	 * @private
113
	 * @param string $str
114
	 */
115
	function html( $str ) {
116
		echo $this->data[$str];
117
	}
118
119
	/**
120
	 * @private
121
	 * @param string $str
122
	 */
123
	function msg( $str ) {
124
		echo htmlspecialchars( $this->translator->translate( $str ) );
125
	}
126
127
	/**
128
	 * @private
129
	 * @param string $str
130
	 */
131
	function msgHtml( $str ) {
132
		echo $this->translator->translate( $str );
133
	}
134
135
	/**
136
	 * An ugly, ugly hack.
137
	 * @private
138
	 * @param string $str
139
	 */
140
	function msgWiki( $str ) {
141
		global $wgOut;
142
143
		$text = $this->translator->translate( $str );
144
		echo $wgOut->parse( $text );
145
	}
146
147
	/**
148
	 * @private
149
	 * @param string $str
150
	 * @return bool
151
	 */
152
	function haveData( $str ) {
153
		return isset( $this->data[$str] );
154
	}
155
156
	/**
157
	 * @private
158
	 *
159
	 * @param string $str
160
	 * @return bool
161
	 */
162
	function haveMsg( $str ) {
163
		$msg = $this->translator->translate( $str );
164
		return ( $msg != '-' ) && ( $msg != '' ); # ????
165
	}
166
167
	/**
168
	 * Get the Skin object related to this object
169
	 *
170
	 * @return Skin
171
	 */
172
	public function getSkin() {
173
		return $this->data['skin'];
174
	}
175
176
	/**
177
	 * Fetch the output of a QuickTemplate and return it
178
	 *
179
	 * @since 1.23
180
	 * @return string
181
	 */
182
	public function getHTML() {
183
		ob_start();
184
		$this->execute();
185
		$html = ob_get_contents();
186
		ob_end_clean();
187
		return $html;
188
	}
189
}
190