Issues (1401)

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.

client/includes/OtherProjectsSitesGenerator.php (1 issue)

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
namespace Wikibase\Client;
4
5
use Site;
6
use SiteLookup;
7
8
/**
9
 * Generates a list of sites that should be displayed in the "Other projects" sidebar.
10
 *
11
 * @license GPL-2.0-or-later
12
 * @author Thomas Pellissier Tanon
13
 * @author Marius Hoch < [email protected] >
14
 */
15
class OtherProjectsSitesGenerator implements OtherProjectsSitesProvider {
16
17
	/**
18
	 * @var SiteLookup
19
	 */
20
	private $siteLookup;
21
22
	/**
23
	 * @var string
24
	 */
25
	private $localSiteId;
26
27
	/**
28
	 * @var string[]
29
	 */
30
	private $specialSiteGroups;
31
32
	/**
33
	 * @param SiteLookup $siteLookup
34
	 * @param string $localSiteId
35
	 * @param string[] $specialSiteGroups
36
	 */
37
	public function __construct( SiteLookup $siteLookup, $localSiteId, array $specialSiteGroups ) {
38
		$this->siteLookup = $siteLookup;
39
		$this->localSiteId = $localSiteId;
40
		$this->specialSiteGroups = $specialSiteGroups;
41
	}
42
43
	/**
44
	 * Get the site ids of other projects to use.
45
	 *
46
	 * @param array $siteLinkGroups
47
	 * @return string[]
48
	 */
49
	public function getOtherProjectsSiteIds( array $siteLinkGroups ) {
50
		$localSite = $this->getLocalSite();
51
52
		if ( $localSite === null ) {
53
			wfWarn( 'Site not found for ' . $this->localSiteId );
54
			return [];
55
		}
56
57
		$currentGroupId = $localSite->getGroup();
58
		$otherProjectsSiteIds = [];
59
60
		$this->expandSpecialGroups( $siteLinkGroups );
61
		foreach ( $siteLinkGroups as $groupId ) {
62
			if ( $groupId === $currentGroupId ) {
63
				continue;
64
			}
65
66
			$siteToAdd = $this->getSiteForGroup( $groupId, $localSite->getLanguageCode() );
0 ignored issues
show
Are you sure the assignment to $siteToAdd is correct as $this->getSiteForGroup($...ite->getLanguageCode()) (which targets Wikibase\Client\OtherPro...ator::getSiteForGroup()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
67
			if ( $siteToAdd ) {
68
				$otherProjectsSiteIds[] = $siteToAdd->getGlobalId();
69
			}
70
		}
71
72
		return $otherProjectsSiteIds;
73
	}
74
75
	/**
76
	 * Returns the site to link to for a given group or null
77
	 *
78
	 * If there is only one site in this group (like for commons) this site is returned else the site in the same language
79
	 * as the current site is returned
80
	 *
81
	 * @param string $groupId
82
	 * @param string $currentLanguageCode
83
	 *
84
	 * @return Site|null
85
	 */
86
	private function getSiteForGroup( $groupId, $currentLanguageCode ) {
87
		$siteGroupList = $this->siteLookup->getSites()->getGroup( $groupId );
88
		if ( $siteGroupList->count() === 1 ) {
89
			return $siteGroupList[0];
90
		}
91
92
		/** @var Site $site */
93
		foreach ( $siteGroupList as $site ) {
94
			if ( $site->getLanguageCode() === $currentLanguageCode ) {
95
				return $site;
96
			}
97
		}
98
99
		return null;
100
	}
101
102
	/**
103
	 * @param array &$groups
104
	 */
105
	private function expandSpecialGroups( &$groups ) {
106
		if ( !in_array( 'special', $groups ) ) {
107
			return;
108
		}
109
110
		$groups = array_diff( $groups, [ 'special' ] );
111
		$groups = array_merge( $groups, $this->specialSiteGroups );
112
	}
113
114
	/**
115
	 * @return Site
116
	 */
117
	private function getLocalSite() {
118
		return $this->siteLookup->getSite( $this->localSiteId );
119
	}
120
121
}
122