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.

maintenance/parse.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 59 and the first side effect is on line 52.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

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

Loading history...
2
/**
3
 * Parse some wikitext.
4
 *
5
 * Wikitext can be given by stdin or using a file. The wikitext will be parsed
6
 * using 'CLIParser' as a title. This can be overridden with --title option.
7
 *
8
 * Example1:
9
 * @code
10
 * $ php parse.php --title foo
11
 * ''[[foo]]''^D
12
 * <p><i><strong class="selflink">foo</strong></i>
13
 * </p>
14
 * @endcode
15
 *
16
 * Example2:
17
 * @code
18
 * $ echo "'''bold'''" > /tmp/foo.txt
19
 * $ php parse.php /tmp/foo.txt
20
 * <p><b>bold</b>
21
 * </p>$
22
 * @endcode
23
 *
24
 * Example3:
25
 * @code
26
 * $ cat /tmp/foo | php parse.php
27
 * <p><b>bold</b>
28
 * </p>$
29
 * @endcode
30
 *
31
 * This program is free software; you can redistribute it and/or modify
32
 * it under the terms of the GNU General Public License as published by
33
 * the Free Software Foundation; either version 2 of the License, or
34
 * (at your option) any later version.
35
 *
36
 * This program is distributed in the hope that it will be useful,
37
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
 * GNU General Public License for more details.
40
 *
41
 * You should have received a copy of the GNU General Public License along
42
 * with this program; if not, write to the Free Software Foundation, Inc.,
43
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
44
 * http://www.gnu.org/copyleft/gpl.html
45
 *
46
 * @file
47
 * @ingroup Maintenance
48
 * @author Antoine Musso <hashar at free dot fr>
49
 * @license GNU General Public License 2.0 or later
50
 */
51
52
require_once __DIR__ . '/Maintenance.php';
53
54
/**
55
 * Maintenance script to parse some wikitext.
56
 *
57
 * @ingroup Maintenance
58
 */
59
class CLIParser extends Maintenance {
60
	protected $parser;
61
62
	public function __construct() {
63
		parent::__construct();
64
		$this->addDescription( 'Parse a given wikitext' );
65
		$this->addOption(
66
			'title',
67
			'Title name for the given wikitext (Default: \'CLIParser\')',
68
			false,
69
			true
70
		);
71
		$this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
72
	}
73
74
	public function execute() {
75
		$this->initParser();
76
		print $this->render( $this->Wikitext() );
77
	}
78
79
	/**
80
	 * @param string $wikitext Wikitext to get rendered
81
	 * @return string HTML Rendering
82
	 */
83
	public function render( $wikitext ) {
84
		return $this->parse( $wikitext )->getText();
85
	}
86
87
	/**
88
	 * Get wikitext from a the file passed as argument or STDIN
89
	 * @return string Wikitext
90
	 */
91
	protected function Wikitext() {
92
		$php_stdin = 'php://stdin';
93
		$input_file = $this->getArg( 0, $php_stdin );
94
95
		if ( $input_file === $php_stdin && !$this->mQuiet ) {
96
			$ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
97
			$this->error( basename( __FILE__ )
98
				. ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
99
		}
100
101
		return file_get_contents( $input_file );
102
	}
103
104
	protected function initParser() {
105
		global $wgParserConf;
106
		$parserClass = $wgParserConf['class'];
107
		$this->parser = new $parserClass();
108
	}
109
110
	/**
111
	 * Title object to use for CLI parsing.
112
	 * Default title is 'CLIParser', it can be overridden with the option
113
	 * --title <Your:Title>
114
	 *
115
	 * @return Title
116
	 */
117
	protected function getTitle() {
118
		$title = $this->getOption( 'title' )
119
			? $this->getOption( 'title' )
120
			: 'CLIParser';
121
122
		return Title::newFromText( $title );
123
	}
124
125
	/**
126
	 * @param string $wikitext Wikitext to parse
127
	 * @return ParserOutput
128
	 */
129
	protected function parse( $wikitext ) {
130
		return $this->parser->parse(
131
			$wikitext,
132
			$this->getTitle(),
133
			new ParserOptions()
134
		);
135
	}
136
}
137
138
$maintClass = "CLIParser";
139
require_once RUN_MAINTENANCE_IF_MAIN;
140