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.

Plugins/FlaggedRevs.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
/**
4
 * This file is part of Peachy MediaWiki Bot API
5
 *
6
 * Peachy is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
class FlaggedRevs {
21
22
	private $wiki;
23
24
    /**
25
     * @param Wiki $wikiClass
26
     * @throws DependencyError
27
     */
28
	function __construct( Wiki &$wikiClass ) {
29
30
		if( !array_key_exists( 'FlaggedRevs', $wikiClass->get_extensions() ) ) {
31
			throw new DependencyError( "FlaggedRevs", "http://www.mediawiki.org/wiki/Extension:FlaggedRevs" );
32
		}
33
34
		$this->wiki = $wikiClass;
35
	}
36
37
    /**
38
     * @param $revid
39
     * @param null $reason
40
     * @param int $status
41
     * @return bool
42
     * @throws AssertFailure
43
     * @throws BadEntryError
44
     * @throws HookError
45
     * @throws LoggedOut
46
     * @throws MWAPIError
47
     */
48
	public function review( $revid, $reason = null, $status = 1 ) {
49
50
		if( !in_array( 'review', $this->wiki->get_userrights() ) ) {
51
			pecho( "User is not allowed to review revisions", PECHO_FATAL );
52
			return false;
53
		}
54
55
		$tokens = $this->wiki->get_tokens();
56
57
		if( $tokens['edit'] == '+\\' ) {
58
			pecho( "User has logged out.\n\n", PECHO_FATAL );
59
			return false;
60
		}
61
62
		if( mb_strlen( $reason, '8bit' ) > 255 ) {
63
			pecho( "Comment is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL );
64
			return false;
65
		}
66
67
		pecho( "Reviewing $revid...\n\n", PECHO_NOTICE );
68
69
		$editarray = array(
70
			'flag_accuracy' => $status,
71
			'action'        => 'review',
72
			'token'         => $tokens['edit'],
73
			'revid'         => $revid
74
		);
75
76
		if( !empty( $reason ) ) $editArray['comment'] = $reason;
77
78
		if( $this->wiki->get_maxlag() ) {
79
			$editarray['maxlag'] = $this->wiki->get_maxlag();
80
		}
81
82
		Hooks::runHook( 'StartReview', array( &$editarray ) );
83
84
		$result = $this->wiki->apiQuery( $editarray, true );
85
86
		if( isset( $result['review'] ) ) {
87
			if( isset( $result['review']['revid'] ) ) {
88
				return true;
89
			} else {
90
				pecho( "Review error...\n\n" . print_r( $result['review'], true ) . "\n\n", PECHO_FATAL );
91
				return false;
92
			}
93
		} else {
94
			pecho( "Review error...\n\n" . print_r( $result, true ), PECHO_FATAL );
95
			return false;
96
		}
97
	}
98
99
    /**
100
     * @param $title
101
     * @param string $level
102
     * @param null $reason
103
     * @param bool|false $autoreview
104
     * @param bool|false $watch
105
     * @return bool
106
     * @throws AssertFailure
107
     * @throws BadEntryError
108
     * @throws HookError
109
     * @throws LoggedOut
110
     * @throws MWAPIError
111
     */
112
	public function stabilize( $title, $level = 'none', $reason = null, $autoreview = false, $watch = false ) {
113
114
		if( !in_array( 'stablesettings', $this->wiki->get_userrights() ) ) {
115
			pecho( "User is not allowed to change the stabilization settings", PECHO_FATAL );
116
			return false;
117
		}
118
119
		$tokens = $this->wiki->get_tokens();
120
121
		if( $tokens['edit'] == '+\\' ) {
122
			pecho( "User has logged out.\n\n", PECHO_FATAL );
123
			return false;
124
		}
125
126
		if( mb_strlen( $reason, '8bit' ) > 255 ) {
127
			pecho( "Comment is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL );
128
			return false;
129
		}
130
131
		pecho( "Stabilizing title...\n\n", PECHO_NOTICE );
132
133
		$editarray = array(
134
			'action'       => 'review',
135
			'title'        => $title,
136
			'token'        => $tokens['edit'],
137
			'protectlevel' => $level
138
		);
139
140
		if( $watch ) $editArray['watch'] = 'yes';
141
		if( !empty( $reason ) ) $editArray['reason'] = $reason;
0 ignored issues
show
The variable $editArray does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
142
143
		if( $this->wiki->get_maxlag() ) {
144
			$editarray['maxlag'] = $this->wiki->get_maxlag();
145
		}
146
147
		Hooks::runHook( 'StartStabilize', array( &$editarray ) );
148
149
		$result = $this->wiki->apiQuery( $editarray, true );
150
151
		if( isset( $result['stabilize'] ) ) {
152
			if( isset( $result['stabilize']['title'] ) ) {
153
				return true;
154
			} else {
155
				pecho( "Stabilization error...\n\n" . print_r( $result['stabilize'], true ) . "\n\n", PECHO_FATAL );
156
				return false;
157
			}
158
		} else {
159
			pecho( "Stabilization error...\n\n" . print_r( $result, true ), PECHO_FATAL );
160
			return false;
161
		}
162
163
	}
164
165
	public function flagconfig() { }
166
167
	public function reviewedpages() { }
168
169
	public function unreviewedpages() { }
170
171
	public function oldreviewedpages() { }
172
173
}
174