Issues (48)

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.

maintenance/rebuildJSONData.php (3 issues)

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
$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/../../..';
4
require_once $basePath . '/maintenance/Maintenance.php';
5
6
7
/**
8
 * Class for handling the rebuilding process of JSON namespaces
9
 * @author Toni Hermoso
10
 */
11
12
class RebuildJSONData extends Maintenance {
13
	
14
	public function __construct() {
15
		parent::__construct();
16
		$this->addDescription( "\n" .
17
			"Script for rebuilding data stored in JSON stores\n"
18
		);
19
		$this->addDefaultParams();
20
	}
21
22
	/**
23
	 * @see Maintenance::addDefaultParams
24
	 */
25
	protected function addDefaultParams() {
26
		$this->addOption( 'namespace', '<namespace> Namespace index number to be refreshed.', true, true, "ns" );
27
		$this->addOption( 'dryrun', '<dryRun> If you don\'t really want to refresh information', false, false, "dr" );
28
		$this->addOption( 'u', 'User to run the script', false, true );
29
	}
30
	
31
	/**
32
	 * @see Maintenance::execute
33
	 */
34
	public function execute() {
35
		
36
		if ( !defined( 'SMW_VERSION' ) || !$GLOBALS['smwgSemanticsEnabled'] ) {
37
			
38
			$this->reportMessage( "\nYou need to have SMW enabled in order to run this maintenance script!\n" );
39
			return false;
40
		}
41
		
42
		$ns = $this->getOption( "namespace", null ); 
43
		$dryRun = $this->getOption( "dryrun", false); 
44
		$u = $this->getOption( 'u', false );
45
46
		$reportingInterval = 100;
47
		$dbr = wfGetDB( DB_SLAVE );
48
		$ns_restrict = "page_namespace > -1";
49
		$tables = array('page');
50
		
51
		$seltables = array( 'page_id' );
52
		// Need to do for NS
53
		if ( $ns > -1 ) {
54
			if ( is_numeric( $ns ) ) {
55
				$ns_restrict = "page_namespace = $ns";
56
			}
57
		}
58
59
		// Default, no user
60
		$user = null;
61
		if ( $u ) {
62
			// $user = User::newSystemUser("SDImport");
63
			$user = User::newFromName( $u );
64
		}
65
		
66
67
		$res = $dbr->select( $tables,
68
			$seltables,
69
			array(
70
				$ns_restrict ),
71
			__METHOD__
72
		);
73
		$num = $dbr->numRows( $res );
74
		$this->output( "$num articles...\n" );
75
		$i = 0;
76
		foreach ( $res as $row ) {
77
			if ( !( ++$i % $reportingInterval ) ) {
78
				$this->output( "$i\n" );
79
				wfWaitForSlaves(); // Doubt if necessary
80
			}
81
			if ( ! $dryRun ) {
82
				self::refreshArticle( $row->page_id, $user );
83
			}
84
		}
85
86
	}
87
	
88
	
89
	/**
90
	 * Run fixEditFromArticle for all links on a given page_id (and a user)
91
	 * @param $id int The page_id
92
	 */
93
	public static function refreshArticle( $pageid, $user ) {
94
95
		$wikipage = WikiPage::newFromID( $pageid );
96
	
97
		if ( $wikipage === null ) {
98
			return;
99
		}
100
101
		// Check compatibility. Only if newer versions of MW
102
		if ( method_exists ( $wikipage, "getContent" ) ) {
103
			$contentModel = $wikipage->getContentModel();
104
			if ( $contentModel === "json" || ! $wikipage->exists() ) {
105
106
				// Retrigger import
107
				$statusValue = new StatusValue();
108
				$statusValue->setOK(true);
109
				$status = new Status();
110
				$status->wrap( $statusValue );
111
112
                // TODO: To be fixed	
113
				SDImportData::saveJSONData( $wikipage, $user, $wikipage->getContent(), "Rebuild JSON", 0, null, null, 2, $wikipage->getRevision(), $status, false );
0 ignored issues
show
0 is of type integer, 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...
null is of type null, 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...
false is of type boolean, but the function expects a integer.

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...
114
				// $status = $wikipage->doEditContent( $wikipage->getContent(), "Rebuild", EDIT_FORCE_BOT, false, $user );
115
				// $status = SDImportData::importJSON( $wikipage->getContent()->getNativeData(), $wikipage->getTitle()->getPrefixedText(), true );
116
			}
117
		}
118
		
119
	}
120
	
121
}
122
123
124
$maintClass = 'RebuildJSONData';
125
require_once( DO_MAINTENANCE );
126