Issues (165)

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.

Includes/Peachy.php (1 issue)

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
/**
4
 * Base Peachy class, used to generate all other classes
5
 */
6
class Peachy {
7
8
	/**
9
	 * Initializes Peachy, logs in with a either the configuration file or a given username and password
10
	 *
11
	 * @static
12
	 * @access public
13
	 *
14
	 * @param string $config_name Name of the config file stored in the Configs directory, minus the .cfg extension. Default null
15
	 * @param string $pgUsername Username to log in if no config file specified. Default null
16
	 * @param string $password Password to log in with if no config file specified. Default null
17
	 * @param string $base_url URL to api.php if no config file specified. Defaults to English Wikipedia's API.
18
	 * @param string $classname
19
	 *
20
	 * @throws LoginError
21
	 * @return Wiki                Instance of the Wiki class, where most functions are stored
22
	 */
23
	public static function newWiki( $config_name = null, $pgUsername = null, $password = null, $base_url = 'http://en.wikipedia.org/w/api.php', $classname = 'Wiki' ) {
24
		pecho( "Loading Peachy (version " . PEACHYVERSION . ")...\n\n", PECHO_NORMAL );
25
		/*$updater = new AutoUpdate();
26
		$Uptodate = $updater->Checkforupdate();
27
		if( !$Uptodate ) $updater->updatePeachy();*/
28
29
		if( !is_null( $config_name ) ) {
30
			$config_params = self::parse_config( $config_name );
31
32
		} else {
33
			$config_params = array(
34
				'username' => $pgUsername,
35
				'password' => $password,
36
				'baseurl'  => $base_url,
37
				'method'   => 'legacy'
38
			);
39
40
		}
41
42
		if( is_null( $config_params['baseurl'] ) || !isset( $config_params['baseurl'] ) ) {
43
			throw new LoginError( array( "MissingParam", "The baseurl parameter was not set." ) );
44
		}
45
46
		if( !isset( $config_params['username'] ) ) {
47
			$config_params['nologin'] = true;
48
		}
49
		if( !isset( $config_params['password'] ) && isset( $config_params['method'] ) && $config_params['method'] == "legacy" ) {
50
			$config_params['nologin'] = true;
51
		}
52
53
		list( $version, $extensions ) = self::wikiChecks( $config_params['baseurl'] );
54
55
		Hooks::runHook( 'StartLogin', array( &$config_params, &$extensions ) );
56
57
		$w = new $classname( $config_params, $extensions, false, null );
58
		$w->mwversion = $version;
59
60
		return $w;
61
	}
62
63
	/**
64
	 * Performs various checks and settings
65
	 * Checks if MW version is at least {@link MINMW}
66
	 *
67
	 * @static
68
	 * @access    public
69
	 * @param    string $base_url URL to api.php
70
	 * @throws    DependencyError|string
71
	 * @return    array                                    Installed extensions
72
	 */
73
	public static function wikiChecks( $base_url ) {
74
		$http = HTTP::getDefaultInstance();
75
76
		$siteInfo = unserialize(
77
			$http->get(
78
				$base_url,
79
				array(
80
					'action' => 'query',
81
					'meta'   => 'siteinfo',
82
					'format' => 'php',
83
					'siprop' => 'extensions|general',
84
				)
85
			)
86
		);
87
88
		if (isset($siteInfo['error']) && $siteInfo['error']['code'] == 'readapidenied') {
89
			global $pgHooks;
90
			$pgHooks['PostLogin'][] = array( 'Peachy::wikiChecks', $base_url );
91
			return array( MINMW, array() );
92
		}
93
94
		$version = preg_replace('/[^0-9\.]/', '', $siteInfo['query']['general']['generator']);
95
96
		if( version_compare( $version, MINMW ) < 0 ) {
97
			throw new DependencyError( "MediaWiki " . MINMW, "http://mediawiki.org" );
0 ignored issues
show
'http://mediawiki.org' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
98
		}
99
100
		$extensions = array();
101
102
		foreach ($siteInfo['query']['extensions'] as $ext) {
103
			if( isset( $ext['version'] ) ) {
104
				$extensions[$ext['name']] = $ext['version'];
105
			} else {
106
				$extensions[$ext['name']] = '';
107
			}
108
		}
109
110
		return array( $version, $extensions );
111
	}
112
113
	/**
114
	 * Checks for config files, parses them.
115
	 *
116
	 * @access    private
117
	 * @static
118
	 * @param    string $config_name Name of config file
119
	 * @throws    BadEntryError
120
	 * @return    array                            Config params
121
	 */
122
	private static function parse_config( $config_name ) {
123
		global $pgIP;
124
		if( !is_file( $config_name ) ) {
125
			if( !is_file( $pgIP . 'Configs/' . $config_name . '.cfg' ) ) {
126
				throw new BadEntryError( "BadConfig", "A non-existent configuration file was specified." );
127
			} else {
128
				$config_name = $pgIP . 'Configs/' . $config_name . '.cfg';
129
			}
130
		}
131
132
		$config_params = parse_ini_file( $config_name );
133
134
		if( isset( $config_params['useconfig'] ) ) {
135
			$config_params = $config_params + self::parse_config( $config_params['useconfig'] );
136
		}
137
138
		return $config_params;
139
	}
140
141
	/**
142
	 * Function that displays an error message when an End-User attempts to use a function no longer included in Peachy
143
	 *
144
	 * @param null|string $method
145
	 * @param null|string $newFunction
146
	 * @param string $message
147
	 */
148
	public static function deprecatedWarn($method, $newFunction, $message = null)
149
	{
150
		if( is_null( $message ) ) {
151
			$message = "Warning: $method is deprecated. Please use $newFunction instead.";
152
		}
153
154
		$message = "[$message|YELLOW_BAR]\n\n";
155
156
		pecho( $message, PECHO_WARN, 'cecho' );
157
	}
158
159
	/**
160
	 * Checks for and returns an SVN repository version.
161
	 *
162
	 * @return array|bool
163
	 */
164
	public static function getSvnInfo() {
165
		global $pgIP;
166
167
		// http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
168
		$entries = $pgIP . '/.svn/entries';
169
170
		if( !file_exists( $entries ) ) {
171
			return false;
172
		}
173
174
		$lines = file( $entries );
175
		if( !count( $lines ) ) {
176
			return false;
177
		}
178
179
		// check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
180
		if( preg_match( '/^<\?xml/', $lines[0] ) ) {
181
			return false;
182
		}
183
184
		// Subversion is release 1.4 or above.
185
		if( count( $lines ) < 11 ) {
186
			return false;
187
		}
188
189
		$info = array(
190
			'checkout-rev'  => intval( trim( $lines[3] ) ),
191
			'url'           => trim( $lines[4] ),
192
			'repo-url'      => trim( $lines[5] ),
193
			'directory-rev' => intval( trim( $lines[10] ) )
194
		);
195
196
		return $info;
197
	}
198
}
199